diff --git a/.changeset/tender-wolves-promise.md b/.changeset/tender-wolves-promise.md new file mode 100644 index 00000000000..234a0129023 --- /dev/null +++ b/.changeset/tender-wolves-promise.md @@ -0,0 +1,5 @@ +--- +'@rocket.chat/meteor': patch +--- + +Fixes the missing dispatch of `startup` iframe event on client startup. diff --git a/apps/meteor/client/startup/startup.ts b/apps/meteor/client/startup/startup.ts index 652b85045f1..45fa6c12b1b 100644 --- a/apps/meteor/client/startup/startup.ts +++ b/apps/meteor/client/startup/startup.ts @@ -10,8 +10,6 @@ import { fireGlobalEvent } from '../lib/utils/fireGlobalEvent'; import { watchUserId } from '../meteor/user'; Meteor.startup(() => { - fireGlobalEvent('startup', true); - let status: UserStatus | undefined = undefined; Tracker.autorun(async () => { const uid = watchUserId(); diff --git a/apps/meteor/client/views/root/AppLayout.tsx b/apps/meteor/client/views/root/AppLayout.tsx index 6daac59b4f8..33b0714ba3d 100644 --- a/apps/meteor/client/views/root/AppLayout.tsx +++ b/apps/meteor/client/views/root/AppLayout.tsx @@ -30,6 +30,7 @@ import { useMessageLinkClicks } from './hooks/useMessageLinkClicks'; import { useNotificationPermission } from './hooks/useNotificationPermission'; import { useRedirectToSetupWizard } from './hooks/useRedirectToSetupWizard'; import { useSettingsOnLoadSiteUrl } from './hooks/useSettingsOnLoadSiteUrl'; +import { useStartupEvent } from './hooks/useStartupEvent'; import { appLayout } from '../../lib/appLayout'; const AppLayout = () => { @@ -69,6 +70,7 @@ const AppLayout = () => { useLoadMissedMessages(); useDesktopFavicon(); useDesktopTitle(); + useStartupEvent(); const layout = useSyncExternalStore(appLayout.subscribe, appLayout.getSnapshot); diff --git a/apps/meteor/client/views/root/hooks/useStartupEvent.ts b/apps/meteor/client/views/root/hooks/useStartupEvent.ts new file mode 100644 index 00000000000..43bbb2451bd --- /dev/null +++ b/apps/meteor/client/views/root/hooks/useStartupEvent.ts @@ -0,0 +1,11 @@ +import { useEffect } from 'react'; + +import { useFireGlobalEvent } from '../../../hooks/useFireGlobalEvent'; + +export const useStartupEvent = () => { + const { mutate: fireStartupEvent } = useFireGlobalEvent('startup', 'global'); + + useEffect(() => { + fireStartupEvent(true); + }, [fireStartupEvent]); +};