From 1e138f9db848024953192d83898ff09b1a18ed52 Mon Sep 17 00:00:00 2001 From: c3024 Date: Wed, 9 Oct 2024 14:43:03 +0530 Subject: [PATCH 1/9] write platform specific mute settings to backend --- src/CONST.ts | 1 + src/ONYXKEYS.ts | 3 ++ src/libs/API/types.ts | 1 + src/libs/actions/User.ts | 40 +++++++++++++++++-- .../settings/Preferences/PreferencesPage.tsx | 15 ++++++- 5 files changed, 55 insertions(+), 5 deletions(-) diff --git a/src/CONST.ts b/src/CONST.ts index 7131fab28bdb..eb6850281ad8 100755 --- a/src/CONST.ts +++ b/src/CONST.ts @@ -515,6 +515,7 @@ const CONST = { ANDROID: 'android', WEB: 'web', DESKTOP: 'desktop', + MOBILEWEB: 'mobileweb', }, PLATFORM_SPECIFIC_KEYS: { CTRL: { diff --git a/src/ONYXKEYS.ts b/src/ONYXKEYS.ts index 2a325bb4a74f..3bac252d396c 100755 --- a/src/ONYXKEYS.ts +++ b/src/ONYXKEYS.ts @@ -118,6 +118,9 @@ const ONYXKEYS = { /** This NVP contains data associated with HybridApp */ NVP_TRYNEWDOT: 'nvp_tryNewDot', + /** Contains the platforms for which the user muted the sounds */ + NVP_MUTED_PLATFORMS: 'nvp_mutedPlatforms', + /** Contains the user preference for the LHN priority mode */ NVP_PRIORITY_MODE: 'nvp_priorityMode', diff --git a/src/libs/API/types.ts b/src/libs/API/types.ts index fe2d176847b2..17322ef10157 100644 --- a/src/libs/API/types.ts +++ b/src/libs/API/types.ts @@ -75,6 +75,7 @@ const WRITE_COMMANDS = { VALIDATE_SECONDARY_LOGIN: 'ValidateSecondaryLogin', UPDATE_PREFERRED_EMOJI_SKIN_TONE: 'UpdatePreferredEmojiSkinTone', UPDATE_CHAT_PRIORITY_MODE: 'UpdateChatPriorityMode', + TOGGLE_PLATFORM_MUTE: 'TogglePlatformMute', SET_CONTACT_METHOD_AS_DEFAULT: 'SetContactMethodAsDefault', UPDATE_THEME: 'UpdateTheme', UPDATE_STATUS: 'UpdateStatus', diff --git a/src/libs/actions/User.ts b/src/libs/actions/User.ts index 9ea29506accc..00176e265cb6 100644 --- a/src/libs/actions/User.ts +++ b/src/libs/actions/User.ts @@ -52,11 +52,13 @@ import * as Session from './Session'; let currentUserAccountID = -1; let currentEmail = ''; +let authToken = ''; Onyx.connect({ key: ONYXKEYS.SESSION, callback: (value) => { currentUserAccountID = value?.accountID ?? -1; currentEmail = value?.email ?? ''; + authToken = value?.authToken ?? ''; }, }); @@ -982,8 +984,39 @@ function clearUserErrorMessage() { Onyx.merge(ONYXKEYS.USER, {error: ''}); } -function setMuteAllSounds(isMutedAllSounds: boolean) { - Onyx.merge(ONYXKEYS.USER, {isMutedAllSounds}); +// function setMuteAllSounds(isMutedAllSounds: boolean) { +// Onyx.merge(ONYXKEYS.USER, {isMutedAllSounds}); +// } + +function togglePlatformMute(platform, mutedPlatforms) { + const isPlatformMuted = mutedPlatforms?.includes(platform); + const newMutedPlatforms = isPlatformMuted + ? mutedPlatforms.filter((mutedPlatform) => mutedPlatform !== platform) + : [...mutedPlatforms, platform]; + + const optimisticData: OnyxUpdate[] = [ + { + onyxMethod: Onyx.METHOD.SET, + key: ONYXKEYS.NVP_MUTED_PLATFORMS, + value: newMutedPlatforms, + }, + ]; + const failureData: OnyxUpdate[] = [ + { + onyxMethod: Onyx.METHOD.SET, + key: ONYXKEYS.NVP_MUTED_PLATFORMS, + value: mutedPlatforms, + }, + ]; + + const parameters: GetTogglePlatformMuteParams = {authToken, platform}; + + API.write(WRITE_COMMANDS.TOGGLE_PLATFORM_MUTE, parameters, { + optimisticData, + failureData, + }); + + // Onyx.merge(ONYXKEYS.USER, {isMutedAllSounds: !isMutedAllSounds}); } /** @@ -1358,7 +1391,8 @@ export { subscribeToUserEvents, updatePreferredSkinTone, setShouldUseStagingServer, - setMuteAllSounds, + // setMuteAllSounds, + togglePlatformMute, clearUserErrorMessage, joinScreenShare, clearScreenShareRequest, diff --git a/src/pages/settings/Preferences/PreferencesPage.tsx b/src/pages/settings/Preferences/PreferencesPage.tsx index f2c5f0366640..8d0b5c89aec7 100755 --- a/src/pages/settings/Preferences/PreferencesPage.tsx +++ b/src/pages/settings/Preferences/PreferencesPage.tsx @@ -19,12 +19,22 @@ import * as User from '@userActions/User'; import CONST from '@src/CONST'; import ONYXKEYS from '@src/ONYXKEYS'; import ROUTES from '@src/ROUTES'; +import getPlatform from '@libs/getPlatform'; +import * as Browser from '@libs/Browser'; function PreferencesPage() { const [priorityMode] = useOnyx(ONYXKEYS.NVP_PRIORITY_MODE); + + let platform = getPlatform(); + if (Browser.isMobile()) { + platform = CONST.PLATFORM.MOBILEWEB; + } + const [mutedPlatforms] = useOnyx(ONYXKEYS.NVP_MUTED_PLATFORMS); + const isPlatformMuted = mutedPlatforms.includes(platform); const [user] = useOnyx(ONYXKEYS.USER); const [preferredTheme] = useOnyx(ONYXKEYS.PREFERRED_THEME); + const styles = useThemeStyles(); const {translate, preferredLocale} = useLocalize(); const {shouldUseNarrowLayout} = useResponsiveLayout(); @@ -79,8 +89,9 @@ function PreferencesPage() { User.togglePlatformMute(platform, mutedPlatforms)} /> From 2595cb8b69cb207c637209550cafc71fffc19776 Mon Sep 17 00:00:00 2001 From: c3024 Date: Wed, 9 Oct 2024 22:03:38 +0530 Subject: [PATCH 2/9] add types --- src/ONYXKEYS.ts | 2 ++ .../API/parameters/TogglePlatformMuteParams.ts | 8 ++++++++ src/libs/API/parameters/index.ts | 1 + src/libs/actions/User.ts | 16 +++++----------- .../settings/Preferences/PreferencesPage.tsx | 9 ++++----- 5 files changed, 20 insertions(+), 16 deletions(-) create mode 100644 src/libs/API/parameters/TogglePlatformMuteParams.ts diff --git a/src/ONYXKEYS.ts b/src/ONYXKEYS.ts index 3bac252d396c..f3755f9acea3 100755 --- a/src/ONYXKEYS.ts +++ b/src/ONYXKEYS.ts @@ -1,4 +1,5 @@ import type {ValueOf} from 'type-fest'; +import type Platform from '@libs/getPlatform/types'; import type CONST from './CONST'; import type {OnboardingPurposeType} from './CONST'; import type * as FormTypes from './types/form'; @@ -899,6 +900,7 @@ type OnyxValuesMapping = { [ONYXKEYS.USER_METADATA]: OnyxTypes.UserMetadata; [ONYXKEYS.STASHED_SESSION]: OnyxTypes.Session; [ONYXKEYS.BETAS]: OnyxTypes.Beta[]; + [ONYXKEYS.NVP_MUTED_PLATFORMS]: Platform[]; [ONYXKEYS.NVP_PRIORITY_MODE]: ValueOf; [ONYXKEYS.NVP_BLOCKED_FROM_CONCIERGE]: OnyxTypes.BlockedFromConcierge; diff --git a/src/libs/API/parameters/TogglePlatformMuteParams.ts b/src/libs/API/parameters/TogglePlatformMuteParams.ts new file mode 100644 index 000000000000..a9d559f4e1d8 --- /dev/null +++ b/src/libs/API/parameters/TogglePlatformMuteParams.ts @@ -0,0 +1,8 @@ +import Platform from '@libs/getPlatform/types'; + +type TogglePlatformMuteParams = { + authToken: string; + platform: Platform; +}; + +export default TogglePlatformMuteParams; diff --git a/src/libs/API/parameters/index.ts b/src/libs/API/parameters/index.ts index ca233021517f..29e1371990cd 100644 --- a/src/libs/API/parameters/index.ts +++ b/src/libs/API/parameters/index.ts @@ -330,3 +330,4 @@ export type {default as UpdateCompanyCardNameParams} from './UpdateCompanyCardNa export type {default as SetCompanyCardExportAccountParams} from './SetCompanyCardExportAccountParams'; export type {default as SetMissingPersonalDetailsAndShipExpensifyCardParams} from './SetMissingPersonalDetailsAndShipExpensifyCardParams'; export type {default as SetInvoicingTransferBankAccountParams} from './SetInvoicingTransferBankAccountParams'; +export type {default as TogglePlatformMuteParams} from './TogglePlatformMuteParams'; diff --git a/src/libs/actions/User.ts b/src/libs/actions/User.ts index 00176e265cb6..f9aff6ed2f9f 100644 --- a/src/libs/actions/User.ts +++ b/src/libs/actions/User.ts @@ -12,6 +12,7 @@ import type { RequestContactMethodValidateCodeParams, SetContactMethodAsDefaultParams, SetNameValuePairParams, + TogglePlatformMuteParams, UpdateChatPriorityModeParams, UpdateNewsletterSubscriptionParams, UpdatePreferredEmojiSkinToneParams, @@ -23,6 +24,7 @@ import type { import {READ_COMMANDS, WRITE_COMMANDS} from '@libs/API/types'; import DateUtils from '@libs/DateUtils'; import * as ErrorUtils from '@libs/ErrorUtils'; +import type Platform from '@libs/getPlatform/types'; import Log from '@libs/Log'; import Navigation from '@libs/Navigation/Navigation'; import * as SequentialQueue from '@libs/Network/SequentialQueue'; @@ -984,15 +986,9 @@ function clearUserErrorMessage() { Onyx.merge(ONYXKEYS.USER, {error: ''}); } -// function setMuteAllSounds(isMutedAllSounds: boolean) { -// Onyx.merge(ONYXKEYS.USER, {isMutedAllSounds}); -// } - -function togglePlatformMute(platform, mutedPlatforms) { +function togglePlatformMute(platform: Platform, mutedPlatforms: Platform[]) { const isPlatformMuted = mutedPlatforms?.includes(platform); - const newMutedPlatforms = isPlatformMuted - ? mutedPlatforms.filter((mutedPlatform) => mutedPlatform !== platform) - : [...mutedPlatforms, platform]; + const newMutedPlatforms = isPlatformMuted ? mutedPlatforms.filter((mutedPlatform) => mutedPlatform !== platform) : [...mutedPlatforms, platform]; const optimisticData: OnyxUpdate[] = [ { @@ -1009,14 +1005,12 @@ function togglePlatformMute(platform, mutedPlatforms) { }, ]; - const parameters: GetTogglePlatformMuteParams = {authToken, platform}; + const parameters: TogglePlatformMuteParams = {authToken, platform}; API.write(WRITE_COMMANDS.TOGGLE_PLATFORM_MUTE, parameters, { optimisticData, failureData, }); - - // Onyx.merge(ONYXKEYS.USER, {isMutedAllSounds: !isMutedAllSounds}); } /** diff --git a/src/pages/settings/Preferences/PreferencesPage.tsx b/src/pages/settings/Preferences/PreferencesPage.tsx index 8d0b5c89aec7..2fa592b7fbee 100755 --- a/src/pages/settings/Preferences/PreferencesPage.tsx +++ b/src/pages/settings/Preferences/PreferencesPage.tsx @@ -13,28 +13,27 @@ import Text from '@components/Text'; import useLocalize from '@hooks/useLocalize'; import useResponsiveLayout from '@hooks/useResponsiveLayout'; import useThemeStyles from '@hooks/useThemeStyles'; +import * as Browser from '@libs/Browser'; +import getPlatform from '@libs/getPlatform'; import LocaleUtils from '@libs/LocaleUtils'; import Navigation from '@libs/Navigation/Navigation'; import * as User from '@userActions/User'; import CONST from '@src/CONST'; import ONYXKEYS from '@src/ONYXKEYS'; import ROUTES from '@src/ROUTES'; -import getPlatform from '@libs/getPlatform'; -import * as Browser from '@libs/Browser'; function PreferencesPage() { const [priorityMode] = useOnyx(ONYXKEYS.NVP_PRIORITY_MODE); - + let platform = getPlatform(); if (Browser.isMobile()) { platform = CONST.PLATFORM.MOBILEWEB; } const [mutedPlatforms] = useOnyx(ONYXKEYS.NVP_MUTED_PLATFORMS); - const isPlatformMuted = mutedPlatforms.includes(platform); + const isPlatformMuted = mutedPlatforms?.includes(platform); const [user] = useOnyx(ONYXKEYS.USER); const [preferredTheme] = useOnyx(ONYXKEYS.PREFERRED_THEME); - const styles = useThemeStyles(); const {translate, preferredLocale} = useLocalize(); const {shouldUseNarrowLayout} = useResponsiveLayout(); From 414b756994bb259cb8364c07edc6a604b7e3ab5e Mon Sep 17 00:00:00 2001 From: c3024 Date: Wed, 9 Oct 2024 22:24:19 +0530 Subject: [PATCH 3/9] fix lint --- src/ONYXKEYS.ts | 2 +- src/libs/API/parameters/TogglePlatformMuteParams.ts | 2 +- src/libs/API/types.ts | 1 + 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/ONYXKEYS.ts b/src/ONYXKEYS.ts index f3755f9acea3..8767db52ba22 100755 --- a/src/ONYXKEYS.ts +++ b/src/ONYXKEYS.ts @@ -1,5 +1,5 @@ import type {ValueOf} from 'type-fest'; -import type Platform from '@libs/getPlatform/types'; +import type Platform from './libs/getPlatform/types'; import type CONST from './CONST'; import type {OnboardingPurposeType} from './CONST'; import type * as FormTypes from './types/form'; diff --git a/src/libs/API/parameters/TogglePlatformMuteParams.ts b/src/libs/API/parameters/TogglePlatformMuteParams.ts index a9d559f4e1d8..83de3609590a 100644 --- a/src/libs/API/parameters/TogglePlatformMuteParams.ts +++ b/src/libs/API/parameters/TogglePlatformMuteParams.ts @@ -1,4 +1,4 @@ -import Platform from '@libs/getPlatform/types'; +import type Platform from '@libs/getPlatform/types'; type TogglePlatformMuteParams = { authToken: string; diff --git a/src/libs/API/types.ts b/src/libs/API/types.ts index e0c81a729568..72a7794aebbb 100644 --- a/src/libs/API/types.ts +++ b/src/libs/API/types.ts @@ -465,6 +465,7 @@ type WriteCommandParameters = { [WRITE_COMMANDS.UPDATE_PREFERRED_EMOJI_SKIN_TONE]: Parameters.UpdatePreferredEmojiSkinToneParams; [WRITE_COMMANDS.UPDATE_CHAT_PRIORITY_MODE]: Parameters.UpdateChatPriorityModeParams; [WRITE_COMMANDS.SET_CONTACT_METHOD_AS_DEFAULT]: Parameters.SetContactMethodAsDefaultParams; + [WRITE_COMMANDS.TOGGLE_PLATFORM_MUTE]: Parameters.TogglePlatformMuteParams; [WRITE_COMMANDS.UPDATE_THEME]: Parameters.UpdateThemeParams; [WRITE_COMMANDS.UPDATE_STATUS]: Parameters.UpdateStatusParams; [WRITE_COMMANDS.CLEAR_STATUS]: null; From 172368db5b20796019dc53d5b1c53973bfde81f0 Mon Sep 17 00:00:00 2001 From: c3024 Date: Wed, 9 Oct 2024 22:25:56 +0530 Subject: [PATCH 4/9] prettier --- src/ONYXKEYS.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ONYXKEYS.ts b/src/ONYXKEYS.ts index 8767db52ba22..1272f6e59099 100755 --- a/src/ONYXKEYS.ts +++ b/src/ONYXKEYS.ts @@ -1,7 +1,7 @@ import type {ValueOf} from 'type-fest'; -import type Platform from './libs/getPlatform/types'; import type CONST from './CONST'; import type {OnboardingPurposeType} from './CONST'; +import type Platform from './libs/getPlatform/types'; import type * as FormTypes from './types/form'; import type * as OnyxTypes from './types/onyx'; import type Onboarding from './types/onyx/Onboarding'; From 97b893762d12d48f0757dff876e498dbfc2222ad Mon Sep 17 00:00:00 2001 From: c3024 Date: Wed, 9 Oct 2024 22:38:24 +0530 Subject: [PATCH 5/9] prettier and typecheck --- src/libs/actions/User.ts | 1 - src/pages/settings/Preferences/PreferencesPage.tsx | 3 +-- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/src/libs/actions/User.ts b/src/libs/actions/User.ts index f9aff6ed2f9f..5ddbd36df4de 100644 --- a/src/libs/actions/User.ts +++ b/src/libs/actions/User.ts @@ -1385,7 +1385,6 @@ export { subscribeToUserEvents, updatePreferredSkinTone, setShouldUseStagingServer, - // setMuteAllSounds, togglePlatformMute, clearUserErrorMessage, joinScreenShare, diff --git a/src/pages/settings/Preferences/PreferencesPage.tsx b/src/pages/settings/Preferences/PreferencesPage.tsx index 2fa592b7fbee..c30858833168 100755 --- a/src/pages/settings/Preferences/PreferencesPage.tsx +++ b/src/pages/settings/Preferences/PreferencesPage.tsx @@ -29,7 +29,7 @@ function PreferencesPage() { if (Browser.isMobile()) { platform = CONST.PLATFORM.MOBILEWEB; } - const [mutedPlatforms] = useOnyx(ONYXKEYS.NVP_MUTED_PLATFORMS); + const [mutedPlatforms = []] = useOnyx(ONYXKEYS.NVP_MUTED_PLATFORMS); const isPlatformMuted = mutedPlatforms?.includes(platform); const [user] = useOnyx(ONYXKEYS.USER); const [preferredTheme] = useOnyx(ONYXKEYS.PREFERRED_THEME); @@ -89,7 +89,6 @@ function PreferencesPage() { User.togglePlatformMute(platform, mutedPlatforms)} /> From 266996a7b791e0e105919c551d6a82a20ad54749 Mon Sep 17 00:00:00 2001 From: c3024 Date: Thu, 10 Oct 2024 23:05:55 +0530 Subject: [PATCH 6/9] chnage mutedPlatforms to object --- src/ONYXKEYS.ts | 2 +- src/libs/actions/User.ts | 7 ++++--- src/pages/settings/Preferences/PreferencesPage.tsx | 9 +++------ 3 files changed, 8 insertions(+), 10 deletions(-) diff --git a/src/ONYXKEYS.ts b/src/ONYXKEYS.ts index 1272f6e59099..26e915648c29 100755 --- a/src/ONYXKEYS.ts +++ b/src/ONYXKEYS.ts @@ -900,7 +900,7 @@ type OnyxValuesMapping = { [ONYXKEYS.USER_METADATA]: OnyxTypes.UserMetadata; [ONYXKEYS.STASHED_SESSION]: OnyxTypes.Session; [ONYXKEYS.BETAS]: OnyxTypes.Beta[]; - [ONYXKEYS.NVP_MUTED_PLATFORMS]: Platform[]; + [ONYXKEYS.NVP_MUTED_PLATFORMS]: Partial>; [ONYXKEYS.NVP_PRIORITY_MODE]: ValueOf; [ONYXKEYS.NVP_BLOCKED_FROM_CONCIERGE]: OnyxTypes.BlockedFromConcierge; diff --git a/src/libs/actions/User.ts b/src/libs/actions/User.ts index 5ddbd36df4de..51a389975769 100644 --- a/src/libs/actions/User.ts +++ b/src/libs/actions/User.ts @@ -986,9 +986,10 @@ function clearUserErrorMessage() { Onyx.merge(ONYXKEYS.USER, {error: ''}); } -function togglePlatformMute(platform: Platform, mutedPlatforms: Platform[]) { - const isPlatformMuted = mutedPlatforms?.includes(platform); - const newMutedPlatforms = isPlatformMuted ? mutedPlatforms.filter((mutedPlatform) => mutedPlatform !== platform) : [...mutedPlatforms, platform]; +function togglePlatformMute(platform: Platform, mutedPlatforms: Partial>) { + const newMutedPlatforms = mutedPlatforms?.[platform] + ? {...mutedPlatforms, [platform]: undefined} // Remove platform if it's muted + : {...mutedPlatforms, [platform]: true}; // Add platform if it's not muted const optimisticData: OnyxUpdate[] = [ { diff --git a/src/pages/settings/Preferences/PreferencesPage.tsx b/src/pages/settings/Preferences/PreferencesPage.tsx index c30858833168..5dee30518533 100755 --- a/src/pages/settings/Preferences/PreferencesPage.tsx +++ b/src/pages/settings/Preferences/PreferencesPage.tsx @@ -25,12 +25,9 @@ import ROUTES from '@src/ROUTES'; function PreferencesPage() { const [priorityMode] = useOnyx(ONYXKEYS.NVP_PRIORITY_MODE); - let platform = getPlatform(); - if (Browser.isMobile()) { - platform = CONST.PLATFORM.MOBILEWEB; - } - const [mutedPlatforms = []] = useOnyx(ONYXKEYS.NVP_MUTED_PLATFORMS); - const isPlatformMuted = mutedPlatforms?.includes(platform); + const platform = Browser.isMobile() ? CONST.PLATFORM.MOBILEWEB : getPlatform(); + const [mutedPlatforms = {}] = useOnyx(ONYXKEYS.NVP_MUTED_PLATFORMS); + const isPlatformMuted = mutedPlatforms[platform]; const [user] = useOnyx(ONYXKEYS.USER); const [preferredTheme] = useOnyx(ONYXKEYS.PREFERRED_THEME); From d4a4ec5ec458cafa73a85ba7f8c10444f5592e76 Mon Sep 17 00:00:00 2001 From: c3024 Date: Fri, 25 Oct 2024 13:34:28 +0530 Subject: [PATCH 7/9] rename API command param to platformToMute --- src/libs/API/parameters/TogglePlatformMuteParams.ts | 2 +- src/libs/actions/User.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/libs/API/parameters/TogglePlatformMuteParams.ts b/src/libs/API/parameters/TogglePlatformMuteParams.ts index 83de3609590a..1f633de164f2 100644 --- a/src/libs/API/parameters/TogglePlatformMuteParams.ts +++ b/src/libs/API/parameters/TogglePlatformMuteParams.ts @@ -2,7 +2,7 @@ import type Platform from '@libs/getPlatform/types'; type TogglePlatformMuteParams = { authToken: string; - platform: Platform; + platformToMute: Platform; }; export default TogglePlatformMuteParams; diff --git a/src/libs/actions/User.ts b/src/libs/actions/User.ts index 5c6817a1f661..8f72627b1831 100644 --- a/src/libs/actions/User.ts +++ b/src/libs/actions/User.ts @@ -1002,7 +1002,7 @@ function togglePlatformMute(platform: Platform, mutedPlatforms: Partial Date: Sat, 26 Oct 2024 15:08:45 +0530 Subject: [PATCH 8/9] enhanceParameters adds authToken to the parameters --- src/libs/API/parameters/TogglePlatformMuteParams.ts | 1 - src/libs/actions/User.ts | 11 +---------- 2 files changed, 1 insertion(+), 11 deletions(-) diff --git a/src/libs/API/parameters/TogglePlatformMuteParams.ts b/src/libs/API/parameters/TogglePlatformMuteParams.ts index 1f633de164f2..1517782e18d7 100644 --- a/src/libs/API/parameters/TogglePlatformMuteParams.ts +++ b/src/libs/API/parameters/TogglePlatformMuteParams.ts @@ -1,7 +1,6 @@ import type Platform from '@libs/getPlatform/types'; type TogglePlatformMuteParams = { - authToken: string; platformToMute: Platform; }; diff --git a/src/libs/actions/User.ts b/src/libs/actions/User.ts index 8f72627b1831..0c710ca51d7b 100644 --- a/src/libs/actions/User.ts +++ b/src/libs/actions/User.ts @@ -54,15 +54,6 @@ import * as Session from './Session'; let currentUserAccountID = -1; let currentEmail = ''; -let authToken = ''; -Onyx.connect({ - key: ONYXKEYS.SESSION, - callback: (value) => { - currentUserAccountID = value?.accountID ?? -1; - currentEmail = value?.email ?? ''; - authToken = value?.authToken ?? ''; - }, -}); let myPersonalDetails: OnyxEntry; Onyx.connect({ @@ -1002,7 +993,7 @@ function togglePlatformMute(platform: Platform, mutedPlatforms: Partial Date: Sat, 26 Oct 2024 15:20:22 +0530 Subject: [PATCH 9/9] subscribe to session correctly --- src/libs/actions/User.ts | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/libs/actions/User.ts b/src/libs/actions/User.ts index 0c710ca51d7b..eaccbb8497ac 100644 --- a/src/libs/actions/User.ts +++ b/src/libs/actions/User.ts @@ -54,6 +54,13 @@ import * as Session from './Session'; let currentUserAccountID = -1; let currentEmail = ''; +Onyx.connect({ + key: ONYXKEYS.SESSION, + callback: (value) => { + currentUserAccountID = value?.accountID ?? -1; + currentEmail = value?.email ?? ''; + }, +}); let myPersonalDetails: OnyxEntry; Onyx.connect({