Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F32098229
D15408.1765011384.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Size
2 KB
Referenced Files
None
Subscribers
None
D15408.1765011384.diff
View Options
diff --git a/lib/shared/farcaster/farcaster-hooks.js b/lib/shared/farcaster/farcaster-hooks.js
--- a/lib/shared/farcaster/farcaster-hooks.js
+++ b/lib/shared/farcaster/farcaster-hooks.js
@@ -1040,6 +1040,36 @@
]);
}
+function useLightweightSyncOnAppStart() {
+ const isUserLoggedIn = useSelector(isLoggedIn);
+ const userDataReady = useIsUserDataReady();
+ const fullyLoggedIn = isUserLoggedIn && userDataReady;
+ const currentUserSupportsDCs = useCurrentUserSupportsDCs();
+ const farcasterDCsLoaded = useFarcasterDCsLoaded();
+ const lightweightSync = useLightweightFarcasterConversationsSync();
+ const started = React.useRef(false);
+
+ React.useEffect(() => {
+ // We're waiting for the state to be ready
+ if (started.current || !fullyLoggedIn || !currentUserSupportsDCs) {
+ return;
+ }
+ started.current = true;
+ // If we're here, it means that the full sync is not yet done. In that
+ // case, we don't want to perform the lightweight sync during this run
+ // of the app.
+ if (!farcasterDCsLoaded) {
+ return;
+ }
+ void lightweightSync();
+ }, [
+ currentUserSupportsDCs,
+ farcasterDCsLoaded,
+ fullyLoggedIn,
+ lightweightSync,
+ ]);
+}
+
export {
useFarcasterConversationsSync,
useLightweightFarcasterConversationsSync,
@@ -1051,4 +1081,5 @@
useAddNewFarcasterMessage,
useFarcasterSync,
useFarcasterThreadRefresher,
+ useLightweightSyncOnAppStart,
};
diff --git a/native/components/farcaster-sync-handler.react.js b/native/components/farcaster-sync-handler.react.js
--- a/native/components/farcaster-sync-handler.react.js
+++ b/native/components/farcaster-sync-handler.react.js
@@ -5,6 +5,7 @@
import { useIsUserDataReady } from 'lib/hooks/backup-hooks.js';
import { isLoggedIn } from 'lib/selectors/user-selectors.js';
+import { useLightweightSyncOnAppStart } from 'lib/shared/farcaster/farcaster-hooks.js';
import {
useCurrentUserSupportsDCs,
useFarcasterDCsLoaded,
@@ -26,6 +27,8 @@
const farcasterDCsLoaded = useFarcasterDCsLoaded();
const currentRouteName = useCurrentLeafRouteName();
+ useLightweightSyncOnAppStart();
+
React.useEffect(() => {
if (!navContext) {
return;
diff --git a/web/components/farcaster-sync-overlay.react.js b/web/components/farcaster-sync-overlay.react.js
--- a/web/components/farcaster-sync-overlay.react.js
+++ b/web/components/farcaster-sync-overlay.react.js
@@ -2,6 +2,7 @@
import * as React from 'react';
+import { useLightweightSyncOnAppStart } from 'lib/shared/farcaster/farcaster-hooks.js';
import {
useCurrentUserSupportsDCs,
useFarcasterDCsLoaded,
@@ -21,6 +22,8 @@
const isFullSyncInProgress =
currentUserSupportsDCs && farcasterDCsLoaded === false;
+ useLightweightSyncOnAppStart();
+
const style = React.useMemo(() => {
if (!isFullSyncInProgress) {
return {};
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sat, Dec 6, 8:56 AM (17 h, 13 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
5834809
Default Alt Text
D15408.1765011384.diff (2 KB)
Attached To
Mode
D15408: [lib] Run the lightweight sync
Attached
Detach File
Event Timeline
Log In to Comment