This commit is contained in:
Insert5StarName 2023-10-05 05:44:28 +02:00
parent 6dd0b88050
commit df54b3db97
3 changed files with 77 additions and 27 deletions

View file

@ -2,32 +2,17 @@ export class Clean1696332072038 {
name = 'Clean1696332072038' name = 'Clean1696332072038'
async up(queryRunner) { 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_d844bfc6f3f523a05189076efa"`);
await queryRunner.query(`DROP INDEX "public"."IDX_605472305f26818cc93d1baaa7"`); await queryRunner.query(`DROP INDEX "public"."IDX_605472305f26818cc93d1baaa7"`);
await queryRunner.query(`DROP INDEX "public"."IDX_90f7da835e4c10aca6853621e1"`); 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(`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) { 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_e4f3094c43f2d665e6030b0337"`);
await queryRunner.query(`DROP INDEX "public"."IDX_cddcaf418dc4d392ecfcca842a"`); await queryRunner.query(`DROP INDEX "public"."IDX_cddcaf418dc4d392ecfcca842a"`);
await queryRunner.query(`DROP INDEX "public"."IDX_021015e6683570ae9f6b0c62be"`); 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(`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`);
} }
} }

View file

@ -98,16 +98,25 @@ SPDX-License-Identifier: AGPL-3.0-only
<button <button
v-if="canRenote" v-if="canRenote"
ref="renoteButton" ref="renoteButton"
:class="$style.footerButton" v-tooltip.noDelay.bottom="i18n.ts.renote"
class="_button" class="_button"
:class="$style.footerButton"
v-bind:style="hasRenotedBefore ? 'color: var(--accent) !important;' : ''"
@mousedown="renote()" @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> <p v-if="appearNote.renoteCount > 0" :class="$style.footerButtonCount">{{ appearNote.renoteCount }}</p>
</button> </button>
<button v-else :class="$style.footerButton" class="_button" disabled> <button
<i class="ph-prohibit ph-bold ph-lg"></i> 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>
<button v-if="appearNote.myReaction == null && appearNote.reactionAcceptance !== 'likeOnly'" ref="likeButton" :class="$style.footerButton" class="_button" v-on:click.stop @click="like()"> <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> <i class="ph-heart ph-bold ph-lg"></i>
</button> </button>
@ -268,6 +277,17 @@ useTooltip(renoteButton, async (showing) => {
}, {}, 'closed'); }, {}, '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'; type Visibility = 'public' | 'home' | 'followers' | 'specified';
// defaultStore.state.visibilitystringstring // defaultStore.state.visibilitystringstring
@ -345,6 +365,7 @@ function renote(viaKeyboard = false) {
}).then(() => { }).then(() => {
os.toast(i18n.ts.renoted); os.toast(i18n.ts.renoted);
}); });
hasRenotedBefore.value = true;
}, },
}, { }, {
text: i18n.ts.quote, 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, { os.popupMenu(items, renoteButton.value, {
viaKeyboard, viaKeyboard,
}); });

View file

@ -2,7 +2,6 @@
SPDX-FileCopyrightText: syuilo and other misskey contributors SPDX-FileCopyrightText: syuilo and other misskey contributors
SPDX-License-Identifier: AGPL-3.0-only SPDX-License-Identifier: AGPL-3.0-only
--> -->
<template> <template>
<div <div
v-if="!muted" v-if="!muted"
@ -109,16 +108,25 @@ SPDX-License-Identifier: AGPL-3.0-only
<button <button
v-if="canRenote" v-if="canRenote"
ref="renoteButton" ref="renoteButton"
v-tooltip.noDelay.bottom="i18n.ts.renote"
class="_button" class="_button"
:class="$style.noteFooterButton" :class="$style.noteFooterButton"
v-bind:style="hasRenotedBefore ? 'color: var(--accent) !important;' : ''"
@mousedown="renote()" @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> <p v-if="appearNote.renoteCount > 0" :class="$style.noteFooterButtonCount">{{ appearNote.renoteCount }}</p>
</button> </button>
<button v-else class="_button" :class="$style.noteFooterButton" disabled> <button
<i class="ph-prohibit ph-bold ph-lg"></i> 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>
<button v-if="appearNote.myReaction == null && appearNote.reactionAcceptance !== 'likeOnly'" ref="likeButton" :class="$style.noteFooterButton" class="_button" @mousedown="like()"> <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> <i class="ph-heart ph-bold ph-lg"></i>
</button> </button>
@ -328,6 +336,18 @@ useTooltip(renoteButton, async (showing) => {
}, {}, 'closed'); }, {}, '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) { function renote(viaKeyboard = false) {
pleaseLogin(); pleaseLogin();
showMovedDialog(); showMovedDialog();
@ -365,7 +385,6 @@ function renote(viaKeyboard = false) {
}, },
}, null]); }, null]);
} }
items = items.concat([{ items = items.concat([{
text: i18n.ts.renote, text: i18n.ts.renote,
icon: 'ph-repeat ph-bold ph-lg', icon: 'ph-repeat ph-bold ph-lg',
@ -383,6 +402,7 @@ function renote(viaKeyboard = false) {
}).then(() => { }).then(() => {
os.toast(i18n.ts.renoted); os.toast(i18n.ts.renoted);
}); });
hasRenotedBefore.value = true;
}, },
}, { }, {
text: i18n.ts.quote, 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, { os.popupMenu(items, renoteButton.value, {
viaKeyboard, viaKeyboard,
}); });