Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Chore: deprecate refreshClients methods #26956

Merged
merged 11 commits into from
Nov 22, 2022
3 changes: 3 additions & 0 deletions apps/meteor/app/assets/server/assets.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import { getURL } from '../../utils/lib/getURL';
import { getExtension } from '../../utils/lib/mimeTypes';
import { hasPermission } from '../../authorization/server';
import { RocketChatFile } from '../../file';
import { methodDeprecationLogger } from '../../lib/server/lib/deprecationWarningLogger';

const RocketChatAssetsInstance = new RocketChatFile.GridFS({
name: 'assets',
Expand Down Expand Up @@ -416,6 +417,8 @@ WebAppHashing.calculateClientHash = function (manifest, includeFilter, runtimeCo

Meteor.methods({
refreshClients() {
methodDeprecationLogger.warn('refreshClients will be deprecated in future versions of Rocket.Chat');

if (!Meteor.userId()) {
throw new Meteor.Error('error-invalid-user', 'Invalid user', {
method: 'refreshClients',
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
import { ISetting } from '@rocket.chat/core-typings';
import { Button } from '@rocket.chat/fuselage';
import { useToastMessageDispatch, useMethod, useTranslation } from '@rocket.chat/ui-contexts';
import React, { memo, ReactElement } from 'react';

import { useEditableSettingsGroupSections } from '../../EditableSettingsContext';
Expand All @@ -12,33 +10,9 @@ type AssetsGroupPageProps = ISetting;
function AssetsGroupPage({ _id, ...group }: AssetsGroupPageProps): ReactElement {
const sections = useEditableSettingsGroupSections(_id);
const solo = sections.length === 1;
const t = useTranslation();

const refreshClients = useMethod('refreshClients');
const dispatchToastMessage = useToastMessageDispatch();

const handleApplyAndRefreshAllClientsButtonClick = async (): Promise<void> => {
try {
await refreshClients();
dispatchToastMessage({
type: 'success',
message: t('Clients_will_refresh_in_a_few_seconds'),
});
} catch (error) {
dispatchToastMessage({ type: 'error', message: error });
}
};

return (
<GroupPage
_id={_id}
{...group}
headerButtons={
<>
<Button onClick={handleApplyAndRefreshAllClientsButtonClick}>{t('Apply_and_refresh_all_clients')}</Button>
</>
}
>
<GroupPage _id={_id} {...group}>
{sections.map((sectionName) => (
<Section key={sectionName} groupId={_id} hasReset={false} sectionName={sectionName} solo={solo} />
))}
Expand Down