From ceda2ca89661d1bd3889453997fe0868a8c31e9d Mon Sep 17 00:00:00 2001 From: syuilo Date: Mon, 28 May 2018 14:39:46 +0900 Subject: [PATCH] Implement delete note --- locales/ja.yml | 24 ++++++---- .../app/common/views/components/note-menu.vue | 10 +++++ .../views/components/note-detail.sub.vue | 1 + .../desktop/views/components/note-detail.vue | 1 + .../desktop/views/components/notes.note.vue | 3 +- .../views/components/sub-note-content.vue | 5 ++- .../mobile/views/components/note-detail.vue | 3 +- .../app/mobile/views/components/note.vue | 3 +- .../views/components/sub-note-content.vue | 5 ++- src/remote/activitypub/kernel/delete/note.ts | 10 +---- src/remote/activitypub/renderer/delete.ts | 4 ++ src/renderers/get-note-summary.ts | 4 ++ src/server/api/endpoints.ts | 5 +++ src/server/api/endpoints/notes/delete.ts | 26 +++++++++++ src/services/note/delete.ts | 44 +++++++++++++++++++ 15 files changed, 125 insertions(+), 23 deletions(-) create mode 100644 src/remote/activitypub/renderer/delete.ts create mode 100644 src/server/api/endpoints/notes/delete.ts create mode 100644 src/services/note/delete.ts diff --git a/locales/ja.yml b/locales/ja.yml index 06ef453de8..d8bc94b293 100644 --- a/locales/ja.yml +++ b/locales/ja.yml @@ -126,6 +126,8 @@ common/views/components/nav.vue: common/views/components/note-menu.vue: favorite: "お気に入り" pin: "ピン留め" + delete: "削除" + delete-confirm: "この投稿を削除しますか?" remote: "投稿元で見る" common/views/components/poll.vue: @@ -360,14 +362,16 @@ desktop/views/components/messaging-window.vue: desktop/views/components/note-detail.vue: more: "会話をもっと読み込む" - private: "(この投稿は非公開です)" + private: "この投稿は非公開です" + deleted: "この投稿は削除されました" reposted-by: "{}がRenote" location: "位置情報" renote: "Renote" add-reaction: "リアクション" desktop/views/components/note-detail.sub.vue: - private: "(この投稿は非公開です)" + private: "この投稿は非公開です" + deleted: "この投稿は削除されました" desktop/views/components/notes.note.vue: reposted-by: "{}がRenote" @@ -565,8 +569,9 @@ desktop/views/components/settings.profile.vue: is-cat: "このアカウントはCatです" desktop/views/components/sub-note-content.vue: - hidden: "(この投稿は非公開です)" - media: "つのメディア" + private: "この投稿は非公開です" + deleted: "この投稿は削除されました" + media-count: "{}つのメディア" poll: "投票" desktop/views/components/taskmanager.vue: @@ -771,14 +776,16 @@ mobile/views/components/note.vue: reposted-by: "{}がRenote" more: "もっと見る" less: "隠す" - hidden: "この投稿は非公開です" + private: "この投稿は非公開です" + deleted: "この投稿は削除されました" location: "位置情報" mobile/views/components/note-detail.vue: reply: "返信" reaction: "リアクション" reposted-by: "{}がRenote" - hidden: "この投稿は非公開です" + private: "この投稿は非公開です" + deleted: "この投稿は削除されました" location: "位置情報" mobile/views/components/note-preview.vue: @@ -813,8 +820,9 @@ mobile/views/components/post-form.vue: username-prompt: "ユーザー名を入力してください" mobile/views/components/sub-note-content.vue: - hidden: "この投稿は非公開です" - media-count: "{}個のメディア" + private: "この投稿は非公開です" + deleted: "この投稿は削除されました" + media-count: "{}つのメディア" poll: "投票" mobile/views/components/timeline.vue: diff --git a/src/client/app/common/views/components/note-menu.vue b/src/client/app/common/views/components/note-menu.vue index fb95055049..a400610a2b 100644 --- a/src/client/app/common/views/components/note-menu.vue +++ b/src/client/app/common/views/components/note-menu.vue @@ -4,6 +4,7 @@
+ %i18n:@remote%
@@ -59,6 +60,15 @@ export default Vue.extend({ }); }, + del() { + if (!window.confirm('%i18n:@delete-confirm%')) return; + (this as any).api('notes/delete', { + noteId: this.note.id + }).then(() => { + this.$destroy(); + }); + }, + favorite() { (this as any).api('notes/favorites/create', { noteId: this.note.id diff --git a/src/client/app/desktop/views/components/note-detail.sub.vue b/src/client/app/desktop/views/components/note-detail.sub.vue index 0471c70ee7..00e54ff1a6 100644 --- a/src/client/app/desktop/views/components/note-detail.sub.vue +++ b/src/client/app/desktop/views/components/note-detail.sub.vue @@ -16,6 +16,7 @@
%i18n:@private% + %i18n:@deleted%
diff --git a/src/client/app/desktop/views/components/note-detail.vue b/src/client/app/desktop/views/components/note-detail.vue index e64990b4ce..63b2150110 100644 --- a/src/client/app/desktop/views/components/note-detail.vue +++ b/src/client/app/desktop/views/components/note-detail.vue @@ -39,6 +39,7 @@
%i18n:@private% + %i18n:@deleted%
diff --git a/src/client/app/desktop/views/components/notes.note.vue b/src/client/app/desktop/views/components/notes.note.vue index c4ad67c2f8..f293ffacfb 100644 --- a/src/client/app/desktop/views/components/notes.note.vue +++ b/src/client/app/desktop/views/components/notes.note.vue @@ -41,7 +41,8 @@

- (この投稿は非公開です) + %i18n:@private% + %i18n:@deleted% %fa:reply% RP: diff --git a/src/client/app/desktop/views/components/sub-note-content.vue b/src/client/app/desktop/views/components/sub-note-content.vue index 8aa32cec73..46e1b802b9 100644 --- a/src/client/app/desktop/views/components/sub-note-content.vue +++ b/src/client/app/desktop/views/components/sub-note-content.vue @@ -1,13 +1,14 @@