chore: Remove meteor cached collection startup for anons (#33975)

pull/34006/head
Tiago Evangelista Pinto 2 years ago committed by GitHub
parent 2db1ecb0ef
commit 8f8e413b35
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 16
      apps/meteor/client/hooks/useLoadRoomForAllowedAnonymousRead.ts
  2. 14
      apps/meteor/client/startup/collections.ts
  3. 1
      apps/meteor/client/startup/index.ts
  4. 2
      apps/meteor/client/views/root/AppLayout.tsx

@ -0,0 +1,16 @@
import { useSetting, useUserId } from '@rocket.chat/ui-contexts';
import { useEffect } from 'react';
import { CachedChatRoom, CachedChatSubscription } from '../../app/models/client';
export const useLoadRoomForAllowedAnonymousRead = () => {
const userId = useUserId();
const accountsAllowAnonymousRead = useSetting('Accounts_AllowAnonymousRead');
useEffect(() => {
if (!userId && accountsAllowAnonymousRead === true) {
CachedChatRoom.init();
CachedChatSubscription.ready.set(true);
}
}, [accountsAllowAnonymousRead, userId]);
};

@ -1,14 +0,0 @@
import { Meteor } from 'meteor/meteor';
import { Tracker } from 'meteor/tracker';
import { CachedChatRoom, CachedChatSubscription } from '../../app/models/client';
import { settings } from '../../app/settings/client';
Meteor.startup(() => {
Tracker.autorun(() => {
if (!Meteor.userId() && settings.get('Accounts_AllowAnonymousRead') === true) {
CachedChatRoom.init();
CachedChatSubscription.ready.set(true);
}
});
});

@ -5,7 +5,6 @@ import './afterLogoutCleanUp';
import './appRoot';
import './audit';
import './callbacks';
import './collections';
import './customOAuth';
import './deviceManagement';
import './e2e';

@ -8,6 +8,7 @@ import { useGoogleTagManager } from './hooks/useGoogleTagManager';
import { useMessageLinkClicks } from './hooks/useMessageLinkClicks';
import { useAnalytics } from '../../../app/analytics/client/loadScript';
import { useAnalyticsEventTracking } from '../../hooks/useAnalyticsEventTracking';
import { useLoadRoomForAllowedAnonymousRead } from '../../hooks/useLoadRoomForAllowedAnonymousRead';
import { useNotifyUser } from '../../hooks/useNotifyUser';
import { appLayout } from '../../lib/appLayout';
@ -25,6 +26,7 @@ const AppLayout = () => {
useAnalytics();
useEscapeKeyStroke();
useAnalyticsEventTracking();
useLoadRoomForAllowedAnonymousRead();
useNotifyUser();
const layout = useSyncExternalStore(appLayout.subscribe, appLayout.getSnapshot);

Loading…
Cancel
Save