mirror of
https://github.com/streetwriters/notesnook.git
synced 2026-09-01 19:49:54 +02:00
mobile: fix app shortcut navigation, flash, and back-nav issues
Signed-off-by: kashaf-ansari-dev <kashafansari3108@gmail.com>
This commit is contained in:
committed by
Ammar Ahmed
parent
a40814a3ab
commit
c3c9b1fbf4
@@ -57,10 +57,6 @@ const { appLockEnabled, appLockMode } = SettingsService.get();
|
||||
if (appLockEnabled || appLockMode !== "none") {
|
||||
useUserStore.getState().lockApp(true);
|
||||
}
|
||||
initShortcutListener();
|
||||
Linking.getInitialURL().then((url) => {
|
||||
useSettingStore.setState({ initialUrl: url });
|
||||
});
|
||||
|
||||
Shortcuts.getInitialShortcut().then((shortcut) => {
|
||||
useSettingStore.setState({
|
||||
@@ -68,6 +64,11 @@ Shortcuts.getInitialShortcut().then((shortcut) => {
|
||||
pendingShortcutLoaded: true
|
||||
});
|
||||
RNBootSplash.hide({ fade: true });
|
||||
initShortcutListener();
|
||||
});
|
||||
|
||||
Linking.getInitialURL().then((url) => {
|
||||
useSettingStore.setState({ initialUrl: url });
|
||||
});
|
||||
|
||||
const App = (props: { configureMode: "note-preview" }) => {
|
||||
|
||||
@@ -90,7 +90,9 @@ export const FluidPanels = forwardRef<TabsRef, TabProps>(function FluidTabs(
|
||||
initialPage === "editor" ? editorStartPosition : widths ? widths.sidebar : 0
|
||||
);
|
||||
const startX = useSharedValue(0);
|
||||
const currentTab = useSharedValue(initialPage === "editor" ? 2 : 1);
|
||||
const currentTab = useSharedValue(
|
||||
initialPage === "editor" && deviceMode !== "tablet" ? 2 : 1
|
||||
);
|
||||
const previousTab = useSharedValue(1);
|
||||
const isDrawerOpen = useSharedValue(false);
|
||||
const gestureStartValue = useSharedValue({
|
||||
|
||||
@@ -100,9 +100,10 @@ export const FluidPanelsView = React.memo(
|
||||
if (pendingShortcut?.type === "notesnook.action.newnote") {
|
||||
eSendEvent(eOnLoadNote, { newNote: true });
|
||||
editorState().movedAway = false;
|
||||
fluidTabsRef.current?.goToPage("editor", true);
|
||||
useSettingStore.setState({ pendingShortcut: null });
|
||||
}
|
||||
}, []);
|
||||
}, [pendingShortcut]);
|
||||
|
||||
useDeviceOrientationChange((o) => {
|
||||
if (
|
||||
|
||||
@@ -309,7 +309,7 @@ export const RootNavigation = () => {
|
||||
);
|
||||
const clearSelection = useSelectionStore((state) => state.clearSelection);
|
||||
const resetTimer = React.useRef<NodeJS.Timeout>(undefined);
|
||||
const isFirstRun = React.useRef(true);
|
||||
const isNavigationLoaded = React.useRef(true);
|
||||
const onStateChange = React.useCallback(
|
||||
(state: any) => {
|
||||
if (useSelectionStore.getState().selectionMode) {
|
||||
@@ -331,34 +331,17 @@ export const RootNavigation = () => {
|
||||
}, []);
|
||||
|
||||
React.useEffect(() => {
|
||||
if (isFirstRun.current) {
|
||||
isFirstRun.current = false;
|
||||
if (isNavigationLoaded.current) {
|
||||
isNavigationLoaded.current = false;
|
||||
return;
|
||||
}
|
||||
if (!pendingShortcut) return;
|
||||
|
||||
const routes = rootNavigatorRef.current?.getState()?.routes;
|
||||
const currentRoute = routes?.[routes.length - 1]?.name;
|
||||
|
||||
if (pendingShortcut.type === "notesnook.action.newreminder") {
|
||||
if (currentRoute !== "AddReminder") {
|
||||
rootNavigatorRef.current?.navigate("AddReminder" as any);
|
||||
}
|
||||
rootNavigatorRef.current?.navigate("AddReminder" as any);
|
||||
useSettingStore.setState({ pendingShortcut: null });
|
||||
} else if (pendingShortcut.type === "notesnook.action.newnote") {
|
||||
if (fluidTabsRef.current) {
|
||||
if (currentRoute !== "FluidPanelsView") {
|
||||
rootNavigatorRef.current?.navigate("FluidPanelsView" as any);
|
||||
}
|
||||
eSendEvent(eOnLoadNote, { newNote: true });
|
||||
editorState().movedAway = false;
|
||||
fluidTabsRef.current.goToPage("editor", true);
|
||||
useSettingStore.setState({ pendingShortcut: null });
|
||||
} else {
|
||||
if (currentRoute !== "FluidPanelsView") {
|
||||
rootNavigatorRef.current?.navigate("FluidPanelsView" as any);
|
||||
}
|
||||
}
|
||||
rootNavigatorRef.current?.navigate("FluidPanelsView" as any);
|
||||
}
|
||||
}, [pendingShortcut]);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user