From df54b3db976b9249f0b20025f9393b37e85a4e46 Mon Sep 17 00:00:00 2001 From: Insert5StarName <anime@shourai.de> Date: Thu, 5 Oct 2023 05:44:28 +0200 Subject: [PATCH] test --- .../backend/migration/1696332072038-clean.js | 17 +------ packages/frontend/src/components/MkNote.vue | 43 +++++++++++++++--- .../src/components/MkNoteDetailed.vue | 44 ++++++++++++++++--- 3 files changed, 77 insertions(+), 27 deletions(-) diff --git a/packages/backend/migration/1696332072038-clean.js b/packages/backend/migration/1696332072038-clean.js index 97dba655f4..2eecf70cff 100644 --- a/packages/backend/migration/1696332072038-clean.js +++ b/packages/backend/migration/1696332072038-clean.js @@ -2,32 +2,17 @@ export class Clean1696332072038 { name = 'Clean1696332072038' async up(queryRunner) { - await queryRunner.query(`ALTER TABLE "user_list_membership" DROP CONSTRAINT "FK_d844bfc6f3f523a05189076efaa"`); - await queryRunner.query(`ALTER TABLE "user_list_membership" DROP CONSTRAINT "FK_605472305f26818cc93d1baaa74"`); + await queryRunner.query(`DROP INDEX "public"."IDX_d844bfc6f3f523a05189076efa"`); await queryRunner.query(`DROP INDEX "public"."IDX_605472305f26818cc93d1baaa7"`); await queryRunner.query(`DROP INDEX "public"."IDX_90f7da835e4c10aca6853621e1"`); await queryRunner.query(`ALTER TABLE "meta" ALTER COLUMN "preservedUsernames" SET DEFAULT '{ "admin", "administrator", "root", "system", "maintainer", "host", "mod", "moderator", "owner", "superuser", "staff", "auth", "i", "me", "everyone", "all", "mention", "mentions", "example", "user", "users", "account", "accounts", "official", "help", "helps", "support", "supports", "info", "information", "informations", "announce", "announces", "announcement", "announcements", "notice", "notification", "notifications", "dev", "developer", "developers", "tech", "misskey" }'`); - await queryRunner.query(`COMMENT ON COLUMN "user_list_membership"."createdAt" IS 'The created date of the UserListMembership.'`); - await queryRunner.query(`CREATE INDEX "IDX_021015e6683570ae9f6b0c62be" ON "user_list_membership" ("userId") `); - await queryRunner.query(`CREATE INDEX "IDX_cddcaf418dc4d392ecfcca842a" ON "user_list_membership" ("userListId") `); - await queryRunner.query(`CREATE UNIQUE INDEX "IDX_e4f3094c43f2d665e6030b0337" ON "user_list_membership" ("userId", "userListId") `); - await queryRunner.query(`ALTER TABLE "user_list_membership" ADD CONSTRAINT "FK_021015e6683570ae9f6b0c62bee" FOREIGN KEY ("userId") REFERENCES "user"("id") ON DELETE CASCADE ON UPDATE NO ACTION`); - await queryRunner.query(`ALTER TABLE "user_list_membership" ADD CONSTRAINT "FK_cddcaf418dc4d392ecfcca842a7" FOREIGN KEY ("userListId") REFERENCES "user_list"("id") ON DELETE CASCADE ON UPDATE NO ACTION`); } async down(queryRunner) { - await queryRunner.query(`ALTER TABLE "user_list_membership" DROP CONSTRAINT "FK_cddcaf418dc4d392ecfcca842a7"`); - await queryRunner.query(`ALTER TABLE "user_list_membership" DROP CONSTRAINT "FK_021015e6683570ae9f6b0c62bee"`); await queryRunner.query(`DROP INDEX "public"."IDX_e4f3094c43f2d665e6030b0337"`); await queryRunner.query(`DROP INDEX "public"."IDX_cddcaf418dc4d392ecfcca842a"`); await queryRunner.query(`DROP INDEX "public"."IDX_021015e6683570ae9f6b0c62be"`); - await queryRunner.query(`COMMENT ON COLUMN "user_list_membership"."createdAt" IS 'The created date of the UserListJoining.'`); await queryRunner.query(`ALTER TABLE "meta" ALTER COLUMN "preservedUsernames" SET DEFAULT '{admin,administrator,root,system,maintainer,host,mod,moderator,owner,superuser,staff,auth,i,me,everyone,all,mention,mentions,example,user,users,account,accounts,official,help,helps,support,supports,info,information,informations,announce,announces,announcement,announcements,notice,notification,notifications,dev,developer,developers,tech,misskey}'`); - await queryRunner.query(`CREATE UNIQUE INDEX "IDX_90f7da835e4c10aca6853621e1" ON "user_list_membership" ("userId", "userListId") `); - await queryRunner.query(`CREATE INDEX "IDX_605472305f26818cc93d1baaa7" ON "user_list_membership" ("userListId") `); - await queryRunner.query(`CREATE INDEX "IDX_d844bfc6f3f523a05189076efa" ON "user_list_membership" ("userId") `); - await queryRunner.query(`ALTER TABLE "user_list_membership" ADD CONSTRAINT "FK_605472305f26818cc93d1baaa74" FOREIGN KEY ("userListId") REFERENCES "user_list"("id") ON DELETE CASCADE ON UPDATE NO ACTION`); - await queryRunner.query(`ALTER TABLE "user_list_membership" ADD CONSTRAINT "FK_d844bfc6f3f523a05189076efaa" FOREIGN KEY ("userId") REFERENCES "user"("id") ON DELETE CASCADE ON UPDATE NO ACTION`); } } diff --git a/packages/frontend/src/components/MkNote.vue b/packages/frontend/src/components/MkNote.vue index 5999854399..b723848f77 100644 --- a/packages/frontend/src/components/MkNote.vue +++ b/packages/frontend/src/components/MkNote.vue @@ -98,16 +98,25 @@ SPDX-License-Identifier: AGPL-3.0-only <button v-if="canRenote" ref="renoteButton" - :class="$style.footerButton" + v-tooltip.noDelay.bottom="i18n.ts.renote" class="_button" + :class="$style.footerButton" + v-bind:style="hasRenotedBefore ? 'color: var(--accent) !important;' : ''" @mousedown="renote()" > - <i class="ph-repeat ph-bold ph-lg"></i> + <i class="ph-rocket-launch ph-bold ph-lg"></i> <p v-if="appearNote.renoteCount > 0" :class="$style.footerButtonCount">{{ appearNote.renoteCount }}</p> </button> - <button v-else :class="$style.footerButton" class="_button" disabled> - <i class="ph-prohibit ph-bold ph-lg"></i> + <button + v-else + v-tooltip.noDelay.bottom="i18n.ts.disabled" + class="_button" + :class="$style.footerButton" + disabled="true" + > + <i class="ph-rocket-launch ph-bold ph-lg"></i> </button> + <button v-if="appearNote.myReaction == null && appearNote.reactionAcceptance !== 'likeOnly'" ref="likeButton" :class="$style.footerButton" class="_button" v-on:click.stop @click="like()"> <i class="ph-heart ph-bold ph-lg"></i> </button> @@ -268,6 +277,17 @@ useTooltip(renoteButton, async (showing) => { }, {}, 'closed'); }); +const hasRenotedBefore = ref(false); +if ($i){ + os.api("notes/renotes", { + noteId: props.note.id, + userId: $i.id, + limit: 1, + }).then((res) => { + hasRenotedBefore.value = res.length > 0; + }); +} + type Visibility = 'public' | 'home' | 'followers' | 'specified'; // defaultStore.state.visibilityãŒstringãªãŸã‚stringã‚‚å—ã‘付ã‘ã¦ã„ã‚‹ @@ -345,6 +365,7 @@ function renote(viaKeyboard = false) { }).then(() => { os.toast(i18n.ts.renoted); }); + hasRenotedBefore.value = true; }, }, { text: i18n.ts.quote, @@ -355,7 +376,19 @@ function renote(viaKeyboard = false) { }); }, }]); - + if (hasRenotedBefore.value) { + items.push({ + text: i18n.ts.unrenote, + icon: "ph-trash ph-bold ph-lg", + danger: true, + action: () => { + os.api("notes/unrenote", { + noteId: props.note.id, + }); + hasRenotedBefore.value = false; + }, + }); + } os.popupMenu(items, renoteButton.value, { viaKeyboard, }); diff --git a/packages/frontend/src/components/MkNoteDetailed.vue b/packages/frontend/src/components/MkNoteDetailed.vue index 2d9566bce3..b56777555d 100644 --- a/packages/frontend/src/components/MkNoteDetailed.vue +++ b/packages/frontend/src/components/MkNoteDetailed.vue @@ -2,7 +2,6 @@ SPDX-FileCopyrightText: syuilo and other misskey contributors SPDX-License-Identifier: AGPL-3.0-only --> - <template> <div v-if="!muted" @@ -109,16 +108,25 @@ SPDX-License-Identifier: AGPL-3.0-only <button v-if="canRenote" ref="renoteButton" + v-tooltip.noDelay.bottom="i18n.ts.renote" class="_button" :class="$style.noteFooterButton" + v-bind:style="hasRenotedBefore ? 'color: var(--accent) !important;' : ''" @mousedown="renote()" > - <i class="ph-repeat ph-bold ph-lg"></i> + <i class="ph-rocket-launch ph-bold ph-lg"></i> <p v-if="appearNote.renoteCount > 0" :class="$style.noteFooterButtonCount">{{ appearNote.renoteCount }}</p> </button> - <button v-else class="_button" :class="$style.noteFooterButton" disabled> - <i class="ph-prohibit ph-bold ph-lg"></i> + <button + v-else + v-tooltip.noDelay.bottom="i18n.ts.disabled" + class="_button" + :class="$style.noteFooterButton" + disabled="true" + > + <i class="ph-rocket-launch ph-bold ph-lg"></i> </button> + <button v-if="appearNote.myReaction == null && appearNote.reactionAcceptance !== 'likeOnly'" ref="likeButton" :class="$style.noteFooterButton" class="_button" @mousedown="like()"> <i class="ph-heart ph-bold ph-lg"></i> </button> @@ -328,6 +336,18 @@ useTooltip(renoteButton, async (showing) => { }, {}, 'closed'); }); +const hasRenotedBefore = ref(false); +if ($i){ + os.api("notes/renotes", { + noteId: props.note.id, + userId: $i.id, + limit: 1, + }).then((res) => { + hasRenotedBefore.value = res.length > 0; + }); +} + + function renote(viaKeyboard = false) { pleaseLogin(); showMovedDialog(); @@ -365,7 +385,6 @@ function renote(viaKeyboard = false) { }, }, null]); } - items = items.concat([{ text: i18n.ts.renote, icon: 'ph-repeat ph-bold ph-lg', @@ -383,6 +402,7 @@ function renote(viaKeyboard = false) { }).then(() => { os.toast(i18n.ts.renoted); }); + hasRenotedBefore.value = true; }, }, { text: i18n.ts.quote, @@ -393,7 +413,19 @@ function renote(viaKeyboard = false) { }); }, }]); - + if (hasRenotedBefore.value) { + items.push({ + text: i18n.ts.unrenote, + icon: "ph-trash ph-bold ph-lg", + danger: true, + action: () => { + os.api("notes/unrenote", { + noteId: props.note.id, + }); + hasRenotedBefore.value = false; + }, + }); + } os.popupMenu(items, renoteButton.value, { viaKeyboard, }); -- GitLab