From 900de4f93f12fb66ce9cff4dace5804bef12370a Mon Sep 17 00:00:00 2001 From: ammarahm-ed Date: Tue, 30 Aug 2022 13:30:11 +0500 Subject: [PATCH] mobile: fix all typescript errors --- apps/mobile/app/common/database/index.js | 2 - apps/mobile/app/components/auth/two-factor.js | 4 +- .../delay-layout/default-placeholder.tsx | 6 +- .../components/sheets/move-notes/movenote.tsx | 16 +++- apps/mobile/app/components/tip/index.tsx | 12 +-- .../ui/animated-button.tsx/index.tsx | 20 +++-- .../mobile/app/components/ui/button/index.tsx | 25 +++--- .../app/components/ui/icon-button/index.tsx | 5 +- apps/mobile/app/components/ui/input/index.tsx | 59 ++++++-------- .../app/components/ui/pressable/index.tsx | 16 ++-- .../app/components/walkthroughs/index.tsx | 6 -- apps/mobile/app/hooks/use-rotator.ts | 4 +- apps/mobile/app/hooks/use-sync-progress.ts | 3 - apps/mobile/app/hooks/use-tooltip.ts | 1 - apps/mobile/app/hooks/use-vault-status.ts | 48 +++++++++++ apps/mobile/app/screens/editor/index.tsx | 16 ++-- .../mobile/app/screens/editor/tiptap/types.ts | 3 +- .../editor/tiptap/use-editor-events.ts | 9 ++- .../app/screens/editor/tiptap/use-editor.ts | 26 +++--- .../mobile/app/screens/editor/tiptap/utils.ts | 5 +- apps/mobile/app/screens/notes/colored.tsx | 6 +- apps/mobile/app/screens/notes/common.ts | 6 +- apps/mobile/app/screens/notes/index.tsx | 13 ++- apps/mobile/app/screens/notes/monographs.tsx | 1 - apps/mobile/app/screens/notes/tagged.tsx | 5 +- apps/mobile/app/screens/notes/topic-notes.tsx | 10 ++- apps/mobile/app/screens/settings/2fa.tsx | 11 +-- .../settings/editor/configure-toolbar.tsx | 7 +- .../app/screens/settings/editor/group.tsx | 4 +- .../app/screens/settings/editor/state.ts | 6 +- .../screens/settings/editor/tool-sheet.tsx | 9 +-- .../app/screens/settings/editor/tool.tsx | 29 ++++--- .../settings/editor/toolbar-definition.ts | 8 +- apps/mobile/app/screens/settings/group.tsx | 3 +- apps/mobile/app/screens/settings/home.tsx | 2 +- apps/mobile/app/screens/settings/index.tsx | 6 +- .../app/screens/settings/section-item.tsx | 3 - .../app/screens/settings/settings-data.tsx | 51 +++++++----- apps/mobile/app/services/biometrics.ts | 25 +++--- apps/mobile/app/services/navigation.ts | 61 +++----------- apps/mobile/app/services/notifications.ts | 48 ++++++----- apps/mobile/app/services/settings.ts | 35 ++++---- apps/mobile/app/services/tip-manager.ts | 17 ++-- apps/mobile/app/stores/index.ts | 8 +- .../mobile/app/stores/use-attachment-store.ts | 1 - apps/mobile/app/stores/use-editor-store.ts | 1 - apps/mobile/app/stores/use-favorite-store.ts | 1 - apps/mobile/app/stores/use-menu-store.ts | 10 +-- apps/mobile/app/stores/use-message-store.ts | 1 - .../mobile/app/stores/use-navigation-store.ts | 79 ++++++++++++++----- apps/mobile/app/stores/use-notebook-store.ts | 1 - apps/mobile/app/stores/use-notes-store.ts | 1 - apps/mobile/app/stores/use-selection-store.ts | 11 +-- apps/mobile/app/stores/use-setting-store.ts | 7 +- apps/mobile/app/stores/use-tag-store.ts | 1 - apps/mobile/app/stores/use-theme-store.ts | 2 + apps/mobile/app/stores/use-trash-store.ts | 1 - apps/mobile/app/utils/global-refs.ts | 3 +- apps/mobile/app/utils/types.ts | 2 + 59 files changed, 395 insertions(+), 387 deletions(-) create mode 100644 apps/mobile/app/hooks/use-vault-status.ts diff --git a/apps/mobile/app/common/database/index.js b/apps/mobile/app/common/database/index.js index 2ea388d476..fa13a586c0 100644 --- a/apps/mobile/app/common/database/index.js +++ b/apps/mobile/app/common/database/index.js @@ -53,9 +53,7 @@ export async function loadDatabase() { // DB = module.default; // } // db = new DB(Storage, Platform.OS === 'ios' ? EventSource : AndroidEventSource, filesystem); - // //@ts-ignore // if (DOMParser) { - // //@ts-ignore // await DOMParser.prepare(); // } } diff --git a/apps/mobile/app/components/auth/two-factor.js b/apps/mobile/app/components/auth/two-factor.js index a73e5c04ac..5fd5251e8b 100644 --- a/apps/mobile/app/components/auth/two-factor.js +++ b/apps/mobile/app/components/auth/two-factor.js @@ -194,7 +194,6 @@ const TwoFactorVerification = ({ onMfaLogin, mfaInfo }) => { code.current = value; onNext(); }} - //@ts-ignore inputStyle={{ fontSize: SIZE.lg, height: 60, @@ -208,8 +207,7 @@ const TwoFactorVerification = ({ onMfaLogin, mfaInfo }) => { containerStyle={{ height: 60, borderWidth: 0, - //@ts-ignore - width: null, + width: undefined, minWidth: "50%" }} /> diff --git a/apps/mobile/app/components/delay-layout/default-placeholder.tsx b/apps/mobile/app/components/delay-layout/default-placeholder.tsx index 0758533889..7e0ce76230 100644 --- a/apps/mobile/app/components/delay-layout/default-placeholder.tsx +++ b/apps/mobile/app/components/delay-layout/default-placeholder.tsx @@ -10,9 +10,11 @@ export const DefaultPlaceholder = ({ color }: { color: string }) => { const message = useMessageStore((state) => state.message); const annoucements = useMessageStore((state) => state.announcements); const hasAnnoucements = annoucements.length > 0; - //@ts-ignore const shadeColor = color - ? hexToRGBA(COLORS_NOTE[color?.toLowerCase()], 0.15) + ? hexToRGBA( + COLORS_NOTE[color?.toLowerCase() as keyof typeof COLORS_NOTE], + 0.15 + ) : colors.shade; return ( diff --git a/apps/mobile/app/components/sheets/move-notes/movenote.tsx b/apps/mobile/app/components/sheets/move-notes/movenote.tsx index fdbb2e5733..7a502694b3 100644 --- a/apps/mobile/app/components/sheets/move-notes/movenote.tsx +++ b/apps/mobile/app/components/sheets/move-notes/movenote.tsx @@ -23,6 +23,15 @@ import { PressableButton } from "../../ui/pressable"; import Seperator from "../../ui/seperator"; import Heading from "../../ui/typography/heading"; import Paragraph from "../../ui/typography/paragraph"; + +type CommonItemType = { + id: string; + title: string; + headline?: string; + type: string; + notes?: string[]; +}; + export const MoveNotes = ({ notebook, selectedTopic, @@ -74,7 +83,6 @@ export const MoveNotes = ({ const addNewTopic = async (value: string) => { if (!value || value.trim().length === 0) { - //@ts-ignore ToastEvent.show({ heading: "Topic title is required", type: "error", @@ -99,13 +107,13 @@ export const MoveNotes = ({ return true; }; - const renderItem = ({ item }: { item: TopicType | NoteType }) => { + const renderItem = ({ item }: { item: CommonItemType }) => { return ( { if (item.type == "topic") { - setTopic(topic || item); + setTopic(topic || (item as TopicType)); } else { select(item.id); } @@ -143,7 +151,7 @@ export const MoveNotes = ({ }} color={colors.icon} > - {item.notes.length} Notes + {item.notes?.length} Notes ) : null} diff --git a/apps/mobile/app/components/tip/index.tsx b/apps/mobile/app/components/tip/index.tsx index 30dd7336f1..eeb9543b6e 100644 --- a/apps/mobile/app/components/tip/index.tsx +++ b/apps/mobile/app/components/tip/index.tsx @@ -47,27 +47,23 @@ export const Tip = ({ }} >