upd: only allow one renote

This commit is contained in:
Mar0xy 2023-10-13 21:40:43 +02:00
parent 67f5caa61a
commit a37da15eaf
No known key found for this signature in database
GPG key ID: 56569BBE47D2C828

View file

@ -111,9 +111,10 @@ SPDX-License-Identifier: AGPL-3.0-only
ref="renoteButton"
class="_button"
:class="$style.noteFooterButton"
@mousedown="renote()"
:style="renoted ? 'color: var(--accent) !important;' : ''"
@mousedown="renoted ? undoRenote() : 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>
@ -266,6 +267,7 @@ const renoteUri = appearNote.renote ? appearNote.renote.uri : null;
const isMyRenote = $i && ($i.id === note.userId);
const showContent = ref(false);
const isDeleted = ref(false);
const renoted = ref(false);
const muted = ref($i ? checkWordMute(appearNote, $i, $i.mutedWords) : false);
const translation = ref(null);
const translating = ref(false);
@ -275,6 +277,16 @@ const conversation = ref<Misskey.entities.Note[]>([]);
const replies = ref<Misskey.entities.Note[]>([]);
const canRenote = computed(() => ['public', 'home'].includes(appearNote.visibility) || appearNote.userId === $i.id);
if ($i){
os.api("notes/renotes", {
noteId: appearNote.id,
userId: $i.id,
limit: 1,
}).then((res) => {
renoted.value = res.length > 0;
});
}
const keymap = {
'r': () => reply(true),
'e|a|plus': () => react(true),
@ -337,7 +349,7 @@ function renote(viaKeyboard = false) {
if (appearNote.channel) {
items = items.concat([{
text: i18n.ts.inChannelRenote,
icon: 'ph-repeat ph-bold ph-lg',
icon: 'ph-rocket-launcher ph-bold ph-lg',
action: () => {
const el = renoteButton.value as HTMLElement | null | undefined;
if (el) {
@ -352,6 +364,7 @@ function renote(viaKeyboard = false) {
channelId: appearNote.channelId,
}).then(() => {
os.toast(i18n.ts.renoted);
renoted.value = true;
});
},
}, {
@ -368,7 +381,7 @@ function renote(viaKeyboard = false) {
items = items.concat([{
text: i18n.ts.renote,
icon: 'ph-repeat ph-bold ph-lg',
icon: 'ph-rocket-launch ph-bold ph-lg',
action: () => {
const el = renoteButton.value as HTMLElement | null | undefined;
if (el) {
@ -382,6 +395,7 @@ function renote(viaKeyboard = false) {
renoteId: appearNote.id,
}).then(() => {
os.toast(i18n.ts.renoted);
renoted.value = true;
});
},
}, {
@ -466,6 +480,14 @@ function undoReact(note): void {
});
}
function undoRenote() : void {
if (!renoted) return;
os.api("notes/unrenote", {
noteId: appearNote.id,
});
renoted.value = false;
}
function onContextmenu(ev: MouseEvent): void {
const isLink = (el: HTMLElement) => {
if (el.tagName === 'A') return true;