upd: only allow one renote
This commit is contained in:
parent
67f5caa61a
commit
a37da15eaf
1 changed files with 26 additions and 4 deletions
|
@ -111,9 +111,10 @@ SPDX-License-Identifier: AGPL-3.0-only
|
||||||
ref="renoteButton"
|
ref="renoteButton"
|
||||||
class="_button"
|
class="_button"
|
||||||
:class="$style.noteFooterButton"
|
: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>
|
<p v-if="appearNote.renoteCount > 0" :class="$style.noteFooterButtonCount">{{ appearNote.renoteCount }}</p>
|
||||||
</button>
|
</button>
|
||||||
<button v-else class="_button" :class="$style.noteFooterButton" disabled>
|
<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 isMyRenote = $i && ($i.id === note.userId);
|
||||||
const showContent = ref(false);
|
const showContent = ref(false);
|
||||||
const isDeleted = ref(false);
|
const isDeleted = ref(false);
|
||||||
|
const renoted = ref(false);
|
||||||
const muted = ref($i ? checkWordMute(appearNote, $i, $i.mutedWords) : false);
|
const muted = ref($i ? checkWordMute(appearNote, $i, $i.mutedWords) : false);
|
||||||
const translation = ref(null);
|
const translation = ref(null);
|
||||||
const translating = ref(false);
|
const translating = ref(false);
|
||||||
|
@ -275,6 +277,16 @@ const conversation = ref<Misskey.entities.Note[]>([]);
|
||||||
const replies = ref<Misskey.entities.Note[]>([]);
|
const replies = ref<Misskey.entities.Note[]>([]);
|
||||||
const canRenote = computed(() => ['public', 'home'].includes(appearNote.visibility) || appearNote.userId === $i.id);
|
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 = {
|
const keymap = {
|
||||||
'r': () => reply(true),
|
'r': () => reply(true),
|
||||||
'e|a|plus': () => react(true),
|
'e|a|plus': () => react(true),
|
||||||
|
@ -337,7 +349,7 @@ function renote(viaKeyboard = false) {
|
||||||
if (appearNote.channel) {
|
if (appearNote.channel) {
|
||||||
items = items.concat([{
|
items = items.concat([{
|
||||||
text: i18n.ts.inChannelRenote,
|
text: i18n.ts.inChannelRenote,
|
||||||
icon: 'ph-repeat ph-bold ph-lg',
|
icon: 'ph-rocket-launcher ph-bold ph-lg',
|
||||||
action: () => {
|
action: () => {
|
||||||
const el = renoteButton.value as HTMLElement | null | undefined;
|
const el = renoteButton.value as HTMLElement | null | undefined;
|
||||||
if (el) {
|
if (el) {
|
||||||
|
@ -352,6 +364,7 @@ function renote(viaKeyboard = false) {
|
||||||
channelId: appearNote.channelId,
|
channelId: appearNote.channelId,
|
||||||
}).then(() => {
|
}).then(() => {
|
||||||
os.toast(i18n.ts.renoted);
|
os.toast(i18n.ts.renoted);
|
||||||
|
renoted.value = true;
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
}, {
|
}, {
|
||||||
|
@ -368,7 +381,7 @@ function renote(viaKeyboard = false) {
|
||||||
|
|
||||||
items = items.concat([{
|
items = items.concat([{
|
||||||
text: i18n.ts.renote,
|
text: i18n.ts.renote,
|
||||||
icon: 'ph-repeat ph-bold ph-lg',
|
icon: 'ph-rocket-launch ph-bold ph-lg',
|
||||||
action: () => {
|
action: () => {
|
||||||
const el = renoteButton.value as HTMLElement | null | undefined;
|
const el = renoteButton.value as HTMLElement | null | undefined;
|
||||||
if (el) {
|
if (el) {
|
||||||
|
@ -382,6 +395,7 @@ function renote(viaKeyboard = false) {
|
||||||
renoteId: appearNote.id,
|
renoteId: appearNote.id,
|
||||||
}).then(() => {
|
}).then(() => {
|
||||||
os.toast(i18n.ts.renoted);
|
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 {
|
function onContextmenu(ev: MouseEvent): void {
|
||||||
const isLink = (el: HTMLElement) => {
|
const isLink = (el: HTMLElement) => {
|
||||||
if (el.tagName === 'A') return true;
|
if (el.tagName === 'A') return true;
|
||||||
|
|
Loading…
Reference in a new issue