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: fix timestamp type

Steven319f679e30fb
diff --git a/web/src/components/kit/DatePicker.tsx b/web/src/components/kit/DatePicker.tsx
index 89b027f2a..5e73526e3 100644
--- a/web/src/components/kit/DatePicker.tsx
+++ b/web/src/components/kit/DatePicker.tsx
@@ -12,14 +12,14 @@ import "@/less/common/date-picker.less";
interface DatePickerProps {
className?: string;
isFutureDateDisabled?: boolean;
- datestamp: DateStamp;
- handleDateStampChange: (datestamp: DateStamp) => void;
+ datestamp: number;
+ handleDateStampChange: (datestamp: number) => void;
}
const DatePicker: React.FC<DatePickerProps> = (props: DatePickerProps) => {
const t = useTranslate();
const { className, isFutureDateDisabled, datestamp, handleDateStampChange } = props;
- const [currentDateStamp, setCurrentDateStamp] = useState<DateStamp>(getMonthFirstDayDateStamp(datestamp));
+ const [currentDateStamp, setCurrentDateStamp] = useState<number>(getMonthFirstDayDateStamp(datestamp));
const [countByDate, setCountByDate] = useState(new Map());
const currentUsername = useUserStore().getCurrentUsername();
@@ -55,7 +55,7 @@ const DatePicker: React.FC<DatePickerProps> = (props: DatePickerProps) => {
});
}
- const handleDateItemClick = (datestamp: DateStamp) => {
+ const handleDateItemClick = (datestamp: number) => {
handleDateStampChange(datestamp);
};
@@ -122,7 +122,7 @@ const DatePicker: React.FC<DatePickerProps> = (props: DatePickerProps) => {
);
};
-function getMonthDayAmount(datestamp: DateStamp): number {
+function getMonthDayAmount(datestamp: number): number {
const dateTemp = new Date(datestamp);
const currentDate = new Date(`${dateTemp.getFullYear()}/${dateTemp.getMonth() + 1}/1`);
const nextMonthDate =
@@ -133,7 +133,7 @@ function getMonthDayAmount(datestamp: DateStamp): number {
return (nextMonthDate.getTime() - currentDate.getTime()) / DAILY_TIMESTAMP;
}
-function getMonthFirstDayDateStamp(timestamp: TimeStamp): DateStamp {
+function getMonthFirstDayDateStamp(timestamp: number): number {
const dateTemp = new Date(timestamp);
const currentDate = new Date(`${dateTemp.getFullYear()}/${dateTemp.getMonth() + 1}/1`);
return currentDate.getTime();
diff --git a/web/src/helpers/datetime.ts b/web/src/helpers/datetime.ts
index 84900f1fa..72683b084 100644
--- a/web/src/helpers/datetime.ts
+++ b/web/src/helpers/datetime.ts
@@ -5,7 +5,7 @@ export function convertToMillis(localSetting: LocalSetting) {
return hoursToMillis;
}
-export function getTimeStampByDate(t: Date | number | string): number {
+export function getTimeStampByDate(t: Date | number | string | any): number {
return new Date(t).getTime();
}
diff --git a/web/src/pages/DailyReview.tsx b/web/src/pages/DailyReview.tsx
index 17c0d46f7..3b39bda6a 100644
--- a/web/src/pages/DailyReview.tsx
+++ b/web/src/pages/DailyReview.tsx
@@ -83,7 +83,7 @@ const DailyReview = () => {
});
};
- const handleDataPickerChange = (datestamp: DateStamp): void => {
+ const handleDataPickerChange = (datestamp: number): void => {
setCurrentDateStamp(datestamp);
toggleShowDatePicker(false);
};
diff --git a/web/src/types/common.d.ts b/web/src/types/common.d.ts
index 91263426e..f1d2f1062 100644
--- a/web/src/types/common.d.ts
+++ b/web/src/types/common.d.ts
@@ -1,9 +1,5 @@
type BasicType = undefined | null | boolean | number | string | Record<string, unknown> | Array<BasicType>;
-type DateStamp = number;
-
-type TimeStamp = number;
-
type FunctionType = (...args: unknown[]) => unknown;
interface KVObject<T = any> {
diff --git a/web/src/types/modules/memo.d.ts b/web/src/types/modules/memo.d.ts
index f09f4ce40..47e684753 100644
--- a/web/src/types/modules/memo.d.ts
+++ b/web/src/types/modules/memo.d.ts
@@ -6,11 +6,11 @@ interface Memo {
id: MemoId;
creatorUsername: string;
- createdTs: TimeStamp;
- updatedTs: TimeStamp;
+ createdTs: number;
+ updatedTs: number;
rowStatus: RowStatus;
- displayTs: TimeStamp;
+ displayTs: number;
content: string;
visibility: Visibility;
pinned: boolean;
@@ -29,7 +29,7 @@ interface MemoCreate {
interface MemoPatch {
id: MemoId;
- createdTs?: TimeStamp;
+ createdTs?: number;
rowStatus?: RowStatus;
content?: string;
resourceIdList?: ResourceId[];
diff --git a/web/src/types/modules/resource.d.ts b/web/src/types/modules/resource.d.ts
index 0fd7618c2..275e98dc2 100644
--- a/web/src/types/modules/resource.d.ts
+++ b/web/src/types/modules/resource.d.ts
@@ -3,8 +3,8 @@ type ResourceId = number;
interface Resource {
id: ResourceId;
- createdTs: TimeStamp;
- updatedTs: TimeStamp;
+ createdTs: number;
+ updatedTs: number;
filename: string;
externalLink: string;
diff --git a/web/src/types/modules/user.d.ts b/web/src/types/modules/user.d.ts
index 8b2739583..b5358d1ed 100644
--- a/web/src/types/modules/user.d.ts
+++ b/web/src/types/modules/user.d.ts
@@ -4,8 +4,8 @@ type UserRole = "HOST" | "USER";
interface User {
id: UserId;
- createdTs: TimeStamp;
- updatedTs: TimeStamp;
+ createdTs: number;
+ updatedTs: number;
rowStatus: RowStatus;
username: string;