A fully open source & end-to-end encrypted note taking alternative to Evernote.
TypeScript asp-net-coredotnet-coreelectronfosshacktoberfestnote-managmentnote-takingnote-taking-appnotebooknotesnotes-appopen-sourceopensourceprivacyproductivityreactreact-nativereactjsself-hosted
mobile: use new types from core
Abdullah Atta843be2a62c96
diff --git a/apps/mobile/app/common/filesystem/download.js b/apps/mobile/app/common/filesystem/download.jsindex 5623eae50..41015ca22 100644--- a/apps/mobile/app/common/filesystem/download.js+++ b/apps/mobile/app/common/filesystem/download.js@@ -98,7 +98,7 @@ export async function downloadFile(filename, data, cancelToken) {export async function getUploadedFileSize(hash) {try {const url = `${hosts.API_HOST}/s3?name=${hash}`;- const token = await db.user.tokenManager.getAccessToken();+ const token = await db.tokenManager.getAccessToken();const attachmentInfo = await fetch(url, {method: "HEAD",diff --git a/apps/mobile/app/components/attachments/actions.js b/apps/mobile/app/components/attachments/actions.jsindex 820d480d6..4d9228e9d 100644--- a/apps/mobile/app/components/attachments/actions.js+++ b/apps/mobile/app/components/attachments/actions.js@@ -64,7 +64,7 @@ const Actions = ({ attachment, setAttachments, fwdRef, close }) => {name: "Download",onPress: async () => {if (currentProgress) {- await db.fs.cancel(attachment.metadata.hash);+ await db.fs().cancel(attachment.metadata.hash);useAttachmentStore.getState().remove(attachment.metadata.hash);}downloadAttachment(attachment.metadata.hash, false);diff --git a/apps/mobile/app/components/attachments/download-attachments.js b/apps/mobile/app/components/attachments/download-attachments.jsindex 3d8bff584..ebc8a4503 100644--- a/apps/mobile/app/components/attachments/download-attachments.js+++ b/apps/mobile/app/components/attachments/download-attachments.js@@ -68,7 +68,7 @@ const DownloadAttachments = ({ close, attachments, isNote, update }) => {});canceled.current = true;console.log(groupId.current, "canceling groupId downloads");- await db.fs.cancel(groupId.current);+ await db.fs().cancel(groupId.current);setDownloading(false);groupId.current = null;};diff --git a/apps/mobile/app/components/auth/session-expired.js b/apps/mobile/app/components/auth/session-expired.jsindex 82279766e..0f2af241b 100644--- a/apps/mobile/app/components/auth/session-expired.js+++ b/apps/mobile/app/components/auth/session-expired.js@@ -108,9 +108,9 @@ export const SessionExpired = () => {const open = React.useCallback(async () => {try {- let res = await db.user.tokenManager.getToken();+ let res = await db.tokenManager.getToken();if (!res) throw new Error("no token found");- if (db.user.tokenManager._isTokenExpired(res))+ if (db.tokenManager._isTokenExpired(res))throw new Error("token expired");Sync.run("global", false, true, async (complete) => {if (!complete) {diff --git a/apps/mobile/app/components/sheets/reminder/index.tsx b/apps/mobile/app/components/sheets/reminder/index.tsxindex 41e8b87ac..d87caaf98 100644--- a/apps/mobile/app/components/sheets/reminder/index.tsx+++ b/apps/mobile/app/components/sheets/reminder/index.tsx@@ -517,7 +517,7 @@ export default function ReminderSheet({mode="date"onConfirm={handleConfirm}onCancel={hideDatePicker}- is24Hour={db.settings?.getTimeFormat() === "24-hour"}+ is24Hour={db.settings.getTimeFormat() === "24-hour"}date={date || new Date(Date.now())}/>diff --git a/apps/mobile/app/components/sheets/topic-sheet/index.tsx b/apps/mobile/app/components/sheets/topic-sheet/index.tsxindex 362dd071e..f7931bba3 100644--- a/apps/mobile/app/components/sheets/topic-sheet/index.tsx+++ b/apps/mobile/app/components/sheets/topic-sheet/index.tsx@@ -103,14 +103,14 @@ export const TopicsSheet = () => {const [topics, setTopics] = useState(notebook? qclone(- groupArray(notebook.topics, db.settings?.getGroupOptions("topics"))+ groupArray(notebook.topics, db.settings.getGroupOptions("topics"))): []);const currentItem = useRef<string>();const { fontScale } = useWindowDimensions();const [groupOptions, setGroupOptions] = useState(- db.settings?.getGroupOptions("topics")+ db.settings.getGroupOptions("topics"));const onRequestUpdate = React.useCallback(@@ -124,7 +124,7 @@ export const TopicsSheet = () => {setTopics(qclone(- groupArray(_notebook.topics, db.settings?.getGroupOptions("topics"))+ groupArray(_notebook.topics, db.settings.getGroupOptions("topics"))));}@@ -133,7 +133,7 @@ export const TopicsSheet = () => {);const onUpdate = useCallback(() => {- setGroupOptions({ ...(db.settings?.getGroupOptions("topics") as any) });+ setGroupOptions({ ...(db.settings.getGroupOptions("topics") as any) });onRequestUpdate();}, [onRequestUpdate]);diff --git a/apps/mobile/app/screens/editor/tiptap/use-editor.ts b/apps/mobile/app/screens/editor/tiptap/use-editor.tsindex 932c1b72d..57a67761e 100644--- a/apps/mobile/app/screens/editor/tiptap/use-editor.ts+++ b/apps/mobile/app/screens/editor/tiptap/use-editor.ts@@ -211,7 +211,7 @@ export const useEditor = (id = await db.notes?.add(noteData);if (!note && id) {currentNote.current = db.notes?.note(id).data as NoteType;- const defaultNotebook = db.settings?.getDefaultNotebook();+ const defaultNotebook = db.settings.getDefaultNotebook();if (!state.current.onNoteCreated && defaultNotebook) {onNoteCreated(id, {type: defaultNotebook.topic ? "topic" : "notebook",diff --git a/apps/mobile/app/screens/notebook/index.tsx b/apps/mobile/app/screens/notebook/index.tsxindex e861b02bf..37547dbd0 100644--- a/apps/mobile/app/screens/notebook/index.tsx+++ b/apps/mobile/app/screens/notebook/index.tsx@@ -40,7 +40,7 @@ const Notebook = ({ route, navigation }: NavigationProps<"Notebook">) => {const [notes, setNotes] = useState(groupArray(db.relations?.from(route.params.item, "note") || [],- db.settings?.getGroupOptions("notes")+ db.settings.getGroupOptions("notes")));const params = useRef<NotebookScreenParams>(route?.params);@@ -86,7 +86,7 @@ const Notebook = ({ route, navigation }: NavigationProps<"Notebook">) => {params.current.item = notebook;const notes = db.relations?.from(notebook, "note");setNotes(- groupArray(notes || [], db.settings?.getGroupOptions("notes"))+ groupArray(notes || [], db.settings.getGroupOptions("notes")));syncWithNavigation();}diff --git a/apps/mobile/app/screens/notes/colored.tsx b/apps/mobile/app/screens/notes/colored.tsxindex 1255725bb..9d69eb977 100644--- a/apps/mobile/app/screens/notes/colored.tsx+++ b/apps/mobile/app/screens/notes/colored.tsx@@ -45,7 +45,7 @@ export const ColoredNotes = ({ColoredNotes.get = (params: NotesScreenParams, grouped = true) => {const notes = db.notes?.colored(params.item.id) || [];return grouped- ? groupArray(notes, db.settings?.getGroupOptions("notes"))+ ? groupArray(notes, db.settings.getGroupOptions("notes")): notes;};diff --git a/apps/mobile/app/screens/notes/monographs.tsx b/apps/mobile/app/screens/notes/monographs.tsxindex 601704fac..55638236e 100644--- a/apps/mobile/app/screens/notes/monographs.tsx+++ b/apps/mobile/app/screens/notes/monographs.tsx@@ -45,7 +45,7 @@ export const Monographs = ({Monographs.get = (params: NotesScreenParams, grouped = true) => {const notes = db.monographs?.all || [];return grouped- ? groupArray(notes, db.settings?.getGroupOptions("notes"))+ ? groupArray(notes, db.settings.getGroupOptions("notes")): notes;};diff --git a/apps/mobile/app/screens/notes/tagged.tsx b/apps/mobile/app/screens/notes/tagged.tsxindex 069c1aadd..41b1c225b 100644--- a/apps/mobile/app/screens/notes/tagged.tsx+++ b/apps/mobile/app/screens/notes/tagged.tsx@@ -45,7 +45,7 @@ export const TaggedNotes = ({TaggedNotes.get = (params: NotesScreenParams, grouped = true) => {const notes = db.notes?.tagged((params.item as unknown as NoteType).id) || [];return grouped- ? groupArray(notes, db.settings?.getGroupOptions("notes"))+ ? groupArray(notes, db.settings.getGroupOptions("notes")): notes;};diff --git a/apps/mobile/app/screens/notes/topic-notes.tsx b/apps/mobile/app/screens/notes/topic-notes.tsxindex 75f7d03c4..922f8d8e3 100644--- a/apps/mobile/app/screens/notes/topic-notes.tsx+++ b/apps/mobile/app/screens/notes/topic-notes.tsx@@ -81,7 +81,7 @@ TopicNotes.get = (params: NotesScreenParams, grouped = true) => {}const notes = topic?.all || [];return grouped- ? groupArray(notes, db.settings?.getGroupOptions("notes"))+ ? groupArray(notes, db.settings.getGroupOptions("notes")): notes;};diff --git a/apps/mobile/app/screens/settings/editor/state.ts b/apps/mobile/app/screens/settings/editor/state.tsindex 2c411785a..b1c5912c5 100644--- a/apps/mobile/app/screens/settings/editor/state.ts+++ b/apps/mobile/app/screens/settings/editor/state.ts@@ -70,7 +70,7 @@ export const useDragState = create<DragState>(const _data = clone(data);presets["custom"] = _data;- db.settings?.setToolbarConfig(+ db.settings.setToolbarConfig(useSettingStore.getState().deviceMode || "mobile",{preset: "custom",@@ -80,7 +80,7 @@ export const useDragState = create<DragState>(set({ data: _data, preset: "custom", customPresetData: _data });},setPreset: (preset) => {- db.settings?.setToolbarConfig(+ db.settings.setToolbarConfig(useSettingStore.getState().deviceMode || "mobile",{preset,@@ -98,7 +98,7 @@ export const useDragState = create<DragState>(init: async () => {const user = await db.user?.getUser();if (!user) return;- const toolbarConfig = db.settings?.getToolbarConfig(+ const toolbarConfig = db.settings.getToolbarConfig(useSettingStore.getState().deviceMode || "mobile");if (!toolbarConfig) {diff --git a/apps/mobile/app/screens/settings/settings-data.tsx b/apps/mobile/app/screens/settings/settings-data.tsxindex 28fdc9a9d..b4aa47bf7 100644--- a/apps/mobile/app/screens/settings/settings-data.tsx+++ b/apps/mobile/app/screens/settings/settings-data.tsx@@ -516,9 +516,9 @@ export const settingsGroups: SettingSection[] = [name: "Clear default notebook/topic",description: "Clear the default notebook/topic for new notes",modifer: () => {- db.settings?.setDefaultNotebook(undefined);+ db.settings.setDefaultNotebook(undefined);},- hidden: () => !db.settings?.getDefaultNotebook()+ hidden: () => !db.settings.getDefaultNotebook()}]},diff --git a/apps/mobile/app/screens/settings/title-format.tsx b/apps/mobile/app/screens/settings/title-format.tsxindex 4f08a58f7..f5d28b10c 100644--- a/apps/mobile/app/screens/settings/title-format.tsx+++ b/apps/mobile/app/screens/settings/title-format.tsx@@ -26,7 +26,7 @@ import { useThemeColors } from "@notesnook/theme";import { SIZE } from "../../utils/size";export const TitleFormat = () => {- const [titleFormat] = useState(db.settings?.getTitleFormat());+ const [titleFormat] = useState(db.settings.getTitleFormat());const inputRef = useRef<TextInput>();const { colors } = useThemeColors();@@ -34,10 +34,10 @@ export const TitleFormat = () => {<><InputonSubmit={(e) => {- db.settings?.setTitleFormat(e.nativeEvent.text);+ db.settings.setTitleFormat(e.nativeEvent.text);}}onChangeText={(text) => {- db.settings?.setTitleFormat(text);+ db.settings.setTitleFormat(text);}}containerStyle={{ marginTop: 6 }}onLayout={() => {diff --git a/apps/mobile/app/screens/trash/index.tsx b/apps/mobile/app/screens/trash/index.tsxindex b61eb4180..7f92a4fdd 100644--- a/apps/mobile/app/screens/trash/index.tsx+++ b/apps/mobile/app/screens/trash/index.tsx@@ -102,7 +102,7 @@ export const Trash = ({ navigation, route }: NavigationProps<"Trash">) => {screen="Trash"loading={!isFocused}placeholderData={PLACEHOLDER_DATA(- db.settings?.getTrashCleanupInterval()+ db.settings.getTrashCleanupInterval())}headerProps={{heading: "Trash",diff --git a/apps/mobile/app/stores/use-favorite-store.ts b/apps/mobile/app/stores/use-favorite-store.tsindex 7836c955b..0f6a07787 100644--- a/apps/mobile/app/stores/use-favorite-store.ts+++ b/apps/mobile/app/stores/use-favorite-store.ts@@ -35,7 +35,7 @@ export const useFavoriteStore = create<FavoriteStore>((set, get) => ({set({favorites: groupArray(db?.notes?.favorites || [],- db.settings?.getGroupOptions("favorites")+ db.settings.getGroupOptions("favorites"))});return;diff --git a/apps/mobile/app/stores/use-notebook-store.ts b/apps/mobile/app/stores/use-notebook-store.tsindex bf253a213..101e04c1b 100644--- a/apps/mobile/app/stores/use-notebook-store.ts+++ b/apps/mobile/app/stores/use-notebook-store.ts@@ -34,7 +34,7 @@ export const useNotebookStore = create<NotebookStore>((set, get) => ({set({notebooks: groupArray((db?.notebooks?.all as NotebookType[]) || [],- db.settings?.getGroupOptions("notebooks")+ db.settings.getGroupOptions("notebooks"))});return;diff --git a/apps/mobile/app/stores/use-notes-store.ts b/apps/mobile/app/stores/use-notes-store.tsindex b0e7b8eb9..e52b7a15b 100644--- a/apps/mobile/app/stores/use-notes-store.ts+++ b/apps/mobile/app/stores/use-notes-store.ts@@ -40,7 +40,7 @@ export const useNoteStore = create<NoteStore>((set, get) => ({set({notes: groupArray((db.notes?.all as NoteType[]) || [],- db.settings?.getGroupOptions("home")+ db.settings.getGroupOptions("home"))});return;diff --git a/apps/mobile/app/stores/use-tag-store.ts b/apps/mobile/app/stores/use-tag-store.tsindex 88cc38ab3..eaf8af0b3 100644--- a/apps/mobile/app/stores/use-tag-store.ts+++ b/apps/mobile/app/stores/use-tag-store.ts@@ -36,7 +36,7 @@ export const useTagStore = create<TagStore>((set, get) => ({set({tags: groupArray((db?.tags?.all as TagType[]) || [],- db.settings?.getGroupOptions("tags")+ db.settings.getGroupOptions("tags"))});return;diff --git a/apps/mobile/app/stores/use-trash-store.ts b/apps/mobile/app/stores/use-trash-store.tsindex 8e5defd64..80793f4b6 100644--- a/apps/mobile/app/stores/use-trash-store.ts+++ b/apps/mobile/app/stores/use-trash-store.ts@@ -35,7 +35,7 @@ export const useTrashStore = create<TrashStore>((set, get) => ({set({trash: groupArray(db?.trash?.all || [],- db.settings?.getGroupOptions("trash")+ db.settings.getGroupOptions("trash"))});return;