mirror of
https://github.com/streetwriters/notesnook.git
synced 2025-12-23 06:59:31 +01:00
web: fix type errors and broken imports
This commit is contained in:
@@ -41,7 +41,7 @@ import { createWritableStream } from "./desktop-bridge";
|
|||||||
import { createZipStream } from "../utils/streams/zip-stream";
|
import { createZipStream } from "../utils/streams/zip-stream";
|
||||||
import { FeatureKeys } from "../dialogs/feature-dialog";
|
import { FeatureKeys } from "../dialogs/feature-dialog";
|
||||||
import { ZipEntry, createUnzipIterator } from "../utils/streams/unzip-stream";
|
import { ZipEntry, createUnzipIterator } from "../utils/streams/unzip-stream";
|
||||||
import { User } from "@notesnook/core/dist/api/user-manager";
|
import { User } from "@notesnook/core";
|
||||||
import { LegacyBackupFile } from "@notesnook/core";
|
import { LegacyBackupFile } from "@notesnook/core";
|
||||||
import { useEditorStore } from "../stores/editor-store";
|
import { useEditorStore } from "../stores/editor-store";
|
||||||
|
|
||||||
|
|||||||
@@ -187,7 +187,6 @@ function DiffViewer(props: DiffViewerProps) {
|
|||||||
unlock={async (password) => {
|
unlock={async (password) => {
|
||||||
const decryptedContent = await db.vault.decryptContent(
|
const decryptedContent = await db.vault.decryptContent(
|
||||||
content,
|
content,
|
||||||
session.note.id,
|
|
||||||
password
|
password
|
||||||
);
|
);
|
||||||
setContent({
|
setContent({
|
||||||
@@ -271,7 +270,6 @@ function DiffViewer(props: DiffViewerProps) {
|
|||||||
unlock={async (password) => {
|
unlock={async (password) => {
|
||||||
const decryptedContent = await db.vault.decryptContent(
|
const decryptedContent = await db.vault.decryptContent(
|
||||||
conflictedContent,
|
conflictedContent,
|
||||||
session.note.id,
|
|
||||||
password
|
password
|
||||||
);
|
);
|
||||||
setConflictedContent({
|
setConflictedContent({
|
||||||
|
|||||||
@@ -34,7 +34,9 @@ import { Tag } from "@notesnook/core";
|
|||||||
type HeaderProps = { readonly: boolean; id: string };
|
type HeaderProps = { readonly: boolean; id: string };
|
||||||
function Header(props: HeaderProps) {
|
function Header(props: HeaderProps) {
|
||||||
const { readonly, id } = props;
|
const { readonly, id } = props;
|
||||||
const tags = useEditorStore((store) => store.getSession(id)?.tags || []);
|
const tags = useEditorStore(
|
||||||
|
(store) => store.getSession(id, ["default", "readonly"])?.tags || []
|
||||||
|
);
|
||||||
const refreshTags = useEditorStore((store) => store.refreshTags);
|
const refreshTags = useEditorStore((store) => store.refreshTags);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
|
|||||||
@@ -151,7 +151,7 @@ function EditorView({ id }: { id: string }) {
|
|||||||
const isTOCVisible = useEditorStore((store) => store.isTOCVisible);
|
const isTOCVisible = useEditorStore((store) => store.isTOCVisible);
|
||||||
const toggleProperties = useEditorStore((store) => store.toggleProperties);
|
const toggleProperties = useEditorStore((store) => store.toggleProperties);
|
||||||
const isReadonly = useEditorStore(
|
const isReadonly = useEditorStore(
|
||||||
(store) => store.getSession(id, ["default"])?.note?.readonly
|
(store) => store.getSession(id, ["default", "readonly"])?.note?.readonly
|
||||||
);
|
);
|
||||||
const isFocusMode = useAppStore((store) => store.isFocusMode);
|
const isFocusMode = useAppStore((store) => store.isFocusMode);
|
||||||
const isPreviewSession = !!previewSession.current;
|
const isPreviewSession = !!previewSession.current;
|
||||||
|
|||||||
@@ -62,7 +62,7 @@ function TitleBox(props: TitleBoxProps) {
|
|||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const session = useEditorStore.getState().getSession(id);
|
const session = useEditorStore.getState().getSession(id);
|
||||||
if (!session || !session.note) return;
|
if (!session || !("note" in session) || !session.note) return;
|
||||||
|
|
||||||
const { title } = session.note;
|
const { title } = session.note;
|
||||||
if (!inputRef.current) return;
|
if (!inputRef.current) return;
|
||||||
|
|||||||
@@ -42,7 +42,7 @@ import useStatus, { statusToString } from "../../hooks/use-status";
|
|||||||
import { ScopedThemeProvider } from "../theme-provider";
|
import { ScopedThemeProvider } from "../theme-provider";
|
||||||
import { checkForUpdate, installUpdate } from "../../utils/updater";
|
import { checkForUpdate, installUpdate } from "../../utils/updater";
|
||||||
import { getTimeAgo, toTitleCase } from "@notesnook/common";
|
import { getTimeAgo, toTitleCase } from "@notesnook/common";
|
||||||
import { User } from "@notesnook/core/dist/api/user-manager";
|
import { User } from "@notesnook/core";
|
||||||
|
|
||||||
function StatusBar() {
|
function StatusBar() {
|
||||||
const user = useUserStore((state) => state.user);
|
const user = useUserStore((state) => state.user);
|
||||||
|
|||||||
@@ -44,7 +44,7 @@ import { isUserSubscribed } from "../../hooks/use-is-user-premium";
|
|||||||
import { SUBSCRIPTION_STATUS } from "../../common/constants";
|
import { SUBSCRIPTION_STATUS } from "../../common/constants";
|
||||||
import BaseDialog from "../../components/dialog";
|
import BaseDialog from "../../components/dialog";
|
||||||
import { ScopedThemeProvider } from "../../components/theme-provider";
|
import { ScopedThemeProvider } from "../../components/theme-provider";
|
||||||
import { User } from "@notesnook/core/dist/api/user-manager";
|
import { User } from "@notesnook/core";
|
||||||
|
|
||||||
type BuyDialogProps = {
|
type BuyDialogProps = {
|
||||||
couponCode?: string;
|
couponCode?: string;
|
||||||
|
|||||||
@@ -30,7 +30,7 @@ import {
|
|||||||
} from "./steps";
|
} from "./steps";
|
||||||
import { Authenticator, OnNextFunction } from "./types";
|
import { Authenticator, OnNextFunction } from "./types";
|
||||||
import { ErrorText } from "../../components/error-text";
|
import { ErrorText } from "../../components/error-text";
|
||||||
import { AuthenticatorType } from "@notesnook/core/dist/api/user-manager";
|
import { AuthenticatorType } from "@notesnook/core";
|
||||||
|
|
||||||
type MultifactorDialogProps = {
|
type MultifactorDialogProps = {
|
||||||
onClose: Perform;
|
onClose: Perform;
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ import { Perform } from "../../common/dialog-controller";
|
|||||||
import Dialog from "../../components/dialog";
|
import Dialog from "../../components/dialog";
|
||||||
import { steps } from "./steps";
|
import { steps } from "./steps";
|
||||||
import { ErrorText } from "../../components/error-text";
|
import { ErrorText } from "../../components/error-text";
|
||||||
import { AuthenticatorType } from "@notesnook/core/dist/api/user-manager";
|
import { AuthenticatorType } from "@notesnook/core";
|
||||||
|
|
||||||
type RecoveryCodesDialogProps = {
|
type RecoveryCodesDialogProps = {
|
||||||
onClose: Perform;
|
onClose: Perform;
|
||||||
|
|||||||
@@ -57,7 +57,7 @@ import {
|
|||||||
} from "./types";
|
} from "./types";
|
||||||
import { showMultifactorDialog } from "../../common/dialog-controller";
|
import { showMultifactorDialog } from "../../common/dialog-controller";
|
||||||
import { ErrorText } from "../../components/error-text";
|
import { ErrorText } from "../../components/error-text";
|
||||||
import { AuthenticatorType } from "@notesnook/core/dist/api/user-manager";
|
import { AuthenticatorType } from "@notesnook/core";
|
||||||
|
|
||||||
const QRCode = React.lazy(() => import("../../re-exports/react-qrcode-logo"));
|
const QRCode = React.lazy(() => import("../../re-exports/react-qrcode-logo"));
|
||||||
|
|
||||||
|
|||||||
@@ -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/>.
|
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { AuthenticatorType } from "@notesnook/core/dist/api/user-manager";
|
import { AuthenticatorType } from "@notesnook/core";
|
||||||
import { Perform } from "../../common/dialog-controller";
|
import { Perform } from "../../common/dialog-controller";
|
||||||
import { Icon } from "../../components/icons";
|
import { Icon } from "../../components/icons";
|
||||||
|
|
||||||
|
|||||||
@@ -103,8 +103,11 @@ export const BackupExportSettings: SettingsGroup[] = [
|
|||||||
description: "Encrypt all backup files using your master key.",
|
description: "Encrypt all backup files using your master key.",
|
||||||
isHidden: () => !useUserStore.getState().isLoggedIn,
|
isHidden: () => !useUserStore.getState().isLoggedIn,
|
||||||
onStateChange: (listener) => {
|
onStateChange: (listener) => {
|
||||||
useUserStore.subscribe((s) => s.isLoggedIn, listener);
|
const subscriptions = [
|
||||||
useSettingStore.subscribe((s) => s.encryptBackups, listener);
|
useUserStore.subscribe((s) => s.isLoggedIn, listener),
|
||||||
|
useSettingStore.subscribe((s) => s.encryptBackups, listener)
|
||||||
|
];
|
||||||
|
return () => subscriptions.forEach((s) => s());
|
||||||
},
|
},
|
||||||
components: [
|
components: [
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -22,6 +22,8 @@ import { SettingsGroup } from "./types";
|
|||||||
import { useStore as useSettingStore } from "../../stores/setting-store";
|
import { useStore as useSettingStore } from "../../stores/setting-store";
|
||||||
import dayjs from "dayjs";
|
import dayjs from "dayjs";
|
||||||
import { isUserPremium } from "../../hooks/use-is-user-premium";
|
import { isUserPremium } from "../../hooks/use-is-user-premium";
|
||||||
|
import { TimeFormat } from "@notesnook/core/dist/utils/date";
|
||||||
|
import { TrashCleanupInterval } from "@notesnook/core";
|
||||||
|
|
||||||
export const BehaviourSettings: SettingsGroup[] = [
|
export const BehaviourSettings: SettingsGroup[] = [
|
||||||
{
|
{
|
||||||
@@ -91,7 +93,7 @@ export const BehaviourSettings: SettingsGroup[] = [
|
|||||||
{
|
{
|
||||||
type: "dropdown",
|
type: "dropdown",
|
||||||
onSelectionChanged: (value) =>
|
onSelectionChanged: (value) =>
|
||||||
useSettingStore.getState().setTimeFormat(value),
|
useSettingStore.getState().setTimeFormat(value as TimeFormat),
|
||||||
selectedOption: () => useSettingStore.getState().timeFormat,
|
selectedOption: () => useSettingStore.getState().timeFormat,
|
||||||
options: [
|
options: [
|
||||||
{ value: "12-hour", title: "12h" },
|
{ value: "12-hour", title: "12h" },
|
||||||
@@ -121,7 +123,9 @@ export const BehaviourSettings: SettingsGroup[] = [
|
|||||||
onSelectionChanged: (value) =>
|
onSelectionChanged: (value) =>
|
||||||
useSettingStore
|
useSettingStore
|
||||||
.getState()
|
.getState()
|
||||||
.setTrashCleanupInterval(parseInt(value)),
|
.setTrashCleanupInterval(
|
||||||
|
parseInt(value) as TrashCleanupInterval
|
||||||
|
),
|
||||||
selectedOption: () =>
|
selectedOption: () =>
|
||||||
useSettingStore.getState().trashCleanupInterval.toString(),
|
useSettingStore.getState().trashCleanupInterval.toString(),
|
||||||
options: [
|
options: [
|
||||||
|
|||||||
@@ -145,5 +145,5 @@ export type TextInputSettingComponent = BaseSettingComponent<"input"> & {
|
|||||||
};
|
};
|
||||||
|
|
||||||
export type CustomSettingComponent = BaseSettingComponent<"custom"> & {
|
export type CustomSettingComponent = BaseSettingComponent<"custom"> & {
|
||||||
component: () => JSX.Element;
|
component: () => JSX.Element | null;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -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/>.
|
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { User } from "@notesnook/core/dist/api/user-manager";
|
import { User } from "@notesnook/core";
|
||||||
import { SUBSCRIPTION_STATUS } from "../common/constants";
|
import { SUBSCRIPTION_STATUS } from "../common/constants";
|
||||||
import {
|
import {
|
||||||
useStore as useUserStore,
|
useStore as useUserStore,
|
||||||
@@ -30,7 +30,6 @@ export function useIsUserPremium() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export function isUserPremium(user?: User) {
|
export function isUserPremium(user?: User) {
|
||||||
return true;
|
|
||||||
if (IS_TESTING) return true;
|
if (IS_TESTING) return true;
|
||||||
if (!user) user = userstore.get().user;
|
if (!user) user = userstore.get().user;
|
||||||
if (!user) return false;
|
if (!user) return false;
|
||||||
|
|||||||
@@ -28,7 +28,7 @@ import { NNCrypto } from "./nncrypto";
|
|||||||
import type { Cipher, SerializedKey } from "@notesnook/crypto/dist/src/types";
|
import type { Cipher, SerializedKey } from "@notesnook/crypto/dist/src/types";
|
||||||
import { isFeatureSupported } from "../utils/feature-check";
|
import { isFeatureSupported } from "../utils/feature-check";
|
||||||
import { IKeyStore } from "./key-store";
|
import { IKeyStore } from "./key-store";
|
||||||
import { User } from "@notesnook/core/dist/api/user-manager";
|
import { User } from "@notesnook/core";
|
||||||
|
|
||||||
type EncryptedKey = { iv: Uint8Array; cipher: BufferSource };
|
type EncryptedKey = { iv: Uint8Array; cipher: BufferSource };
|
||||||
export type DatabasePersistence = "memory" | "db";
|
export type DatabasePersistence = "memory" | "db";
|
||||||
|
|||||||
@@ -316,8 +316,9 @@ class AppStore extends BaseStore<AppStore> {
|
|||||||
|
|
||||||
logger.error(err);
|
logger.error(err);
|
||||||
if (err.cause === "MERGE_CONFLICT") {
|
if (err.cause === "MERGE_CONFLICT") {
|
||||||
const sessionId = editorstore.get().session.id;
|
// TODO: reopen conflicted note
|
||||||
if (sessionId) await editorstore.openSession(sessionId, true);
|
// const sessionId = editorstore.get().session.id;
|
||||||
|
// if (sessionId) await editorstore.openSession(sessionId, true);
|
||||||
await this.refresh();
|
await this.refresh();
|
||||||
this.updateSyncStatus("conflicts");
|
this.updateSyncStatus("conflicts");
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -121,14 +121,14 @@ class AttachmentStore extends BaseStore<AttachmentStore> {
|
|||||||
if (await db.attachments.remove(attachment.hash, false)) {
|
if (await db.attachments.remove(attachment.hash, false)) {
|
||||||
await this.get().refresh();
|
await this.get().refresh();
|
||||||
|
|
||||||
const sessionId = useEditorStore.getState().session.id;
|
const session = useEditorStore.getState().getActiveSession(); //.id;
|
||||||
if (
|
if (
|
||||||
sessionId &&
|
session &&
|
||||||
(await db.relations
|
(await db.relations
|
||||||
.to({ id: attachment.id, type: "attachment" }, "note")
|
.to({ id: attachment.id, type: "attachment" }, "note")
|
||||||
.has(sessionId))
|
.has(session.id))
|
||||||
) {
|
) {
|
||||||
await useEditorStore.getState().clearSession();
|
useEditorStore.getState().closeSessions(session.id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
|
|||||||
@@ -71,8 +71,10 @@ class NoteStore extends BaseStore<NoteStore> {
|
|||||||
};
|
};
|
||||||
|
|
||||||
delete = async (...ids: string[]) => {
|
delete = async (...ids: string[]) => {
|
||||||
const { session, clearSession } = useEditorStore.getState();
|
const { closeSessions, getActiveSession } = useEditorStore.getState();
|
||||||
if (session.id && ids.indexOf(session.id) > -1) await clearSession();
|
const session = getActiveSession();
|
||||||
|
if (session && session.id && ids.indexOf(session.id) > -1)
|
||||||
|
closeSessions(session.id);
|
||||||
await db.notes.moveToTrash(...ids);
|
await db.notes.moveToTrash(...ids);
|
||||||
await this.refresh();
|
await this.refresh();
|
||||||
};
|
};
|
||||||
@@ -91,7 +93,7 @@ class NoteStore extends BaseStore<NoteStore> {
|
|||||||
|
|
||||||
unlock = async (id: string) => {
|
unlock = async (id: string) => {
|
||||||
return await Vault.unlockNote(id).then(async (res) => {
|
return await Vault.unlockNote(id).then(async (res) => {
|
||||||
if (useEditorStore.getState().session.id === id)
|
if (useEditorStore.getState().getActiveSession()?.id === id)
|
||||||
await useEditorStore.getState().openSession(id);
|
await useEditorStore.getState().openSession(id);
|
||||||
await this.refresh();
|
await this.refresh();
|
||||||
return res;
|
return res;
|
||||||
@@ -101,7 +103,7 @@ class NoteStore extends BaseStore<NoteStore> {
|
|||||||
lock = async (id: string) => {
|
lock = async (id: string) => {
|
||||||
if (!(await Vault.lockNote(id))) return false;
|
if (!(await Vault.lockNote(id))) return false;
|
||||||
await this.refresh();
|
await this.refresh();
|
||||||
if (useEditorStore.getState().session.id === id)
|
if (useEditorStore.getState().getActiveSession()?.id === id)
|
||||||
await useEditorStore.getState().openSession(id, true);
|
await useEditorStore.getState().openSession(id, true);
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -142,8 +144,9 @@ class NoteStore extends BaseStore<NoteStore> {
|
|||||||
action: "favorite" | "pinned" | "readonly" | "localOnly" | "color",
|
action: "favorite" | "pinned" | "readonly" | "localOnly" | "color",
|
||||||
value: boolean | string
|
value: boolean | string
|
||||||
) => {
|
) => {
|
||||||
const { session, toggle } = useEditorStore.getState();
|
const { getActiveSession, toggle } = useEditorStore.getState();
|
||||||
if (!session.id || !noteIds.includes(session.id)) return false;
|
const session = getActiveSession();
|
||||||
|
if (!session || !session.id || !noteIds.includes(session.id)) return false;
|
||||||
toggle(session.id, action, value);
|
toggle(session.id, action, value);
|
||||||
return true;
|
return true;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -181,7 +181,9 @@ class SettingStore extends BaseStore<SettingStore> {
|
|||||||
this.set({ hideNoteTitle: !hideNoteTitle });
|
this.set({ hideNoteTitle: !hideNoteTitle });
|
||||||
Config.set("hideNoteTitle", !hideNoteTitle);
|
Config.set("hideNoteTitle", !hideNoteTitle);
|
||||||
setDocumentTitle(
|
setDocumentTitle(
|
||||||
!hideNoteTitle ? undefined : useEditorStore.getState().session.title
|
!hideNoteTitle
|
||||||
|
? undefined
|
||||||
|
: useEditorStore.getState().getActiveSession()?.title
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -43,7 +43,7 @@ import {
|
|||||||
showLogoutConfirmation
|
showLogoutConfirmation
|
||||||
} from "../common/dialog-controller";
|
} from "../common/dialog-controller";
|
||||||
import { ErrorText } from "../components/error-text";
|
import { ErrorText } from "../components/error-text";
|
||||||
import { AuthenticatorType, User } from "@notesnook/core/dist/api/user-manager";
|
import { AuthenticatorType, User } from "@notesnook/core";
|
||||||
|
|
||||||
type EmailFormData = {
|
type EmailFormData = {
|
||||||
email: string;
|
email: string;
|
||||||
|
|||||||
@@ -31,7 +31,7 @@ import { showRecoveryKeyDialog } from "../common/dialog-controller";
|
|||||||
import Config from "../utils/config";
|
import Config from "../utils/config";
|
||||||
import { EVENTS } from "@notesnook/core/dist/common";
|
import { EVENTS } from "@notesnook/core/dist/common";
|
||||||
import { ErrorText } from "../components/error-text";
|
import { ErrorText } from "../components/error-text";
|
||||||
import { User } from "@notesnook/core/dist/api/user-manager";
|
import { User } from "@notesnook/core";
|
||||||
|
|
||||||
type RecoveryMethodType = "key" | "backup" | "reset";
|
type RecoveryMethodType = "key" | "backup" | "reset";
|
||||||
type RecoveryMethodsFormData = Record<string, unknown>;
|
type RecoveryMethodsFormData = Record<string, unknown>;
|
||||||
|
|||||||
Reference in New Issue
Block a user