-
Notifications
You must be signed in to change notification settings - Fork 11k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: User sound preferences master volume and ringing volume (#33902)
- Loading branch information
1 parent
ef0c5eb
commit d1e6a73
Showing
71 changed files
with
179 additions
and
104 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
--- | ||
"@rocket.chat/meteor": patch | ||
"@rocket.chat/i18n": patch | ||
--- | ||
|
||
Adds "Master volume" and "Call ringer volume" to the user preferences sound section. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
10 changes: 10 additions & 0 deletions
10
apps/meteor/app/utils/client/getUserNotificationsSoundVolume.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import type { IUser } from '@rocket.chat/core-typings'; | ||
|
||
import { getUserPreference } from './lib/getUserPreference'; | ||
|
||
export const getUserNotificationsSoundVolume = (userId: IUser['_id'] | null | undefined) => { | ||
const masterVolume = getUserPreference<number>(userId, 'masterVolume', 100); | ||
const notificationsSoundVolume = getUserPreference<number>(userId, 'notificationsSoundVolume', 100); | ||
|
||
return (notificationsSoundVolume * masterVolume) / 100; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import { useUserPreference } from '@rocket.chat/ui-contexts'; | ||
|
||
const relativeVolume = (volume: number, masterVolume: number) => { | ||
return (volume * masterVolume) / 100; | ||
}; | ||
|
||
export const useUserSoundPreferences = () => { | ||
const masterVolume = useUserPreference<number>('masterVolume', 100) || 100; | ||
const notificationsSoundVolume = useUserPreference<number>('notificationsSoundVolume', 100) || 100; | ||
const voipRingerVolume = useUserPreference<number>('voipRingerVolume', 100) || 100; | ||
|
||
return { | ||
masterVolume, | ||
notificationsSoundVolume: relativeVolume(notificationsSoundVolume, masterVolume), | ||
voipRingerVolume: relativeVolume(voipRingerVolume, masterVolume), | ||
}; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.