mirror of
https://github.com/usememos/memos.git
synced 2025-06-05 22:09:59 +02:00
feat: support updating display time
This commit is contained in:
@ -9,7 +9,7 @@ import { isValidUrl } from "@/helpers/utils";
|
||||
import useCurrentUser from "@/hooks/useCurrentUser";
|
||||
import { useMemoStore, useResourceStore, useUserStore, useWorkspaceSettingStore } from "@/store/v1";
|
||||
import { MemoRelation, MemoRelation_Type } from "@/types/proto/api/v1/memo_relation_service";
|
||||
import { Visibility } from "@/types/proto/api/v1/memo_service";
|
||||
import { Memo, Visibility } from "@/types/proto/api/v1/memo_service";
|
||||
import { Resource } from "@/types/proto/api/v1/resource_service";
|
||||
import { UserSetting } from "@/types/proto/api/v1/user_service";
|
||||
import { WorkspaceMemoRelatedSetting } from "@/types/proto/api/v1/workspace_setting_service";
|
||||
@ -36,8 +36,8 @@ export interface Props {
|
||||
parentMemoName?: string;
|
||||
relationList?: MemoRelation[];
|
||||
autoFocus?: boolean;
|
||||
memoPatchRef?: React.MutableRefObject<Partial<Memo>>;
|
||||
onConfirm?: (memoName: string) => void;
|
||||
onEditPrevious?: () => void;
|
||||
}
|
||||
|
||||
interface State {
|
||||
@ -159,12 +159,6 @@ const MemoEditor = (props: Props) => {
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if (!!props.onEditPrevious && event.key === "ArrowDown" && !state.isComposing && editorRef.current.getContent() === "") {
|
||||
event.preventDefault();
|
||||
props.onEditPrevious();
|
||||
return;
|
||||
}
|
||||
};
|
||||
|
||||
const handleMemoVisibilityChange = (visibility: Visibility) => {
|
||||
@ -293,13 +287,18 @@ const MemoEditor = (props: Props) => {
|
||||
if (memoName) {
|
||||
const prevMemo = await memoStore.getOrFetchMemoByName(memoName);
|
||||
if (prevMemo) {
|
||||
const updateMask = ["content", "visibility"];
|
||||
if (props.memoPatchRef?.current?.displayTime) {
|
||||
updateMask.push("display_ts");
|
||||
}
|
||||
const memo = await memoStore.updateMemo(
|
||||
{
|
||||
name: prevMemo.name,
|
||||
content,
|
||||
visibility: state.memoVisibility,
|
||||
...props.memoPatchRef?.current,
|
||||
},
|
||||
["content", "visibility"],
|
||||
updateMask,
|
||||
);
|
||||
await memoServiceClient.setMemoResources({
|
||||
name: memo.name,
|
||||
|
Reference in New Issue
Block a user