A fully open source & end-to-end encrypted note taking alternative to Evernote.
TypeScript asp-net-coredotnet-coreelectronfosshacktoberfestnote-managmentnote-takingnote-taking-appnotebooknotesnotes-appopen-sourceopensourceprivacyproductivityreactreact-nativereactjsself-hosted
mobile: prevent UI jerk on analytics refresh after app resume
kashaf-ansari-dev17bbaa232328
diff --git a/apps/mobile/app/components/sheets/publish-note/index.tsx b/apps/mobile/app/components/sheets/publish-note/index.tsxindex d8ca896fd..59559c047 100644--- a/apps/mobile/app/components/sheets/publish-note/index.tsx+++ b/apps/mobile/app/components/sheets/publish-note/index.tsx@@ -171,12 +171,20 @@ const PublishNoteSheet = ({setPublishLoading(false);};+ const lastAnalyticsResult = useRef<Awaited<+ ReturnType<typeof db.monographs.analytics>+ > | null>(null);+const analytics = useAsync(async () => {if (!isFeatureAvailable?.isAllowed || !monograph?.id || selfDestruct)return null;- return await db.monographs.analytics(monograph.id);+ const result = await db.monographs.analytics(monograph.id);+ if (result) lastAnalyticsResult.current = result;+ return result;}, [monograph?.id, isFeatureAvailable?.isAllowed, selfDestruct]);+ const analyticsData = analytics.result ?? lastAnalyticsResult.current;+useEffect(() => {const prevState = previousAppState.current;previousAppState.current = appState;@@ -398,8 +406,8 @@ const PublishNoteSheet = ({{isFeatureAvailable?.isAllowed &&!selfDestruct &&- analytics?.result &&- analytics?.result?.totalViews > 0 ? (+ analyticsData &&+ analyticsData?.totalViews > 0 ? (<Viewstyle={{flexDirection: "row",@@ -425,7 +433,7 @@ const PublishNoteSheet = ({<Paragraph size={AppFontSize.sm}>{strings.views()}</Paragraph><Paragraph size={AppFontSize.sm}>- {analytics.result?.totalViews}+ {analyticsData?.totalViews}</Paragraph></View></View>