From 831ef4173d133e5c4cb10dfecc7be59ecd40001d Mon Sep 17 00:00:00 2001 From: Ammar Ahmed Date: Mon, 18 Dec 2023 08:50:01 +0500 Subject: [PATCH] mobile: fix types --- .../app/components/list-items/note/index.tsx | 9 +++--- .../components/list-items/note/wrapper.tsx | 32 ++++++++++++------- 2 files changed, 25 insertions(+), 16 deletions(-) diff --git a/apps/mobile/app/components/list-items/note/index.tsx b/apps/mobile/app/components/list-items/note/index.tsx index a5f1f0231..f40c1a5ca 100644 --- a/apps/mobile/app/components/list-items/note/index.tsx +++ b/apps/mobile/app/components/list-items/note/index.tsx @@ -37,10 +37,7 @@ import { useEditorStore } from "../../../stores/use-editor-store"; import useNavigationStore from "../../../stores/use-navigation-store"; import { useRelationStore } from "../../../stores/use-relation-store"; import { SIZE } from "../../../utils/size"; -import { - NotebooksWithDateEdited, - TagsWithDateEdited -} from "../../list/list-item.wrapper"; + import { Properties } from "../../properties"; import { Button } from "../../ui/button"; import { IconButton } from "../../ui/icon-button"; @@ -48,6 +45,10 @@ import { ReminderTime } from "../../ui/reminder-time"; import { TimeSince } from "../../ui/time-since"; import Heading from "../../ui/typography/heading"; import Paragraph from "../../ui/typography/paragraph"; +import { + NotebooksWithDateEdited, + TagsWithDateEdited +} from "../../../stores/resolve-items"; type NoteItemProps = { item: Note | BaseTrashItem; diff --git a/apps/mobile/app/components/list-items/note/wrapper.tsx b/apps/mobile/app/components/list-items/note/wrapper.tsx index 13cb5de0b..20e2cdc80 100644 --- a/apps/mobile/app/components/list-items/note/wrapper.tsx +++ b/apps/mobile/app/components/list-items/note/wrapper.tsx @@ -33,12 +33,13 @@ import { useEditorStore } from "../../../stores/use-editor-store"; import { useSelectionStore } from "../../../stores/use-selection-store"; import { eOnLoadNote, eShowMergeDialog } from "../../../utils/events"; import { tabBarRef } from "../../../utils/global-refs"; -import type { - NotebooksWithDateEdited, - TagsWithDateEdited -} from "../../list/list-item.wrapper"; + import NotePreview from "../../note-history/preview"; import SelectionWrapper from "../selection-wrapper"; +import { + NotebooksWithDateEdited, + TagsWithDateEdited +} from "../../../stores/resolve-items"; export const openNote = async ( item: Note, @@ -51,15 +52,20 @@ export const openNote = async ( if (!isTrash) { note = (await db.notes.note(item.id)) as Note; } + if (useSelectionStore.getState().selectionMode === item.type) { + const { + selectedItemsList, + selectionMode, + clearSelection, + setSelectedItem + } = useSelectionStore.getState(); - const { selectedItemsList, selectionMode, clearSelection, setSelectedItem } = - useSelectionStore.getState(); - - if (selectedItemsList.length > 0 && selectionMode === item.type) { - setSelectedItem(note.id); + if (selectedItemsList.length > 0 && selectionMode === item.type) { + setSelectedItem(note.id); + } else { + clearSelection(); + } return; - } else { - clearSelection(); } if (note.conflicted) { @@ -88,7 +94,9 @@ export const openNote = async ( ) }); } else { - useEditorStore.getState().setReadonly(note?.readonly); + if (note?.readonly) { + useEditorStore.getState().setReadonly(note?.readonly); + } eSendEvent(eOnLoadNote, { item: note });