mirror of
https://github.com/streetwriters/notesnook.git
synced 2026-07-10 20:41:26 +02:00
mobile: refresh monograph analytics on app foreground
Signed-off-by: kashaf-ansari-dev <kashafansari3108@gmail.com>
This commit is contained in:
@@ -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={{
|
||||
|
||||
Reference in New Issue
Block a user