Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
8 changes: 8 additions & 0 deletions .changeset/spicy-radios-sleep.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
"@rocket.chat/meteor": minor
"@rocket.chat/i18n": minor
"@rocket.chat/rest-typings": minor
"@rocket.chat/ui-voip": minor
---

Introduces a new user preference to enable/disable desktop voice call notifications.
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ const PreferencesNotificationsSection = () => {
const notifyCalendarEventsId = useId();
const enableMobileRingingId = useId();
const desktopNotificationsLabelId = useId();
const desktopNotificationVoiceCallsId = useId();

const showCalendarPreference = user?.settings?.calendar?.outlook?.Enabled;

Expand Down Expand Up @@ -151,6 +152,18 @@ const PreferencesNotificationsSection = () => {
/>
</FieldRow>
</Field>
<Field>
<FieldRow>
<FieldLabel htmlFor={desktopNotificationVoiceCallsId}>{t('Notification_Desktop_show_voice_calls')}</FieldLabel>
<Controller
name='desktopNotificationVoiceCalls'
control={control}
render={({ field: { ref, value, onChange } }) => (
<ToggleSwitch id={desktopNotificationVoiceCallsId} ref={ref} checked={value} onChange={onChange} />
)}
/>
</FieldRow>
</Field>
<Field>
<FieldLabel is='span' id={pushNotificationsId}>
{t('Notification_Push_Default_For')}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ export type AccountPreferencesData = {
masterVolume?: number;
notificationsSoundVolume?: number;
voipRingerVolume?: number;
desktopNotificationVoiceCalls?: boolean;
};

export const useAccountPreferencesValues = (): AccountPreferencesData => {
Expand Down Expand Up @@ -77,6 +78,8 @@ export const useAccountPreferencesValues = (): AccountPreferencesData => {
const notificationsSoundVolume = useUserPreference<number>('notificationsSoundVolume', 100);
const voipRingerVolume = useUserPreference<number>('voipRingerVolume', 100);

const desktopNotificationVoiceCalls = useUserPreference<boolean>('desktopNotificationVoiceCalls');

return {
language,
dontAskAgainList,
Expand Down Expand Up @@ -107,5 +110,6 @@ export const useAccountPreferencesValues = (): AccountPreferencesData => {
masterVolume,
notificationsSoundVolume,
voipRingerVolume,
desktopNotificationVoiceCalls,
};
};
5 changes: 5 additions & 0 deletions apps/meteor/server/settings/accounts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -457,6 +457,11 @@ export const createAccountSettings = () =>
],
public: true,
});
await this.add('Accounts_Default_User_Preferences_desktopNotificationVoiceCalls', true, {
type: 'boolean',
public: true,
i18nLabel: 'Notification_Desktop_show_voice_calls',
});
await this.add('Accounts_Default_User_Preferences_pushNotifications', 'all', {
type: 'select',
values: [
Expand Down
1 change: 1 addition & 0 deletions apps/meteor/tests/end-to-end/api/miscellaneous.ts
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,7 @@ describe('miscellaneous', () => {
'notifyCalendarEvents',
'enableMobileRinging',
'featuresPreview',
'desktopNotificationVoiceCalls',
].filter((p) => Boolean(p));

expect(res.body).to.have.property('success', true);
Expand Down
1 change: 1 addition & 0 deletions packages/i18n/src/locales/en.i18n.json
Original file line number Diff line number Diff line change
Expand Up @@ -3764,6 +3764,7 @@
"Nothing_found": "Nothing found",
"Notice_that_public_channels_will_be_public_and_visible_to_everyone": "Notice that public Channels will be public and visible to everyone.",
"Notification_Desktop_Default_For": "Show Desktop Notifications For",
"Notification_Desktop_show_voice_calls": "Show desktop notifications for voice calls",
"Notification_Push_Default_For": "Send Push Notifications For",
"Notification_RequireInteraction": "Require Interaction to Dismiss Desktop Notification",
"Notification_RequireInteraction_Description": "Works only with Chrome browser versions > 50. Utilizes the parameter *requireInteraction* to show the desktop notification to indefinite until the user interacts with it.",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ export type UsersSetPreferencesParamsPOST = {
omnichannelHideConversationAfterClosing?: boolean;
enableMobileRinging?: boolean;
mentionsWithSymbol?: boolean;
desktopNotificationVoiceCalls?: boolean;
};
};

Expand Down Expand Up @@ -265,6 +266,10 @@ const UsersSetPreferencesParamsPostSchema = {
type: 'boolean',
nullable: true,
},
desktopNotificationVoiceCalls: {
type: 'boolean',
nullable: true,
},
},
required: [],
additionalProperties: false,
Expand Down
8 changes: 7 additions & 1 deletion packages/ui-voip/src/v2/useDesktopNotifications.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { useUserPreference } from '@rocket.chat/ui-contexts';
import { useEffect, useRef } from 'react';
import { useTranslation } from 'react-i18next';

Expand All @@ -22,9 +23,14 @@ const getDisplayInfo = (peerInfo?: PeerInfo) => {
export const useDesktopNotifications = (sessionInfo: SessionInfo) => {
const previousCallId = useRef<string | undefined>(undefined);
const { t } = useTranslation();
const desktopNotificationsEnabled = useUserPreference('desktopNotificationVoiceCalls');

const displayInfo = getDisplayInfo(sessionInfo.peerInfo);
useEffect(() => {
if (!desktopNotificationsEnabled) {
return;
}

if (
typeof window.RocketChatDesktop?.dispatchCustomNotification !== 'function' ||
typeof window.RocketChatDesktop?.closeCustomNotification !== 'function'
Expand Down Expand Up @@ -71,5 +77,5 @@ export const useDesktopNotifications = (sessionInfo: SessionInfo) => {
return () => {
isMounted = false;
};
}, [displayInfo?.avatar, displayInfo?.title, sessionInfo.callId, sessionInfo.state, t]);
}, [displayInfo?.avatar, displayInfo?.title, sessionInfo.callId, sessionInfo.state, t, desktopNotificationsEnabled]);
};
Loading