Skip to content

Commit

Permalink
navigate to homescreen when onyx state is fully set
Browse files Browse the repository at this point in the history
  • Loading branch information
TMisiukiewicz committed Dec 13, 2024
1 parent 47aae42 commit 981ee0d
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 26 deletions.
9 changes: 1 addition & 8 deletions src/components/ImportOnyxState/index.native.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ function applyStateInChunks(state: OnyxValues) {
return promise;
}

export default function ImportOnyxState({setIsLoading, isLoading}: ImportOnyxStateProps) {
export default function ImportOnyxState({setIsLoading}: ImportOnyxStateProps) {
const [isErrorModalVisible, setIsErrorModalVisible] = useState(false);
const [session] = useOnyx(ONYXKEYS.SESSION);

Expand All @@ -71,14 +71,7 @@ export default function ImportOnyxState({setIsLoading, isLoading}: ImportOnyxSta
})
.catch(() => {
setIsErrorModalVisible(true);
})
.finally(() => {
setIsLoading(false);
});

if (isLoading) {
setIsLoading(false);
}
};

return (
Expand Down
18 changes: 5 additions & 13 deletions src/components/ImportOnyxState/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import BaseImportOnyxState from './BaseImportOnyxState';
import type ImportOnyxStateProps from './types';
import {cleanAndTransformState} from './utils';

export default function ImportOnyxState({setIsLoading, isLoading}: ImportOnyxStateProps) {
export default function ImportOnyxState({setIsLoading}: ImportOnyxStateProps) {
const [isErrorModalVisible, setIsErrorModalVisible] = useState(false);
const [session] = useOnyx(ONYXKEYS.SESSION);

Expand All @@ -33,24 +33,16 @@ export default function ImportOnyxState({setIsLoading, isLoading}: ImportOnyxSta
setPreservedUserSession(currentUserSessionCopy);
setShouldForceOffline(true);
Onyx.clear(KEYS_TO_PRESERVE).then(() => {
Onyx.multiSet(transformedState)
.then(() => {
setIsUsingImportedState(true);
Navigation.navigate(ROUTES.HOME);
})
.finally(() => {
setIsLoading(false);
});
Onyx.multiSet(transformedState).then(() => {
setIsUsingImportedState(true);
Navigation.navigate(ROUTES.HOME);
});
});
})
.catch(() => {
setIsErrorModalVisible(true);
setIsLoading(false);
});

if (isLoading) {
setIsLoading(false);
}
};

return (
Expand Down
1 change: 0 additions & 1 deletion src/components/ImportOnyxState/types.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
type ImportOnyxStateProps = {
isLoading: boolean;
setIsLoading: (isLoading: boolean) => void;
};

Expand Down
5 changes: 1 addition & 4 deletions src/pages/settings/Troubleshoot/TroubleshootPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -144,10 +144,7 @@ function TroubleshootPage() {
/>
</TestToolRow>
</View>
<ImportOnyxState
setIsLoading={setIsLoading}
isLoading={isLoading}
/>
<ImportOnyxState setIsLoading={setIsLoading} />
<MenuItemList
menuItems={menuItems}
shouldUseSingleExecution
Expand Down

0 comments on commit 981ee0d

Please sign in to comment.