mobile: refresh monograph analytics on app foreground

Signed-off-by: kashaf-ansari-dev <kashafansari3108@gmail.com>
This commit is contained in:
kashaf-ansari-dev
2026-06-04 07:17:03 +05:00
parent 657f0e428a
commit 4256003e1c

View File

@@ -54,6 +54,7 @@ import FormInput, {
createFormRef,
validators
} from "../../ui/input/form-input";
import { useAppState } from "../../../../app/hooks/use-app-state";
async function fetchMonographData(noteId: string) {
const monographId = db.monographs.monograph(noteId);
@@ -87,6 +88,8 @@ const PublishNoteSheet = ({
const monograph = monographData.result?.monograph;
const publishUrl = monograph && `${hosts.MONOGRAPH_HOST}/${monograph?.id}`;
const isPublished = db.monographs.monograph(note?.id);
const appState = useAppState();
const previousAppState = useRef(appState);
const formRef = useRef(
createFormRef({
@@ -176,6 +179,15 @@ const PublishNoteSheet = ({
return await db.monographs.analytics(monograph.id);
}, [monograph?.id, isFeatureAvailable?.isAllowed]);
useEffect(() => {
const prevState = previousAppState.current;
previousAppState.current = appState;
if (appState === "active" && prevState !== "active" && monograph?.id) {
analytics.execute();
}
}, [appState, monograph?.id]);
return (
<View
style={{