Skip to content

Commit

Permalink
Chore: deprecate refreshClients methods (#26956)
Browse files Browse the repository at this point in the history
Co-authored-by: Guilherme Gazzo <5263975+ggazzo@users.noreply.github.com>
  • Loading branch information
2 people authored and MartinSchoeler committed Nov 28, 2022
1 parent af06a59 commit f586197
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 27 deletions.
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

0 comments on commit f586197

Please sign in to comment.