Fix mobile editor return navigation
This commit is contained in:
1 parent
24161dad7f
commit
3eeff8cb02
2 files changed
+11
-6
No files matched your search
@@ -1118,10 +1118,6 @@ export const WorkspaceApp = ({
|
||||
}, [runQueuedSync]);
|
||||
|
||||
useEffect(() => {
|
||||
if (!isStandaloneRuntime) {
|
||||
return;
|
||||
}
|
||||
|
||||
const refreshWorkspaceQueries = () => {
|
||||
if (document.visibilityState === "hidden" || (typeof navigator !== "undefined" && !navigator.onLine)) {
|
||||
return;
|
||||
@@ -1140,7 +1136,7 @@ export const WorkspaceApp = ({
|
||||
window.removeEventListener("pageshow", refreshWorkspaceQueries);
|
||||
document.removeEventListener("visibilitychange", refreshWorkspaceQueries);
|
||||
};
|
||||
}, [isStandaloneRuntime, queryClient]);
|
||||
}, [queryClient]);
|
||||
|
||||
useEffect(() => {
|
||||
if (syncSummary.total === 0) {
|
||||
|
||||
@@ -333,7 +333,16 @@ const MobileTiptapEditorApp = () => {
|
||||
}, [persistLocalDraft, saveNow, setSaveStateStable]);
|
||||
|
||||
const navigateBack = useCallback(() => {
|
||||
window.location.replace(returnTo);
|
||||
const referrerUrl = document.referrer ? new URL(document.referrer) : null;
|
||||
const canRestorePreviousPage = Boolean(referrerUrl && referrerUrl.origin === window.location.origin && window.history.length > 1);
|
||||
|
||||
if (!canRestorePreviousPage) {
|
||||
window.location.replace(returnTo);
|
||||
return;
|
||||
}
|
||||
|
||||
const currentState = window.history.state as { edgeeverMobileEditorBackGuard?: boolean } | null;
|
||||
window.history.go(currentState?.edgeeverMobileEditorBackGuard ? -2 : -1);
|
||||
}, [returnTo]);
|
||||
|
||||
const leavePage = useCallback(async () => {
|
||||
|
||||
Reference in new issue
Block a user