Skip to content

Commit

Permalink
fix: Remove OsReceive side effect from old FlagshipUI implementation
Browse files Browse the repository at this point in the history
Related PR: #1043
  • Loading branch information
Ldoppea committed Dec 18, 2023
1 parent 4da2aad commit 4a5885f
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 28 deletions.
16 changes: 0 additions & 16 deletions src/app/view/OsReceive/state/OsReceiveState.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ export const osReceiveReducer = (
action: OsReceiveAction
): OsReceiveState => {
let nextState = state
dangerousOsReceiveState = nextState

switch (action.type) {
case OsReceiveActionType.SetFilesToUpload:
Expand Down Expand Up @@ -93,21 +92,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) {
Expand Down
12 changes: 0 additions & 12 deletions src/libs/intents/setFlagshipUI.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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')
Expand Down

0 comments on commit 4a5885f

Please sign in to comment.