Skip to content

A fully open source & end-to-end encrypted note taking alternative to Evernote.

web: fix type errors

Abdullah Atta0a36b5ba5bea
diff --git a/apps/web/src/components/diff-viewer/index.tsx b/apps/web/src/components/diff-viewer/index.tsx
index 3e170b5fa..6bb4b9637 100644
--- a/apps/web/src/components/diff-viewer/index.tsx
+++ b/apps/web/src/components/diff-viewer/index.tsx
@@ -124,7 +124,7 @@ function DiffViewer(props: DiffViewerProps) {
closeSessions(session.id, session.note.id);
await notesStore.refresh();
- await openSession(session.note.id, true);
+ await openSession(session.note.id, { force: true });
}}
mr={2}
sx={{
@@ -365,7 +365,7 @@ async function resolveConflict({
}
await notesStore.refresh();
- useEditorStore.getState().openSession(note.id, true);
+ useEditorStore.getState().openSession(note.id, { force: true });
}
async function createCopy(note: Note, content: ContentItem) {
diff --git a/apps/web/src/components/editor/manager.ts b/apps/web/src/components/editor/manager.ts
index 58b6aead8..0c8d6ef71 100644
--- a/apps/web/src/components/editor/manager.ts
+++ b/apps/web/src/components/editor/manager.ts
@@ -17,7 +17,7 @@ You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-import { useCallback } from "react";
+import { useCallback, useEffect } from "react";
import { IEditor, NoteStatistics } from "./types";
import createStore from "../../common/store";
import BaseStore from "../../stores";
@@ -119,14 +119,18 @@ export function useSearch() {
}
export function useToolbarConfig() {
- const toolbarConfig =
- useEditorManager((store) => store.toolbarConfig) ||
- getCurrentPreset().tools;
+ const toolbarConfig = useEditorManager((store) => store.toolbarConfig);
const setToolbarConfig = useCallback(
(config: ToolbarDefinition) =>
useEditorManager.setState({ toolbarConfig: config }),
[]
);
+ useEffect(() => {
+ getCurrentPreset().then((preset) =>
+ useEditorManager.setState({ toolbarConfig: preset.tools })
+ );
+ }, []);
+
return { toolbarConfig, setToolbarConfig };
}
diff --git a/apps/web/src/dialogs/note-linking-dialog.tsx b/apps/web/src/dialogs/note-linking-dialog.tsx
index f22a4d46e..a351beb1e 100644
--- a/apps/web/src/dialogs/note-linking-dialog.tsx
+++ b/apps/web/src/dialogs/note-linking-dialog.tsx
@@ -29,10 +29,10 @@ import {
createInternalLink
} from "@notesnook/core";
import { VirtualizedList } from "../components/virtualized-list";
-import { ResolvedItem } from "../components/list-container/resolved-item";
import { Button, Flex, Text } from "@theme-ui/components";
import { ScrollContainer } from "@notesnook/ui";
import { LinkAttributes } from "@notesnook/editor/dist/extensions/link";
+import { ResolvedItem } from "@notesnook/common";
export type NoteLinkingDialogProps = {
attributes?: LinkAttributes;
diff --git a/apps/web/src/stores/note-store.ts b/apps/web/src/stores/note-store.ts
index 8bb8c6afb..fb12490e9 100644
--- a/apps/web/src/stores/note-store.ts
+++ b/apps/web/src/stores/note-store.ts
@@ -104,7 +104,7 @@ class NoteStore extends BaseStore<NoteStore> {
if (!(await Vault.lockNote(id))) return false;
await this.refresh();
if (useEditorStore.getState().getActiveSession()?.id === id)
- await useEditorStore.getState().openSession(id, true);
+ await useEditorStore.getState().openSession(id, { force: true });
};
readonly = async (state: boolean, ...ids: string[]) => {
diff --git a/apps/web/src/stores/user-store.ts b/apps/web/src/stores/user-store.ts
index cd02a6789..2f41ce2bf 100644
--- a/apps/web/src/stores/user-store.ts
+++ b/apps/web/src/stores/user-store.ts
@@ -120,7 +120,7 @@ class UserStore extends BaseStore<UserStore> {
form:
| { email: string }
| { email: string; password: string }
- | { code: string; method: AuthenticatorType },
+ | { code: string; method: AuthenticatorType | "recoveryCode" },
skipInit = false,
sessionExpired = false
) => {
diff --git a/apps/web/src/views/auth.tsx b/apps/web/src/views/auth.tsx
index 45dfa254f..287d17720 100644
--- a/apps/web/src/views/auth.tsx
+++ b/apps/web/src/views/auth.tsx
@@ -54,8 +54,8 @@ type PasswordFormData = EmailFormData & {
};
type MFALoginFormData = {
- code?: string;
- method?: MFAMethodType;
+ code: string;
+ method: MFAMethodType;
};
type SignupFormData = EmailFormData &
@@ -652,6 +652,8 @@ function MFACode(props: BaseAuthComponentProps<"mfa:code">) {
subtitle: "Please wait while you are authenticated."
}}
onSubmit={async (form) => {
+ if (!form.code) throw new Error("2FA code is required.");
+
const loginForm: MFALoginFormData = {
code: form.code,
method: formData.selectedMethod