Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion apps/meteor/client/main.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import './serviceWorker';
import './startup/accounts';
import './startup/fakeUserPresence';
import './startup/desktopInjection';

import('@rocket.chat/fuselage-polyfills')
.then(() => import('./meteor/overrides'))
Expand Down
32 changes: 32 additions & 0 deletions apps/meteor/client/startup/desktopInjection.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import { watch } from '../meteor/watch';
import { PublicSettings } from '../stores';

if (window.RocketChatDesktop) {
// backport of rocketchat:user-presence for the desktop app
const fakeUserPresenceModule = {
UserPresence: {
awayTime: undefined,
start: () => undefined,
},
};

// backport of settings module for the desktop app
const fakeSettingsModule = {
settings: {
get: (settingId: string) => watch(PublicSettings.use, (state) => state.get(settingId)?.value),
},
};

window.require = ((fn) =>
Object.assign((id: string) => {
if (id === 'meteor/rocketchat:user-presence') {
return fakeUserPresenceModule;
}

if (id === '/app/settings/client/index.ts') {
return fakeSettingsModule;
}

return fn(id);
}, fn))(window.require);
}
18 changes: 0 additions & 18 deletions apps/meteor/client/startup/fakeUserPresence.ts

This file was deleted.

4 changes: 4 additions & 0 deletions apps/meteor/client/views/root/AppLayout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ import { useNextcloudOAuth } from './hooks/customOAuth/useNextcloudOAuth';
import { useTokenpassOAuth } from './hooks/customOAuth/useTokenpassOAuth';
import { useWordPressOAuth } from './hooks/customOAuth/useWordPressOAuth';
import { useCodeHighlight } from './hooks/useCodeHighlight';
import { useDesktopFavicon } from './hooks/useDesktopFavicon';
import { useDesktopTitle } from './hooks/useDesktopTitle';
import { useEscapeKeyStroke } from './hooks/useEscapeKeyStroke';
import { useGoogleTagManager } from './hooks/useGoogleTagManager';
import { useLoadMissedMessages } from './hooks/useLoadMissedMessages';
Expand Down Expand Up @@ -65,6 +67,8 @@ const AppLayout = () => {
useCodeHighlight();
useLoginViaQuery();
useLoadMissedMessages();
useDesktopFavicon();
useDesktopTitle();

const layout = useSyncExternalStore(appLayout.subscribe, appLayout.getSnapshot);

Expand Down
19 changes: 19 additions & 0 deletions apps/meteor/client/views/root/hooks/useDesktopFavicon.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import { useAbsoluteUrl, useAssetPath } from '@rocket.chat/ui-contexts';
import { useEffect } from 'react';

const { RocketChatDesktop } = window;
Comment thread
coderabbitai[bot] marked this conversation as resolved.
Outdated

export const useDesktopFavicon = () => {
const absoluteUrl = useAbsoluteUrl();

useEffect(() => {
RocketChatDesktop?.setUrlResolver((relativePath?: string) => absoluteUrl(relativePath ?? '/'));
}, [absoluteUrl]);

const faviconUrl = useAssetPath('favicon');

useEffect(() => {
if (!faviconUrl) return;
RocketChatDesktop?.setFavicon(faviconUrl);
}, [faviconUrl]);
};
13 changes: 13 additions & 0 deletions apps/meteor/client/views/root/hooks/useDesktopTitle.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import { useSetting } from '@rocket.chat/ui-contexts';
import { useEffect } from 'react';

const { RocketChatDesktop } = window;

export const useDesktopTitle = () => {
const title = useSetting('Site_Name', 'Rocket.Chat');

useEffect(() => {
if (!title) return;
RocketChatDesktop?.setTitle(title);
}, [title]);
Comment thread
coderabbitai[bot] marked this conversation as resolved.
Outdated
};
Loading