Page MenuHomePhabricator

D12718.id42215.diff
No OneTemporary

D12718.id42215.diff

diff --git a/lib/components/farcaster-data-handler.react.js b/lib/components/farcaster-data-handler.react.js
--- a/lib/components/farcaster-data-handler.react.js
+++ b/lib/components/farcaster-data-handler.react.js
@@ -19,7 +19,13 @@
import { useSelector, useDispatch } from '../utils/redux-utils.js';
import { usingCommServicesAccessToken } from '../utils/services-utils.js';
-function FarcasterDataHandler(): React.Node {
+type Props = {
+ +children?: React.Node,
+};
+
+function FarcasterDataHandler(props: Props): React.Node {
+ const { children } = props;
+
const isActive = useSelector(state => state.lifecycleState !== 'background');
const currentUserID = useSelector(state => state.currentUserInfo?.id);
@@ -139,6 +145,8 @@
const prevCanQueryHandleCurrentUserFIDRef = React.useRef<?boolean>();
const canQueryHandleCurrentUserFID = isActive && loggedIn;
+ const [fidLoaded, setFIDLoaded] = React.useState(false);
+
const handleCurrentUserFID = React.useCallback(async () => {
if (
canQueryHandleCurrentUserFID ===
@@ -181,6 +189,8 @@
},
});
}
+
+ setFIDLoaded(true);
}, [
canQueryHandleCurrentUserFID,
findUserIdentities,
@@ -201,7 +211,23 @@
void handleCurrentUserFID();
}, [handleCurrentUserFID, handleFarcasterMutuals, handleUserStoreFIDs]);
- return null;
+ React.useEffect(() => {
+ if (loggedIn) {
+ return;
+ }
+
+ setFIDLoaded(false);
+ }, [loggedIn]);
+
+ const farcasterDataHandler = React.useMemo(() => {
+ if (!fidLoaded) {
+ return null;
+ }
+
+ return children;
+ }, [children, fidLoaded]);
+
+ return farcasterDataHandler;
}
export { FarcasterDataHandler };
diff --git a/native/root.react.js b/native/root.react.js
--- a/native/root.react.js
+++ b/native/root.react.js
@@ -308,7 +308,11 @@
</DeepLinksContextProvider>
</ChatContextProvider>
<NavigationHandler />
- <ConnectFarcasterAlertHandler />
+ <PersistedStateGate>
+ <FarcasterDataHandler>
+ <ConnectFarcasterAlertHandler />
+ </FarcasterDataHandler>
+ </PersistedStateGate>
</BottomSheetModalProvider>
</NavigationContainer>
);
@@ -367,7 +371,6 @@
<BackgroundIdentityLoginHandler />
<PrekeysHandler />
<ReportHandler />
- <FarcasterDataHandler />
<AutoJoinCommunityHandler />
</PersistedStateGate>
{navigation}

File Metadata

Mime Type
text/plain
Expires
Sat, Dec 28, 6:10 AM (7 h, 55 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2714851
Default Alt Text
D12718.id42215.diff (2 KB)

Event Timeline