From 171cb35e49066dc815dbe6014e83606215cfcdbc Mon Sep 17 00:00:00 2001 From: Ldoppea Date: Mon, 18 Dec 2023 19:35:59 +0100 Subject: [PATCH] fix: Remove OsReceive side effect from old FlagshipUI implementation Now that OsReceive uses the new FlagshipUI API, then this hack is not needed anymore Related PR: #1043 --- src/app/view/OsReceive/state/OsReceiveState.ts | 16 ---------------- src/libs/intents/setFlagshipUI.ts | 12 ------------ 2 files changed, 28 deletions(-) diff --git a/src/app/view/OsReceive/state/OsReceiveState.ts b/src/app/view/OsReceive/state/OsReceiveState.ts index 119e86653..f783790c8 100644 --- a/src/app/view/OsReceive/state/OsReceiveState.ts +++ b/src/app/view/OsReceive/state/OsReceiveState.ts @@ -29,7 +29,6 @@ export const osReceiveReducer = ( action: OsReceiveAction ): OsReceiveState => { let nextState = state - dangerousOsReceiveState = nextState switch (action.type) { case OsReceiveActionType.SetFilesToUpload: @@ -94,21 +93,6 @@ export const initialState: OsReceiveState = { candidateApps: undefined } -/** - * This variable is used to expose the state to the outside world. - * - * It is meant to be a temporary solution to fix an issue where resetUIstate() - * has to know the state of this feature before executing its logic, - * but at the time of writing resetUIState has no connection to the React tree. - * - * It should not be used anywhere else unless absolutely necessary. - * ResetUIState() should be refactored to use a proper React context. - * It can't be done at the time of this commit for time constraints. - */ -let dangerousOsReceiveState = initialState -export const getDangerousOsReceiveState = (): OsReceiveState => - dangerousOsReceiveState - export const useOsReceiveState = (): OsReceiveState => { const context = useContext(OsReceiveStateContext) if (context === undefined) { diff --git a/src/libs/intents/setFlagshipUI.ts b/src/libs/intents/setFlagshipUI.ts index fc81e3864..8f9d0f52b 100644 --- a/src/libs/intents/setFlagshipUI.ts +++ b/src/libs/intents/setFlagshipUI.ts @@ -12,7 +12,6 @@ import { } from '/app/theme/themeManager' import { navigationRef } from '/libs/RootNavigation' import { routes } from '/constants/routes' -import { getDangerousOsReceiveState } from '/app/view/OsReceive/state/OsReceiveState' const isDarkMode = (bottomTheme: StatusBarStyle): boolean => bottomTheme === StatusBarStyle.Light @@ -243,17 +242,6 @@ export const resetUIState = ( ? ThemeInput.Dark : getHomeThemeAsThemeInput() - // If the theme is light, and there are files to upload (OsReceiveScreen visible), then set the theme to dark - // This is done because the file upload dialog is light background, so we want to use dark icons - // This is a temporary fix until we have a proper React context - // see src/app/view/OsReceive/state/OsReceiveState.ts#getDangerousOsReceiveState - if (theme === ThemeInput.Light) { - const hasFilesToUpload = - getDangerousOsReceiveState().filesToUpload.length > 0 - - if (hasFilesToUpload) theme = ThemeInput.Dark - } - themeLog.info('resetUIState', { uri, theme }) void setFlagshipUI({ bottomTheme: theme, topTheme: theme }, 'resetUIState')