Skip to content

armgit / memos

Public Imported from GitHub
0

Memos is an open-source, self-hosted note-taking app that brings your everyday thoughts together in a personal timeline. Your data stays yours, and you choose what to keep private or share.

chore: update type definitions

Steven1d83c68cb52e
diff --git a/web/src/components/CreateResourceDialog.tsx b/web/src/components/CreateResourceDialog.tsx
index e3e92a872..5e540729f 100644
--- a/web/src/components/CreateResourceDialog.tsx
+++ b/web/src/components/CreateResourceDialog.tsx
@@ -1,7 +1,7 @@
import { Autocomplete, Button, IconButton, Input, List, ListItem, Option, Select, Typography } from "@mui/joy";
import React, { useRef, useState } from "react";
import { toast } from "react-hot-toast";
-import { Resource } from "@/types/proto/api/v2/resource_service";
+import { CreateResourceRequest, Resource } from "@/types/proto/api/v2/resource_service";
import { useTranslate } from "@/utils/i18n";
import { useResourceStore } from "../store/module";
import { generateDialog } from "./Dialog";
@@ -29,11 +29,13 @@ const CreateResourceDialog: React.FC<Props> = (props: Props) => {
selectedMode: "local-file",
uploadingFlag: false,
});
- const [resourceCreate, setResourceCreate] = useState<ResourceCreate>({
- filename: "",
- externalLink: "",
- type: "",
- });
+ const [resourceCreate, setResourceCreate] = useState<CreateResourceRequest>(
+ CreateResourceRequest.fromPartial({
+ filename: "",
+ externalLink: "",
+ type: "",
+ }),
+ );
const [fileList, setFileList] = useState<File[]>([]);
const fileInputRef = useRef<HTMLInputElement>(null);
diff --git a/web/src/components/TagList.tsx b/web/src/components/TagList.tsx
index 36ce22ae8..7f10c5b14 100644
--- a/web/src/components/TagList.tsx
+++ b/web/src/components/TagList.tsx
@@ -9,6 +9,10 @@ import { showCommonDialog } from "./Dialog/CommonDialog";
import Icon from "./Icon";
import showRenameTagDialog from "./RenameTagDialog";
+interface KVObject<T = any> {
+ [key: string]: T;
+}
+
interface Tag {
key: string;
text: string;
diff --git a/web/src/helpers/storage.ts b/web/src/helpers/storage.ts
index 90de64412..7807a06dd 100644
--- a/web/src/helpers/storage.ts
+++ b/web/src/helpers/storage.ts
@@ -6,8 +6,6 @@ interface StorageData {
locale: Locale;
// appearance
appearance: Appearance;
- // local setting
- localSetting: LocalSetting;
}
type StorageKey = keyof StorageData;
diff --git a/web/src/store/module/filter.ts b/web/src/store/module/filter.ts
index e07d3ab09..00f116fcb 100644
--- a/web/src/store/module/filter.ts
+++ b/web/src/store/module/filter.ts
@@ -1,3 +1,4 @@
+import { Visibility } from "@/types/proto/api/v2/memo_service";
import store, { useAppSelector } from "..";
import { setFilter } from "../reducer/filter";
diff --git a/web/src/store/reducer/filter.ts b/web/src/store/reducer/filter.ts
index af8c23238..287a1ddaf 100644
--- a/web/src/store/reducer/filter.ts
+++ b/web/src/store/reducer/filter.ts
@@ -1,4 +1,5 @@
import { createSlice, PayloadAction } from "@reduxjs/toolkit";
+import { Visibility } from "@/types/proto/api/v2/memo_service";
interface State {
tag?: string;
diff --git a/web/src/types/common.d.ts b/web/src/types/common.d.ts
index f1d2f1062..03ae447b7 100644
--- a/web/src/types/common.d.ts
+++ b/web/src/types/common.d.ts
@@ -1,9 +1 @@
-type BasicType = undefined | null | boolean | number | string | Record<string, unknown> | Array<BasicType>;
-
type FunctionType = (...args: unknown[]) => unknown;
-
-interface KVObject<T = any> {
- [key: string]: T;
-}
-
-type Option<T> = T | undefined;
diff --git a/web/src/types/modules/common.d.ts b/web/src/types/modules/common.d.ts
deleted file mode 100644
index 1d6373bc9..000000000
--- a/web/src/types/modules/common.d.ts
+++ /dev/null
@@ -1,3 +0,0 @@
-type RowStatus = "NORMAL" | "ARCHIVED";
-
-type Visibility = "PUBLIC" | "PROTECTED" | "PRIVATE";
diff --git a/web/src/types/modules/resource.d.ts b/web/src/types/modules/resource.d.ts
deleted file mode 100644
index 8b649d7e8..000000000
--- a/web/src/types/modules/resource.d.ts
+++ /dev/null
@@ -1,5 +0,0 @@
-interface ResourceCreate {
- filename: string;
- externalLink: string;
- type: string;
-}
diff --git a/web/src/types/modules/setting.d.ts b/web/src/types/modules/setting.d.ts
index 025424001..784b92c12 100644
--- a/web/src/types/modules/setting.d.ts
+++ b/web/src/types/modules/setting.d.ts
@@ -1,43 +1 @@
type Appearance = "system" | "light" | "dark";
-
-interface BasicSetting {
- locale: Locale;
- appearance: Appearance;
-}
-interface Setting {
- locale: Locale;
- appearance: Appearance;
- memoVisibility: Visibility;
- telegramUserId: string;
-}
-
-interface LocalSetting {
- enableDoubleClickEditing: boolean;
-}
-
-interface UserLocaleSetting {
- key: "locale";
- value: Locale;
-}
-
-interface UserAppearanceSetting {
- key: "appearance";
- value: Appearance;
-}
-
-interface UserMemoVisibilitySetting {
- key: "memo-visibility";
- value: Visibility;
-}
-
-interface UserTelegramUserIdSetting {
- key: "telegram-user-id";
- value: string;
-}
-
-type UserSetting = UserLocaleSetting | UserAppearanceSetting | UserMemoVisibilitySetting | UserTelegramUserIdSetting;
-
-interface UserSettingUpsert {
- key: keyof Setting;
- value: string;
-}
diff --git a/web/src/types/modules/user.d.ts b/web/src/types/modules/user.d.ts
index 48e855cd6..96ec55884 100644
--- a/web/src/types/modules/user.d.ts
+++ b/web/src/types/modules/user.d.ts
@@ -5,15 +5,10 @@ interface User {
createdTs: number;
updatedTs: number;
- rowStatus: RowStatus;
username: string;
role: UserRole;
email: string;
nickname: string;
avatarUrl: string;
- userSettingList: UserSetting[];
-
- setting: Setting;
- localSetting: LocalSetting;
}