From dc105799507e58a7eee479336a250f6b2c5d4811 Mon Sep 17 00:00:00 2001 From: Insert5StarName Date: Fri, 22 Sep 2023 22:33:18 +0200 Subject: [PATCH] upd: add support in frontend --- packages/frontend/src/components/MkNote.vue | 2 ++ .../src/components/MkNoteDetailed.vue | 1 + .../frontend/src/components/MkNoteHeader.vue | 1 + .../frontend/src/components/MkPostForm.vue | 6 ++++-- .../src/components/MkPostFormDialog.vue | 1 + .../frontend/src/scripts/get-note-menu.ts | 21 ++++++++++++++++++- packages/misskey-js/src/api.types.ts | 18 ++++++++++++++++ 7 files changed, 47 insertions(+), 3 deletions(-) diff --git a/packages/frontend/src/components/MkNote.vue b/packages/frontend/src/components/MkNote.vue index 0bc94f5bd..5edd175f7 100644 --- a/packages/frontend/src/components/MkNote.vue +++ b/packages/frontend/src/components/MkNote.vue @@ -39,6 +39,8 @@ SPDX-License-Identifier: AGPL-3.0-only + +
diff --git a/packages/frontend/src/components/MkNoteDetailed.vue b/packages/frontend/src/components/MkNoteDetailed.vue index e8e52e00a..56322ef08 100644 --- a/packages/frontend/src/components/MkNoteDetailed.vue +++ b/packages/frontend/src/components/MkNoteDetailed.vue @@ -58,6 +58,7 @@ SPDX-License-Identifier: AGPL-3.0-only +
diff --git a/packages/frontend/src/components/MkNoteHeader.vue b/packages/frontend/src/components/MkNoteHeader.vue index dda7238d2..a54f1e0c3 100644 --- a/packages/frontend/src/components/MkNoteHeader.vue +++ b/packages/frontend/src/components/MkNoteHeader.vue @@ -22,6 +22,7 @@ SPDX-License-Identifier: AGPL-3.0-only + diff --git a/packages/frontend/src/components/MkPostForm.vue b/packages/frontend/src/components/MkPostForm.vue index 2b4dcc8ed..9a7327eaf 100644 --- a/packages/frontend/src/components/MkPostForm.vue +++ b/packages/frontend/src/components/MkPostForm.vue @@ -143,6 +143,7 @@ const props = withDefaults(defineProps<{ fixed?: boolean; autofocus?: boolean; freezeAfterPosted?: boolean; + editId?: Misskey.entities.Note["id"]; }>(), { initialVisibleUsers: () => [], autofocus: true, @@ -709,6 +710,7 @@ async function post(ev?: MouseEvent) { visibility: visibility, visibleUserIds: visibility === 'specified' ? visibleUsers.map(u => u.id) : undefined, reactionAcceptance, + editId: props.editId ? props.editId : undefined, }; if (withHashtags && hashtags && hashtags.trim() !== '') { @@ -731,7 +733,7 @@ async function post(ev?: MouseEvent) { } posting = true; - os.api('notes/create', postData, token).then(() => { + os.api(postData.editId ? "notes/edit" : "notes/create", postData, token).then(() => { if (props.freezeAfterPosted) { posted = true; } else { @@ -755,7 +757,7 @@ async function post(ev?: MouseEvent) { const text = postData.text ?? ''; const lowerCase = text.toLowerCase(); - if ((lowerCase.includes('love') || lowerCase.includes('❤')) && lowerCase.includes('misskey')) { + if ((lowerCase.includes('love') || lowerCase.includes('❤')) && lowerCase.includes('sharkey')) { claimAchievement('iLoveMisskey'); } if ([ diff --git a/packages/frontend/src/components/MkPostFormDialog.vue b/packages/frontend/src/components/MkPostFormDialog.vue index c07a166a8..25a8788a3 100644 --- a/packages/frontend/src/components/MkPostFormDialog.vue +++ b/packages/frontend/src/components/MkPostFormDialog.vue @@ -30,6 +30,7 @@ const props = defineProps<{ instant?: boolean; fixed?: boolean; autofocus?: boolean; + editId?: Misskey.entities.Note["id"]; }>(); const emit = defineEmits<{ diff --git a/packages/frontend/src/scripts/get-note-menu.ts b/packages/frontend/src/scripts/get-note-menu.ts index 734a63203..4d3189b73 100644 --- a/packages/frontend/src/scripts/get-note-menu.ts +++ b/packages/frontend/src/scripts/get-note-menu.ts @@ -171,6 +171,18 @@ export function getNoteMenu(props: { } }); } + function edit(): void { + //os.api('notes/delete', { + // noteId: appearNote.id, + //}); + os.post({ + initialNote: appearNote, + renote: appearNote.renote, + reply: appearNote.reply, + channel: appearNote.channel, + editId: appearNote.id, + }); +} function toggleFavorite(favorite: boolean): void { claimAchievement('noteFavorited1'); @@ -353,10 +365,17 @@ export function getNoteMenu(props: { ...(appearNote.userId === $i.id || $i.isModerator || $i.isAdmin ? [ null, appearNote.userId === $i.id ? { + icon: 'ti ti-pencil', + text: i18n.ts.edit, + danger: true, + action: edit, + }: undefined, + { icon: 'ti ti-edit', text: i18n.ts.deleteAndEdit, + danger: true, action: delEdit, - } : undefined, + }, { icon: 'ti ti-trash', text: i18n.ts.delete, diff --git a/packages/misskey-js/src/api.types.ts b/packages/misskey-js/src/api.types.ts index 46d790fe3..3275f0c8e 100644 --- a/packages/misskey-js/src/api.types.ts +++ b/packages/misskey-js/src/api.types.ts @@ -508,6 +508,24 @@ export type Endpoints = { }; }; res: { createdNote: Note }; }; 'notes/delete': { req: { noteId: Note['id']; }; res: null; }; + 'notes/edit': { req: { + visibility?: 'public' | 'home' | 'followers' | 'specified', + visibleUserIds?: User['id'][]; + text?: null | string; + cw?: null | string; + viaMobile?: boolean; + localOnly?: boolean; + fileIds?: DriveFile['id'][]; + replyId?: null | Note['id']; + renoteId?: null | Note['id']; + channelId?: null | Channel['id']; + poll?: null | { + choices: string[]; + multiple?: boolean; + expiresAt?: null | number; + expiredAfter?: null | number; + }; + }; res: { createdNote: Note }; }; 'notes/favorites/create': { req: { noteId: Note['id']; }; res: null; }; 'notes/favorites/delete': { req: { noteId: Note['id']; }; res: null; }; 'notes/featured': { req: TODO; res: Note[]; };