2021-01-01 06:41:20 -07:00
|
|
|
|
<template>
|
|
|
|
|
<div
|
|
|
|
|
v-if="!muted"
|
|
|
|
|
v-show="!isDeleted"
|
|
|
|
|
v-hotkey="keymap"
|
|
|
|
|
v-size="{ max: [500, 450, 350, 300] }"
|
2021-11-19 03:36:12 -07:00
|
|
|
|
class="lxwezrsl _block"
|
|
|
|
|
:tabindex="!isDeleted ? '-1' : null"
|
|
|
|
|
:class="{ renote: isRenote }"
|
2021-01-01 06:41:20 -07:00
|
|
|
|
>
|
2021-11-19 03:36:12 -07:00
|
|
|
|
<XSub v-for="note in conversation" :key="note.id" class="reply-to-more" :note="note"/>
|
|
|
|
|
<XSub v-if="appearNote.reply" :note="appearNote.reply" class="reply-to"/>
|
|
|
|
|
<div v-if="isRenote" class="renote">
|
2021-01-01 06:41:20 -07:00
|
|
|
|
<MkAvatar class="avatar" :user="note.user"/>
|
2021-04-20 08:22:59 -06:00
|
|
|
|
<i class="fas fa-retweet"></i>
|
2021-01-01 06:41:20 -07:00
|
|
|
|
<I18n :src="$ts.renotedBy" tag="span">
|
|
|
|
|
<template #user>
|
2021-11-19 03:36:12 -07:00
|
|
|
|
<MkA v-user-preview="note.userId" class="name" :to="userPage(note.user)">
|
2021-01-01 06:41:20 -07:00
|
|
|
|
<MkUserName :user="note.user"/>
|
|
|
|
|
</MkA>
|
|
|
|
|
</template>
|
|
|
|
|
</I18n>
|
|
|
|
|
<div class="info">
|
2021-11-19 03:36:12 -07:00
|
|
|
|
<button ref="renoteTime" class="_button time" @click="showRenoteMenu()">
|
2021-04-20 08:22:59 -06:00
|
|
|
|
<i v-if="isMyRenote" class="fas fa-ellipsis-h dropdownIcon"></i>
|
2021-01-01 06:41:20 -07:00
|
|
|
|
<MkTime :time="note.createdAt"/>
|
|
|
|
|
</button>
|
2021-11-19 03:36:12 -07:00
|
|
|
|
<span v-if="note.visibility !== 'public'" class="visibility">
|
2021-04-20 08:22:59 -06:00
|
|
|
|
<i v-if="note.visibility === 'home'" class="fas fa-home"></i>
|
|
|
|
|
<i v-else-if="note.visibility === 'followers'" class="fas fa-unlock"></i>
|
|
|
|
|
<i v-else-if="note.visibility === 'specified'" class="fas fa-envelope"></i>
|
2021-01-01 06:41:20 -07:00
|
|
|
|
</span>
|
2021-11-19 03:36:12 -07:00
|
|
|
|
<span v-if="note.localOnly" class="localOnly"><i class="fas fa-biohazard"></i></span>
|
2021-01-01 06:41:20 -07:00
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
<article class="article" @contextmenu.stop="onContextmenu">
|
|
|
|
|
<header class="header">
|
2021-04-17 08:52:54 -06:00
|
|
|
|
<MkAvatar class="avatar" :user="appearNote.user" :show-indicator="true"/>
|
2021-01-01 06:41:20 -07:00
|
|
|
|
<div class="body">
|
|
|
|
|
<div class="top">
|
2021-11-19 03:36:12 -07:00
|
|
|
|
<MkA v-user-preview="appearNote.user.id" class="name" :to="userPage(appearNote.user)">
|
2021-01-06 20:22:21 -07:00
|
|
|
|
<MkUserName :user="appearNote.user"/>
|
2021-01-01 06:41:20 -07:00
|
|
|
|
</MkA>
|
2021-11-19 03:36:12 -07:00
|
|
|
|
<span v-if="appearNote.user.isBot" class="is-bot">bot</span>
|
|
|
|
|
<span v-if="appearNote.visibility !== 'public'" class="visibility">
|
2021-04-20 08:22:59 -06:00
|
|
|
|
<i v-if="appearNote.visibility === 'home'" class="fas fa-home"></i>
|
|
|
|
|
<i v-else-if="appearNote.visibility === 'followers'" class="fas fa-unlock"></i>
|
|
|
|
|
<i v-else-if="appearNote.visibility === 'specified'" class="fas fa-envelope"></i>
|
2021-01-01 06:41:20 -07:00
|
|
|
|
</span>
|
2021-11-19 03:36:12 -07:00
|
|
|
|
<span v-if="appearNote.localOnly" class="localOnly"><i class="fas fa-biohazard"></i></span>
|
2021-01-01 06:41:20 -07:00
|
|
|
|
</div>
|
2021-01-06 20:22:21 -07:00
|
|
|
|
<div class="username"><MkAcct :user="appearNote.user"/></div>
|
2021-01-29 19:10:33 -07:00
|
|
|
|
<MkInstanceTicker v-if="showTicker" class="ticker" :instance="appearNote.user.instance"/>
|
2021-01-01 06:41:20 -07:00
|
|
|
|
</div>
|
|
|
|
|
</header>
|
|
|
|
|
<div class="main">
|
|
|
|
|
<div class="body">
|
|
|
|
|
<p v-if="appearNote.cw != null" class="cw">
|
|
|
|
|
<Mfm v-if="appearNote.cw != ''" class="text" :text="appearNote.cw" :author="appearNote.user" :i="$i" :custom-emojis="appearNote.emojis"/>
|
2021-09-29 09:50:45 -06:00
|
|
|
|
<XCwButton v-model="showContent" :note="appearNote"/>
|
2021-01-01 06:41:20 -07:00
|
|
|
|
</p>
|
2021-11-19 03:36:12 -07:00
|
|
|
|
<div v-show="appearNote.cw == null || showContent" class="content">
|
2021-01-01 06:41:20 -07:00
|
|
|
|
<div class="text">
|
|
|
|
|
<span v-if="appearNote.isHidden" style="opacity: 0.5">({{ $ts.private }})</span>
|
2021-11-19 03:36:12 -07:00
|
|
|
|
<MkA v-if="appearNote.replyId" class="reply" :to="`/notes/${appearNote.replyId}`"><i class="fas fa-reply"></i></MkA>
|
2021-01-01 06:41:20 -07:00
|
|
|
|
<Mfm v-if="appearNote.text" :text="appearNote.text" :author="appearNote.user" :i="$i" :custom-emojis="appearNote.emojis"/>
|
2021-11-19 03:36:12 -07:00
|
|
|
|
<a v-if="appearNote.renote != null" class="rp">RN:</a>
|
|
|
|
|
<div v-if="translating || translation" class="translation">
|
2021-08-15 05:26:44 -06:00
|
|
|
|
<MkLoading v-if="translating" mini/>
|
2021-11-19 03:36:12 -07:00
|
|
|
|
<div v-else class="translated">
|
2021-11-19 03:03:25 -07:00
|
|
|
|
<b>{{ $t('translatedFrom', { x: translation.sourceLang }) }}: </b>
|
|
|
|
|
<Mfm :text="translation.text" :author="appearNote.user" :i="$i" :custom-emojis="appearNote.emojis"/>
|
2021-08-15 05:26:44 -06:00
|
|
|
|
</div>
|
|
|
|
|
</div>
|
2021-01-01 06:41:20 -07:00
|
|
|
|
</div>
|
2021-11-19 03:36:12 -07:00
|
|
|
|
<div v-if="appearNote.files.length > 0" class="files">
|
2021-01-01 06:41:20 -07:00
|
|
|
|
<XMediaList :media-list="appearNote.files"/>
|
|
|
|
|
</div>
|
2021-11-19 03:36:12 -07:00
|
|
|
|
<XPoll v-if="appearNote.poll" ref="pollViewer" :note="appearNote" class="poll"/>
|
|
|
|
|
<MkUrlPreview v-for="url in urls" :key="url" :url="url" :compact="true" :detail="true" class="url-preview"/>
|
|
|
|
|
<div v-if="appearNote.renote" class="renote"><XNoteSimple :note="appearNote.renote"/></div>
|
2021-01-01 06:41:20 -07:00
|
|
|
|
</div>
|
2021-04-20 08:22:59 -06:00
|
|
|
|
<MkA v-if="appearNote.channel && !inChannel" class="channel" :to="`/channels/${appearNote.channel.id}`"><i class="fas fa-satellite-dish"></i> {{ appearNote.channel.name }}</MkA>
|
2021-01-01 06:41:20 -07:00
|
|
|
|
</div>
|
|
|
|
|
<footer class="footer">
|
|
|
|
|
<div class="info">
|
2021-11-28 04:29:37 -07:00
|
|
|
|
<MkA class="created-at" :to="notePage(appearNote)">
|
|
|
|
|
<MkTime :time="appearNote.createdAt" mode="detail"/>
|
|
|
|
|
</MkA>
|
2021-01-01 06:41:20 -07:00
|
|
|
|
</div>
|
2021-11-19 03:36:12 -07:00
|
|
|
|
<XReactionsViewer ref="reactionsViewer" :note="appearNote"/>
|
|
|
|
|
<button class="button _button" @click="reply()">
|
2021-04-20 08:22:59 -06:00
|
|
|
|
<template v-if="appearNote.reply"><i class="fas fa-reply-all"></i></template>
|
|
|
|
|
<template v-else><i class="fas fa-reply"></i></template>
|
2021-11-19 03:36:12 -07:00
|
|
|
|
<p v-if="appearNote.repliesCount > 0" class="count">{{ appearNote.repliesCount }}</p>
|
2021-01-01 06:41:20 -07:00
|
|
|
|
</button>
|
2021-11-19 03:36:12 -07:00
|
|
|
|
<XRenoteButton ref="renoteButton" class="button" :note="appearNote" :count="appearNote.renoteCount"/>
|
|
|
|
|
<button v-if="appearNote.myReaction == null" ref="reactButton" class="button _button" @click="react()">
|
2021-04-20 08:22:59 -06:00
|
|
|
|
<i class="fas fa-plus"></i>
|
2021-01-01 06:41:20 -07:00
|
|
|
|
</button>
|
2021-11-19 03:36:12 -07:00
|
|
|
|
<button v-if="appearNote.myReaction != null" ref="reactButton" class="button _button reacted" @click="undoReact(appearNote)">
|
2021-04-20 08:22:59 -06:00
|
|
|
|
<i class="fas fa-minus"></i>
|
2021-01-01 06:41:20 -07:00
|
|
|
|
</button>
|
2021-11-19 03:36:12 -07:00
|
|
|
|
<button ref="menuButton" class="button _button" @click="menu()">
|
2021-04-20 08:22:59 -06:00
|
|
|
|
<i class="fas fa-ellipsis-h"></i>
|
2021-01-01 06:41:20 -07:00
|
|
|
|
</button>
|
|
|
|
|
</footer>
|
|
|
|
|
</div>
|
|
|
|
|
</article>
|
|
|
|
|
<XSub v-for="note in replies" :key="note.id" :note="note" class="reply" :detail="true"/>
|
|
|
|
|
</div>
|
|
|
|
|
<div v-else class="_panel muted" @click="muted = false">
|
|
|
|
|
<I18n :src="$ts.userSaysSomething" tag="small">
|
|
|
|
|
<template #name>
|
2021-11-19 03:36:12 -07:00
|
|
|
|
<MkA v-user-preview="appearNote.userId" class="name" :to="userPage(appearNote.user)">
|
2021-01-01 06:41:20 -07:00
|
|
|
|
<MkUserName :user="appearNote.user"/>
|
|
|
|
|
</MkA>
|
|
|
|
|
</template>
|
|
|
|
|
</I18n>
|
|
|
|
|
</div>
|
|
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
<script lang="ts">
|
2021-04-01 19:36:11 -06:00
|
|
|
|
import { defineAsyncComponent, defineComponent, markRaw } from 'vue';
|
|
|
|
|
import * as mfm from 'mfm-js';
|
2021-11-11 10:02:25 -07:00
|
|
|
|
import { sum } from '@/scripts/array';
|
2021-01-01 06:41:20 -07:00
|
|
|
|
import XSub from './note.sub.vue';
|
|
|
|
|
import XNoteHeader from './note-header.vue';
|
2021-10-15 10:28:34 -06:00
|
|
|
|
import XNoteSimple from './note-simple.vue';
|
2021-01-01 06:41:20 -07:00
|
|
|
|
import XReactionsViewer from './reactions-viewer.vue';
|
|
|
|
|
import XMediaList from './media-list.vue';
|
|
|
|
|
import XCwButton from './cw-button.vue';
|
|
|
|
|
import XPoll from './poll.vue';
|
2021-11-12 07:15:14 -07:00
|
|
|
|
import XRenoteButton from './renote-button.vue';
|
2021-11-12 07:53:10 -07:00
|
|
|
|
import { pleaseLogin } from '@/scripts/please-login';
|
|
|
|
|
import { focusPrev, focusNext } from '@/scripts/focus';
|
|
|
|
|
import { url } from '@/config';
|
|
|
|
|
import copyToClipboard from '@/scripts/copy-to-clipboard';
|
|
|
|
|
import { checkWordMute } from '@/scripts/check-word-mute';
|
|
|
|
|
import { userPage } from '@/filters/user';
|
2021-11-28 04:29:37 -07:00
|
|
|
|
import { notePage } from '@/filters/note';
|
2021-11-12 07:53:10 -07:00
|
|
|
|
import * as os from '@/os';
|
2021-12-29 06:13:09 -07:00
|
|
|
|
import { stream } from '@/stream';
|
2021-11-12 07:53:10 -07:00
|
|
|
|
import { noteActions, noteViewInterruptors } from '@/store';
|
|
|
|
|
import { reactionPicker } from '@/scripts/reaction-picker';
|
|
|
|
|
import { extractUrlFromMfm } from '@/scripts/extract-url-from-mfm';
|
2021-01-01 06:41:20 -07:00
|
|
|
|
|
|
|
|
|
// TODO: note.vueとほぼ同じなので共通化したい
|
|
|
|
|
export default defineComponent({
|
|
|
|
|
components: {
|
|
|
|
|
XSub,
|
|
|
|
|
XNoteHeader,
|
2021-10-15 10:28:34 -06:00
|
|
|
|
XNoteSimple,
|
2021-01-01 06:41:20 -07:00
|
|
|
|
XReactionsViewer,
|
|
|
|
|
XMediaList,
|
|
|
|
|
XCwButton,
|
|
|
|
|
XPoll,
|
2021-11-12 07:15:14 -07:00
|
|
|
|
XRenoteButton,
|
2021-11-12 07:53:10 -07:00
|
|
|
|
MkUrlPreview: defineAsyncComponent(() => import('@/components/url-preview.vue')),
|
|
|
|
|
MkInstanceTicker: defineAsyncComponent(() => import('@/components/instance-ticker.vue')),
|
2021-01-01 06:41:20 -07:00
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
inject: {
|
|
|
|
|
inChannel: {
|
|
|
|
|
default: null
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
props: {
|
|
|
|
|
note: {
|
|
|
|
|
type: Object,
|
|
|
|
|
required: true
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
emits: ['update:note'],
|
|
|
|
|
|
|
|
|
|
data() {
|
|
|
|
|
return {
|
|
|
|
|
connection: null,
|
|
|
|
|
conversation: [],
|
|
|
|
|
replies: [],
|
|
|
|
|
showContent: false,
|
|
|
|
|
isDeleted: false,
|
|
|
|
|
muted: false,
|
2021-08-15 05:26:44 -06:00
|
|
|
|
translation: null,
|
|
|
|
|
translating: false,
|
2021-11-28 04:29:37 -07:00
|
|
|
|
notePage,
|
2021-01-01 06:41:20 -07:00
|
|
|
|
};
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
computed: {
|
|
|
|
|
rs() {
|
|
|
|
|
return this.$store.state.reactions;
|
|
|
|
|
},
|
|
|
|
|
keymap(): any {
|
|
|
|
|
return {
|
|
|
|
|
'r': () => this.reply(true),
|
|
|
|
|
'e|a|plus': () => this.react(true),
|
2021-11-12 07:15:14 -07:00
|
|
|
|
'q': () => this.$refs.renoteButton.renote(true),
|
2021-01-01 06:41:20 -07:00
|
|
|
|
'f|b': this.favorite,
|
|
|
|
|
'delete|ctrl+d': this.del,
|
|
|
|
|
'ctrl+q': this.renoteDirectly,
|
|
|
|
|
'up|k|shift+tab': this.focusBefore,
|
|
|
|
|
'down|j|tab': this.focusAfter,
|
|
|
|
|
'esc': this.blur,
|
|
|
|
|
'm|o': () => this.menu(true),
|
|
|
|
|
's': this.toggleShowContent,
|
|
|
|
|
'1': () => this.reactDirectly(this.rs[0]),
|
|
|
|
|
'2': () => this.reactDirectly(this.rs[1]),
|
|
|
|
|
'3': () => this.reactDirectly(this.rs[2]),
|
|
|
|
|
'4': () => this.reactDirectly(this.rs[3]),
|
|
|
|
|
'5': () => this.reactDirectly(this.rs[4]),
|
|
|
|
|
'6': () => this.reactDirectly(this.rs[5]),
|
|
|
|
|
'7': () => this.reactDirectly(this.rs[6]),
|
|
|
|
|
'8': () => this.reactDirectly(this.rs[7]),
|
|
|
|
|
'9': () => this.reactDirectly(this.rs[8]),
|
|
|
|
|
'0': () => this.reactDirectly(this.rs[9]),
|
|
|
|
|
};
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
isRenote(): boolean {
|
|
|
|
|
return (this.note.renote &&
|
|
|
|
|
this.note.text == null &&
|
|
|
|
|
this.note.fileIds.length == 0 &&
|
|
|
|
|
this.note.poll == null);
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
appearNote(): any {
|
|
|
|
|
return this.isRenote ? this.note.renote : this.note;
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
isMyNote(): boolean {
|
|
|
|
|
return this.$i && (this.$i.id === this.appearNote.userId);
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
isMyRenote(): boolean {
|
|
|
|
|
return this.$i && (this.$i.id === this.note.userId);
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
reactionsCount(): number {
|
|
|
|
|
return this.appearNote.reactions
|
|
|
|
|
? sum(Object.values(this.appearNote.reactions))
|
|
|
|
|
: 0;
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
urls(): string[] {
|
|
|
|
|
if (this.appearNote.text) {
|
2021-04-01 19:36:11 -06:00
|
|
|
|
return extractUrlFromMfm(mfm.parse(this.appearNote.text));
|
2021-01-01 06:41:20 -07:00
|
|
|
|
} else {
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
showTicker() {
|
|
|
|
|
if (this.$store.state.instanceTicker === 'always') return true;
|
|
|
|
|
if (this.$store.state.instanceTicker === 'remote' && this.appearNote.user.instance) return true;
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
async created() {
|
|
|
|
|
if (this.$i) {
|
2021-12-29 06:13:09 -07:00
|
|
|
|
this.connection = stream;
|
2021-01-01 06:41:20 -07:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
this.muted = await checkWordMute(this.appearNote, this.$i, this.$store.state.mutedWords);
|
|
|
|
|
|
|
|
|
|
// plugin
|
|
|
|
|
if (noteViewInterruptors.length > 0) {
|
|
|
|
|
let result = this.note;
|
|
|
|
|
for (const interruptor of noteViewInterruptors) {
|
|
|
|
|
result = await interruptor.handler(JSON.parse(JSON.stringify(result)));
|
|
|
|
|
}
|
|
|
|
|
this.$emit('update:note', Object.freeze(result));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
os.api('notes/children', {
|
|
|
|
|
noteId: this.appearNote.id,
|
|
|
|
|
limit: 30
|
|
|
|
|
}).then(replies => {
|
|
|
|
|
this.replies = replies;
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
if (this.appearNote.replyId) {
|
|
|
|
|
os.api('notes/conversation', {
|
|
|
|
|
noteId: this.appearNote.replyId
|
|
|
|
|
}).then(conversation => {
|
|
|
|
|
this.conversation = conversation.reverse();
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
mounted() {
|
|
|
|
|
this.capture(true);
|
|
|
|
|
|
|
|
|
|
if (this.$i) {
|
|
|
|
|
this.connection.on('_connected_', this.onStreamConnected);
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
beforeUnmount() {
|
|
|
|
|
this.decapture(true);
|
|
|
|
|
|
|
|
|
|
if (this.$i) {
|
|
|
|
|
this.connection.off('_connected_', this.onStreamConnected);
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
methods: {
|
|
|
|
|
updateAppearNote(v) {
|
|
|
|
|
this.$emit('update:note', Object.freeze(this.isRenote ? {
|
|
|
|
|
...this.note,
|
|
|
|
|
renote: {
|
|
|
|
|
...this.note.renote,
|
|
|
|
|
...v
|
|
|
|
|
}
|
|
|
|
|
} : {
|
|
|
|
|
...this.note,
|
|
|
|
|
...v
|
|
|
|
|
}));
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
readPromo() {
|
|
|
|
|
os.api('promo/read', {
|
|
|
|
|
noteId: this.appearNote.id
|
|
|
|
|
});
|
|
|
|
|
this.isDeleted = true;
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
capture(withHandler = false) {
|
|
|
|
|
if (this.$i) {
|
2021-03-21 02:38:09 -06:00
|
|
|
|
// TODO: このノートがストリーミング経由で流れてきた場合のみ sr する
|
|
|
|
|
this.connection.send(document.body.contains(this.$el) ? 'sr' : 's', { id: this.appearNote.id });
|
2021-01-01 06:41:20 -07:00
|
|
|
|
if (withHandler) this.connection.on('noteUpdated', this.onStreamNoteUpdated);
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
decapture(withHandler = false) {
|
|
|
|
|
if (this.$i) {
|
|
|
|
|
this.connection.send('un', {
|
|
|
|
|
id: this.appearNote.id
|
|
|
|
|
});
|
|
|
|
|
if (withHandler) this.connection.off('noteUpdated', this.onStreamNoteUpdated);
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
onStreamConnected() {
|
|
|
|
|
this.capture();
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
onStreamNoteUpdated(data) {
|
|
|
|
|
const { type, id, body } = data;
|
|
|
|
|
|
|
|
|
|
if (id !== this.appearNote.id) return;
|
|
|
|
|
|
|
|
|
|
switch (type) {
|
|
|
|
|
case 'reacted': {
|
|
|
|
|
const reaction = body.reaction;
|
|
|
|
|
|
|
|
|
|
// DeepではなくShallowコピーであることに注意。n.reactions[reaction] = hogeとかしないように(親からもらったデータをミューテートすることになるので)
|
|
|
|
|
let n = {
|
|
|
|
|
...this.appearNote,
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
if (body.emoji) {
|
|
|
|
|
const emojis = this.appearNote.emojis || [];
|
|
|
|
|
if (!emojis.includes(body.emoji)) {
|
|
|
|
|
n.emojis = [...emojis, body.emoji];
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// TODO: reactionsプロパティがない場合ってあったっけ? なければ || {} は消せる
|
|
|
|
|
const currentCount = (this.appearNote.reactions || {})[reaction] || 0;
|
|
|
|
|
|
|
|
|
|
// Increment the count
|
|
|
|
|
n.reactions = {
|
|
|
|
|
...this.appearNote.reactions,
|
|
|
|
|
[reaction]: currentCount + 1
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
if (body.userId === this.$i.id) {
|
|
|
|
|
n.myReaction = reaction;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
this.updateAppearNote(n);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
case 'unreacted': {
|
|
|
|
|
const reaction = body.reaction;
|
|
|
|
|
|
|
|
|
|
// DeepではなくShallowコピーであることに注意。n.reactions[reaction] = hogeとかしないように(親からもらったデータをミューテートすることになるので)
|
|
|
|
|
let n = {
|
|
|
|
|
...this.appearNote,
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
// TODO: reactionsプロパティがない場合ってあったっけ? なければ || {} は消せる
|
|
|
|
|
const currentCount = (this.appearNote.reactions || {})[reaction] || 0;
|
|
|
|
|
|
|
|
|
|
// Decrement the count
|
|
|
|
|
n.reactions = {
|
|
|
|
|
...this.appearNote.reactions,
|
|
|
|
|
[reaction]: Math.max(0, currentCount - 1)
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
if (body.userId === this.$i.id) {
|
|
|
|
|
n.myReaction = null;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
this.updateAppearNote(n);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
case 'pollVoted': {
|
|
|
|
|
const choice = body.choice;
|
|
|
|
|
|
|
|
|
|
// DeepではなくShallowコピーであることに注意。n.reactions[reaction] = hogeとかしないように(親からもらったデータをミューテートすることになるので)
|
|
|
|
|
let n = {
|
|
|
|
|
...this.appearNote,
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
const choices = [...this.appearNote.poll.choices];
|
|
|
|
|
choices[choice] = {
|
|
|
|
|
...choices[choice],
|
|
|
|
|
votes: choices[choice].votes + 1,
|
|
|
|
|
...(body.userId === this.$i.id ? {
|
|
|
|
|
isVoted: true
|
|
|
|
|
} : {})
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
n.poll = {
|
|
|
|
|
...this.appearNote.poll,
|
|
|
|
|
choices: choices
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
this.updateAppearNote(n);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
case 'deleted': {
|
|
|
|
|
this.isDeleted = true;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
reply(viaKeyboard = false) {
|
|
|
|
|
pleaseLogin();
|
|
|
|
|
os.post({
|
|
|
|
|
reply: this.appearNote,
|
|
|
|
|
animation: !viaKeyboard,
|
|
|
|
|
}, () => {
|
|
|
|
|
this.focus();
|
|
|
|
|
});
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
renoteDirectly() {
|
|
|
|
|
os.apiWithDialog('notes/create', {
|
|
|
|
|
renoteId: this.appearNote.id
|
|
|
|
|
}, undefined, (res: any) => {
|
2021-11-18 02:45:58 -07:00
|
|
|
|
os.alert({
|
2021-01-01 06:41:20 -07:00
|
|
|
|
type: 'success',
|
|
|
|
|
text: this.$ts.renoted,
|
|
|
|
|
});
|
|
|
|
|
}, (e: Error) => {
|
|
|
|
|
if (e.id === 'b5c90186-4ab0-49c8-9bba-a1f76c282ba4') {
|
2021-11-18 02:45:58 -07:00
|
|
|
|
os.alert({
|
2021-01-01 06:41:20 -07:00
|
|
|
|
type: 'error',
|
|
|
|
|
text: this.$ts.cantRenote,
|
|
|
|
|
});
|
|
|
|
|
} else if (e.id === 'fd4cc33e-2a37-48dd-99cc-9b806eb2031a') {
|
2021-11-18 02:45:58 -07:00
|
|
|
|
os.alert({
|
2021-01-01 06:41:20 -07:00
|
|
|
|
type: 'error',
|
|
|
|
|
text: this.$ts.cantReRenote,
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
react(viaKeyboard = false) {
|
|
|
|
|
pleaseLogin();
|
|
|
|
|
this.blur();
|
2021-03-04 21:49:46 -07:00
|
|
|
|
reactionPicker.show(this.$refs.reactButton, reaction => {
|
2021-02-27 09:09:59 -07:00
|
|
|
|
os.api('notes/reactions/create', {
|
|
|
|
|
noteId: this.appearNote.id,
|
|
|
|
|
reaction: reaction
|
|
|
|
|
});
|
|
|
|
|
}, () => {
|
|
|
|
|
this.focus();
|
|
|
|
|
});
|
2021-01-01 06:41:20 -07:00
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
reactDirectly(reaction) {
|
|
|
|
|
os.api('notes/reactions/create', {
|
|
|
|
|
noteId: this.appearNote.id,
|
|
|
|
|
reaction: reaction
|
|
|
|
|
});
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
undoReact(note) {
|
|
|
|
|
const oldReaction = note.myReaction;
|
|
|
|
|
if (!oldReaction) return;
|
|
|
|
|
os.api('notes/reactions/delete', {
|
|
|
|
|
noteId: note.id
|
|
|
|
|
});
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
favorite() {
|
|
|
|
|
pleaseLogin();
|
|
|
|
|
os.apiWithDialog('notes/favorites/create', {
|
|
|
|
|
noteId: this.appearNote.id
|
|
|
|
|
}, undefined, (res: any) => {
|
2021-11-18 02:45:58 -07:00
|
|
|
|
os.alert({
|
2021-01-01 06:41:20 -07:00
|
|
|
|
type: 'success',
|
|
|
|
|
text: this.$ts.favorited,
|
|
|
|
|
});
|
|
|
|
|
}, (e: Error) => {
|
|
|
|
|
if (e.id === 'a402c12b-34dd-41d2-97d8-4d2ffd96a1a6') {
|
2021-11-18 02:45:58 -07:00
|
|
|
|
os.alert({
|
2021-01-01 06:41:20 -07:00
|
|
|
|
type: 'error',
|
|
|
|
|
text: this.$ts.alreadyFavorited,
|
|
|
|
|
});
|
|
|
|
|
} else if (e.id === '6dd26674-e060-4816-909a-45ba3f4da458') {
|
2021-11-18 02:45:58 -07:00
|
|
|
|
os.alert({
|
2021-01-01 06:41:20 -07:00
|
|
|
|
type: 'error',
|
|
|
|
|
text: this.$ts.cantFavorite,
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
del() {
|
2021-11-18 02:45:58 -07:00
|
|
|
|
os.confirm({
|
2021-01-01 06:41:20 -07:00
|
|
|
|
type: 'warning',
|
|
|
|
|
text: this.$ts.noteDeleteConfirm,
|
|
|
|
|
}).then(({ canceled }) => {
|
|
|
|
|
if (canceled) return;
|
|
|
|
|
|
|
|
|
|
os.api('notes/delete', {
|
|
|
|
|
noteId: this.appearNote.id
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
delEdit() {
|
2021-11-18 02:45:58 -07:00
|
|
|
|
os.confirm({
|
2021-01-01 06:41:20 -07:00
|
|
|
|
type: 'warning',
|
|
|
|
|
text: this.$ts.deleteAndEditConfirm,
|
|
|
|
|
}).then(({ canceled }) => {
|
|
|
|
|
if (canceled) return;
|
|
|
|
|
|
|
|
|
|
os.api('notes/delete', {
|
|
|
|
|
noteId: this.appearNote.id
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
os.post({ initialNote: this.appearNote, renote: this.appearNote.renote, reply: this.appearNote.reply, channel: this.appearNote.channel });
|
|
|
|
|
});
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
toggleFavorite(favorite: boolean) {
|
|
|
|
|
os.apiWithDialog(favorite ? 'notes/favorites/create' : 'notes/favorites/delete', {
|
|
|
|
|
noteId: this.appearNote.id
|
|
|
|
|
});
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
toggleWatch(watch: boolean) {
|
|
|
|
|
os.apiWithDialog(watch ? 'notes/watching/create' : 'notes/watching/delete', {
|
|
|
|
|
noteId: this.appearNote.id
|
|
|
|
|
});
|
|
|
|
|
},
|
|
|
|
|
|
2021-10-31 00:30:22 -06:00
|
|
|
|
toggleThreadMute(mute: boolean) {
|
|
|
|
|
os.apiWithDialog(mute ? 'notes/thread-muting/create' : 'notes/thread-muting/delete', {
|
|
|
|
|
noteId: this.appearNote.id
|
|
|
|
|
});
|
|
|
|
|
},
|
|
|
|
|
|
2021-01-01 06:41:20 -07:00
|
|
|
|
getMenu() {
|
|
|
|
|
let menu;
|
|
|
|
|
if (this.$i) {
|
|
|
|
|
const statePromise = os.api('notes/state', {
|
|
|
|
|
noteId: this.appearNote.id
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
menu = [{
|
2021-04-20 08:22:59 -06:00
|
|
|
|
icon: 'fas fa-copy',
|
2021-01-01 06:41:20 -07:00
|
|
|
|
text: this.$ts.copyContent,
|
|
|
|
|
action: this.copyContent
|
|
|
|
|
}, {
|
2021-04-20 08:22:59 -06:00
|
|
|
|
icon: 'fas fa-link',
|
2021-01-01 06:41:20 -07:00
|
|
|
|
text: this.$ts.copyLink,
|
|
|
|
|
action: this.copyLink
|
|
|
|
|
}, (this.appearNote.url || this.appearNote.uri) ? {
|
2021-04-20 08:22:59 -06:00
|
|
|
|
icon: 'fas fa-external-link-square-alt',
|
2021-01-01 06:41:20 -07:00
|
|
|
|
text: this.$ts.showOnRemote,
|
|
|
|
|
action: () => {
|
|
|
|
|
window.open(this.appearNote.url || this.appearNote.uri, '_blank');
|
|
|
|
|
}
|
|
|
|
|
} : undefined,
|
2021-04-10 21:42:48 -06:00
|
|
|
|
{
|
2021-04-20 08:22:59 -06:00
|
|
|
|
icon: 'fas fa-share-alt',
|
2021-04-10 21:42:48 -06:00
|
|
|
|
text: this.$ts.share,
|
|
|
|
|
action: this.share
|
|
|
|
|
},
|
2021-08-15 05:26:44 -06:00
|
|
|
|
this.$instance.translatorAvailable ? {
|
|
|
|
|
icon: 'fas fa-language',
|
|
|
|
|
text: this.$ts.translate,
|
|
|
|
|
action: this.translate
|
|
|
|
|
} : undefined,
|
2021-01-01 06:41:20 -07:00
|
|
|
|
null,
|
|
|
|
|
statePromise.then(state => state.isFavorited ? {
|
2021-04-20 08:22:59 -06:00
|
|
|
|
icon: 'fas fa-star',
|
2021-01-01 06:41:20 -07:00
|
|
|
|
text: this.$ts.unfavorite,
|
|
|
|
|
action: () => this.toggleFavorite(false)
|
|
|
|
|
} : {
|
2021-04-20 08:22:59 -06:00
|
|
|
|
icon: 'fas fa-star',
|
2021-01-01 06:41:20 -07:00
|
|
|
|
text: this.$ts.favorite,
|
|
|
|
|
action: () => this.toggleFavorite(true)
|
|
|
|
|
}),
|
|
|
|
|
{
|
2021-04-20 08:22:59 -06:00
|
|
|
|
icon: 'fas fa-paperclip',
|
2021-01-01 06:41:20 -07:00
|
|
|
|
text: this.$ts.clip,
|
|
|
|
|
action: () => this.clip()
|
|
|
|
|
},
|
|
|
|
|
(this.appearNote.userId != this.$i.id) ? statePromise.then(state => state.isWatching ? {
|
2021-04-20 08:22:59 -06:00
|
|
|
|
icon: 'fas fa-eye-slash',
|
2021-01-01 06:41:20 -07:00
|
|
|
|
text: this.$ts.unwatch,
|
|
|
|
|
action: () => this.toggleWatch(false)
|
|
|
|
|
} : {
|
2021-04-20 08:22:59 -06:00
|
|
|
|
icon: 'fas fa-eye',
|
2021-01-01 06:41:20 -07:00
|
|
|
|
text: this.$ts.watch,
|
|
|
|
|
action: () => this.toggleWatch(true)
|
|
|
|
|
}) : undefined,
|
2021-10-31 00:30:22 -06:00
|
|
|
|
statePromise.then(state => state.isMutedThread ? {
|
|
|
|
|
icon: 'fas fa-comment-slash',
|
|
|
|
|
text: this.$ts.unmuteThread,
|
|
|
|
|
action: () => this.toggleThreadMute(false)
|
|
|
|
|
} : {
|
|
|
|
|
icon: 'fas fa-comment-slash',
|
|
|
|
|
text: this.$ts.muteThread,
|
|
|
|
|
action: () => this.toggleThreadMute(true)
|
|
|
|
|
}),
|
2021-01-01 06:41:20 -07:00
|
|
|
|
this.appearNote.userId == this.$i.id ? (this.$i.pinnedNoteIds || []).includes(this.appearNote.id) ? {
|
2021-04-20 08:22:59 -06:00
|
|
|
|
icon: 'fas fa-thumbtack',
|
2021-01-01 06:41:20 -07:00
|
|
|
|
text: this.$ts.unpin,
|
|
|
|
|
action: () => this.togglePin(false)
|
|
|
|
|
} : {
|
2021-04-20 08:22:59 -06:00
|
|
|
|
icon: 'fas fa-thumbtack',
|
2021-01-01 06:41:20 -07:00
|
|
|
|
text: this.$ts.pin,
|
|
|
|
|
action: () => this.togglePin(true)
|
|
|
|
|
} : undefined,
|
2021-12-02 04:46:16 -07:00
|
|
|
|
/*...(this.$i.isModerator || this.$i.isAdmin ? [
|
2021-01-01 06:41:20 -07:00
|
|
|
|
null,
|
|
|
|
|
{
|
2021-04-20 08:22:59 -06:00
|
|
|
|
icon: 'fas fa-bullhorn',
|
2021-01-01 06:41:20 -07:00
|
|
|
|
text: this.$ts.promote,
|
|
|
|
|
action: this.promote
|
|
|
|
|
}]
|
|
|
|
|
: []
|
2021-12-02 04:46:16 -07:00
|
|
|
|
),*/
|
2021-01-01 06:41:20 -07:00
|
|
|
|
...(this.appearNote.userId != this.$i.id ? [
|
|
|
|
|
null,
|
|
|
|
|
{
|
2021-04-20 08:22:59 -06:00
|
|
|
|
icon: 'fas fa-exclamation-circle',
|
2021-01-01 06:41:20 -07:00
|
|
|
|
text: this.$ts.reportAbuse,
|
|
|
|
|
action: () => {
|
|
|
|
|
const u = `${url}/notes/${this.appearNote.id}`;
|
2021-11-11 10:02:25 -07:00
|
|
|
|
os.popup(import('@/components/abuse-report-window.vue'), {
|
2021-01-01 06:41:20 -07:00
|
|
|
|
user: this.appearNote.user,
|
|
|
|
|
initialComment: `Note: ${u}\n-----\n`
|
|
|
|
|
}, {}, 'closed');
|
|
|
|
|
}
|
|
|
|
|
}]
|
|
|
|
|
: []
|
|
|
|
|
),
|
|
|
|
|
...(this.appearNote.userId == this.$i.id || this.$i.isModerator || this.$i.isAdmin ? [
|
|
|
|
|
null,
|
|
|
|
|
this.appearNote.userId == this.$i.id ? {
|
2021-04-20 08:22:59 -06:00
|
|
|
|
icon: 'fas fa-edit',
|
2021-01-01 06:41:20 -07:00
|
|
|
|
text: this.$ts.deleteAndEdit,
|
|
|
|
|
action: this.delEdit
|
|
|
|
|
} : undefined,
|
|
|
|
|
{
|
2021-04-20 08:22:59 -06:00
|
|
|
|
icon: 'fas fa-trash-alt',
|
2021-01-01 06:41:20 -07:00
|
|
|
|
text: this.$ts.delete,
|
|
|
|
|
danger: true,
|
|
|
|
|
action: this.del
|
|
|
|
|
}]
|
|
|
|
|
: []
|
|
|
|
|
)]
|
|
|
|
|
.filter(x => x !== undefined);
|
|
|
|
|
} else {
|
|
|
|
|
menu = [{
|
2021-04-20 08:22:59 -06:00
|
|
|
|
icon: 'fas fa-copy',
|
2021-01-01 06:41:20 -07:00
|
|
|
|
text: this.$ts.copyContent,
|
|
|
|
|
action: this.copyContent
|
|
|
|
|
}, {
|
2021-04-20 08:22:59 -06:00
|
|
|
|
icon: 'fas fa-link',
|
2021-01-01 06:41:20 -07:00
|
|
|
|
text: this.$ts.copyLink,
|
|
|
|
|
action: this.copyLink
|
|
|
|
|
}, (this.appearNote.url || this.appearNote.uri) ? {
|
2021-04-20 08:22:59 -06:00
|
|
|
|
icon: 'fas fa-external-link-square-alt',
|
2021-01-01 06:41:20 -07:00
|
|
|
|
text: this.$ts.showOnRemote,
|
|
|
|
|
action: () => {
|
|
|
|
|
window.open(this.appearNote.url || this.appearNote.uri, '_blank');
|
|
|
|
|
}
|
|
|
|
|
} : undefined]
|
|
|
|
|
.filter(x => x !== undefined);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (noteActions.length > 0) {
|
|
|
|
|
menu = menu.concat([null, ...noteActions.map(action => ({
|
2021-04-20 08:22:59 -06:00
|
|
|
|
icon: 'fas fa-plug',
|
2021-01-01 06:41:20 -07:00
|
|
|
|
text: action.title,
|
|
|
|
|
action: () => {
|
|
|
|
|
action.handler(this.appearNote);
|
|
|
|
|
}
|
|
|
|
|
}))]);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return menu;
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
onContextmenu(e) {
|
|
|
|
|
const isLink = (el: HTMLElement) => {
|
|
|
|
|
if (el.tagName === 'A') return true;
|
|
|
|
|
if (el.parentElement) {
|
|
|
|
|
return isLink(el.parentElement);
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
if (isLink(e.target)) return;
|
|
|
|
|
if (window.getSelection().toString() !== '') return;
|
2021-02-20 00:16:19 -07:00
|
|
|
|
|
|
|
|
|
if (this.$store.state.useReactionPickerForContextMenu) {
|
|
|
|
|
e.preventDefault();
|
|
|
|
|
this.react();
|
|
|
|
|
} else {
|
|
|
|
|
os.contextMenu(this.getMenu(), e).then(this.focus);
|
|
|
|
|
}
|
2021-01-01 06:41:20 -07:00
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
menu(viaKeyboard = false) {
|
2021-08-07 21:19:10 -06:00
|
|
|
|
os.popupMenu(this.getMenu(), this.$refs.menuButton, {
|
2021-01-01 06:41:20 -07:00
|
|
|
|
viaKeyboard
|
|
|
|
|
}).then(this.focus);
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
showRenoteMenu(viaKeyboard = false) {
|
|
|
|
|
if (!this.isMyRenote) return;
|
2021-08-07 21:19:10 -06:00
|
|
|
|
os.popupMenu([{
|
2021-01-01 06:41:20 -07:00
|
|
|
|
text: this.$ts.unrenote,
|
2021-04-20 08:22:59 -06:00
|
|
|
|
icon: 'fas fa-trash-alt',
|
2021-01-01 06:41:20 -07:00
|
|
|
|
danger: true,
|
|
|
|
|
action: () => {
|
|
|
|
|
os.api('notes/delete', {
|
|
|
|
|
noteId: this.note.id
|
|
|
|
|
});
|
|
|
|
|
this.isDeleted = true;
|
|
|
|
|
}
|
|
|
|
|
}], this.$refs.renoteTime, {
|
|
|
|
|
viaKeyboard: viaKeyboard
|
|
|
|
|
});
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
toggleShowContent() {
|
|
|
|
|
this.showContent = !this.showContent;
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
copyContent() {
|
|
|
|
|
copyToClipboard(this.appearNote.text);
|
|
|
|
|
os.success();
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
copyLink() {
|
|
|
|
|
copyToClipboard(`${url}/notes/${this.appearNote.id}`);
|
|
|
|
|
os.success();
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
togglePin(pin: boolean) {
|
|
|
|
|
os.apiWithDialog(pin ? 'i/pin' : 'i/unpin', {
|
|
|
|
|
noteId: this.appearNote.id
|
|
|
|
|
}, undefined, null, e => {
|
|
|
|
|
if (e.id === '72dab508-c64d-498f-8740-a8eec1ba385a') {
|
2021-11-18 02:45:58 -07:00
|
|
|
|
os.alert({
|
2021-01-01 06:41:20 -07:00
|
|
|
|
type: 'error',
|
|
|
|
|
text: this.$ts.pinLimitExceeded
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
async clip() {
|
|
|
|
|
const clips = await os.api('clips/list');
|
2021-08-07 21:19:10 -06:00
|
|
|
|
os.popupMenu([{
|
2021-04-20 08:22:59 -06:00
|
|
|
|
icon: 'fas fa-plus',
|
2021-01-01 06:41:20 -07:00
|
|
|
|
text: this.$ts.createNew,
|
|
|
|
|
action: async () => {
|
|
|
|
|
const { canceled, result } = await os.form(this.$ts.createNewClip, {
|
|
|
|
|
name: {
|
|
|
|
|
type: 'string',
|
|
|
|
|
label: this.$ts.name
|
|
|
|
|
},
|
|
|
|
|
description: {
|
|
|
|
|
type: 'string',
|
|
|
|
|
required: false,
|
|
|
|
|
multiline: true,
|
|
|
|
|
label: this.$ts.description
|
|
|
|
|
},
|
|
|
|
|
isPublic: {
|
|
|
|
|
type: 'boolean',
|
|
|
|
|
label: this.$ts.public,
|
|
|
|
|
default: false
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
if (canceled) return;
|
|
|
|
|
|
|
|
|
|
const clip = await os.apiWithDialog('clips/create', result);
|
|
|
|
|
|
|
|
|
|
os.apiWithDialog('clips/add-note', { clipId: clip.id, noteId: this.appearNote.id });
|
|
|
|
|
}
|
|
|
|
|
}, null, ...clips.map(clip => ({
|
|
|
|
|
text: clip.name,
|
|
|
|
|
action: () => {
|
|
|
|
|
os.apiWithDialog('clips/add-note', { clipId: clip.id, noteId: this.appearNote.id });
|
|
|
|
|
}
|
|
|
|
|
}))], this.$refs.menuButton, {
|
|
|
|
|
}).then(this.focus);
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
async promote() {
|
2021-11-18 02:45:58 -07:00
|
|
|
|
const { canceled, result: days } = await os.inputNumber({
|
2021-01-01 06:41:20 -07:00
|
|
|
|
title: this.$ts.numberOfDays,
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
if (canceled) return;
|
|
|
|
|
|
|
|
|
|
os.apiWithDialog('admin/promo/create', {
|
|
|
|
|
noteId: this.appearNote.id,
|
|
|
|
|
expiresAt: Date.now() + (86400000 * days)
|
|
|
|
|
});
|
|
|
|
|
},
|
|
|
|
|
|
2021-04-10 21:42:48 -06:00
|
|
|
|
share() {
|
|
|
|
|
navigator.share({
|
|
|
|
|
title: this.$t('noteOf', { user: this.appearNote.user.name }),
|
|
|
|
|
text: this.appearNote.text,
|
|
|
|
|
url: `${url}/notes/${this.appearNote.id}`
|
|
|
|
|
});
|
|
|
|
|
},
|
|
|
|
|
|
2021-08-15 05:26:44 -06:00
|
|
|
|
async translate() {
|
|
|
|
|
if (this.translation != null) return;
|
|
|
|
|
this.translating = true;
|
|
|
|
|
const res = await os.api('notes/translate', {
|
|
|
|
|
noteId: this.appearNote.id,
|
|
|
|
|
targetLang: localStorage.getItem('lang') || navigator.language,
|
|
|
|
|
});
|
|
|
|
|
this.translating = false;
|
|
|
|
|
this.translation = res;
|
|
|
|
|
},
|
|
|
|
|
|
2021-01-01 06:41:20 -07:00
|
|
|
|
focus() {
|
|
|
|
|
this.$el.focus();
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
blur() {
|
|
|
|
|
this.$el.blur();
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
focusBefore() {
|
|
|
|
|
focusPrev(this.$el);
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
focusAfter() {
|
|
|
|
|
focusNext(this.$el);
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
userPage
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
<style lang="scss" scoped>
|
2021-08-16 00:21:58 -06:00
|
|
|
|
.lxwezrsl {
|
2021-01-01 06:41:20 -07:00
|
|
|
|
position: relative;
|
|
|
|
|
transition: box-shadow 0.1s ease;
|
2021-03-02 06:57:16 -07:00
|
|
|
|
overflow: hidden;
|
2021-01-01 06:41:20 -07:00
|
|
|
|
contain: content;
|
|
|
|
|
|
|
|
|
|
&:focus-visible {
|
|
|
|
|
outline: none;
|
|
|
|
|
|
|
|
|
|
&:after {
|
|
|
|
|
content: "";
|
|
|
|
|
pointer-events: none;
|
|
|
|
|
display: block;
|
|
|
|
|
position: absolute;
|
|
|
|
|
z-index: 10;
|
|
|
|
|
top: 0;
|
|
|
|
|
left: 0;
|
|
|
|
|
right: 0;
|
|
|
|
|
bottom: 0;
|
|
|
|
|
margin: auto;
|
|
|
|
|
width: calc(100% - 8px);
|
|
|
|
|
height: calc(100% - 8px);
|
|
|
|
|
border: dashed 1px var(--focus);
|
|
|
|
|
border-radius: var(--radius);
|
|
|
|
|
box-sizing: border-box;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
&:hover > .article > .main > .footer > .button {
|
|
|
|
|
opacity: 1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
> .reply-to {
|
|
|
|
|
opacity: 0.7;
|
|
|
|
|
padding-bottom: 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
> .reply-to-more {
|
|
|
|
|
opacity: 0.7;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
> .renote {
|
|
|
|
|
display: flex;
|
|
|
|
|
align-items: center;
|
|
|
|
|
padding: 16px 32px 8px 32px;
|
|
|
|
|
line-height: 28px;
|
|
|
|
|
white-space: pre;
|
|
|
|
|
color: var(--renote);
|
|
|
|
|
|
|
|
|
|
> .avatar {
|
|
|
|
|
flex-shrink: 0;
|
|
|
|
|
display: inline-block;
|
|
|
|
|
width: 28px;
|
|
|
|
|
height: 28px;
|
|
|
|
|
margin: 0 8px 0 0;
|
|
|
|
|
border-radius: 6px;
|
|
|
|
|
}
|
|
|
|
|
|
2021-04-20 08:22:59 -06:00
|
|
|
|
> i {
|
2021-01-01 06:41:20 -07:00
|
|
|
|
margin-right: 4px;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
> span {
|
2021-03-02 06:57:16 -07:00
|
|
|
|
overflow: hidden;
|
2021-01-01 06:41:20 -07:00
|
|
|
|
flex-shrink: 1;
|
|
|
|
|
text-overflow: ellipsis;
|
|
|
|
|
white-space: nowrap;
|
|
|
|
|
|
|
|
|
|
> .name {
|
|
|
|
|
font-weight: bold;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
> .info {
|
|
|
|
|
margin-left: auto;
|
|
|
|
|
font-size: 0.9em;
|
|
|
|
|
|
|
|
|
|
> .time {
|
|
|
|
|
flex-shrink: 0;
|
|
|
|
|
color: inherit;
|
|
|
|
|
|
|
|
|
|
> .dropdownIcon {
|
|
|
|
|
margin-right: 4px;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
> .visibility {
|
|
|
|
|
margin-left: 8px;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
> .localOnly {
|
|
|
|
|
margin-left: 8px;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
> .renote + .article {
|
|
|
|
|
padding-top: 8px;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
> .article {
|
|
|
|
|
padding: 32px;
|
|
|
|
|
font-size: 1.1em;
|
|
|
|
|
|
|
|
|
|
> .header {
|
|
|
|
|
display: flex;
|
|
|
|
|
position: relative;
|
|
|
|
|
margin-bottom: 16px;
|
|
|
|
|
|
|
|
|
|
> .avatar {
|
|
|
|
|
display: block;
|
|
|
|
|
flex-shrink: 0;
|
|
|
|
|
width: 58px;
|
|
|
|
|
height: 58px;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
> .body {
|
|
|
|
|
flex: 1;
|
|
|
|
|
display: flex;
|
|
|
|
|
flex-direction: column;
|
|
|
|
|
justify-content: center;
|
|
|
|
|
padding-left: 16px;
|
2021-01-23 01:26:54 -07:00
|
|
|
|
font-size: 0.95em;
|
2021-01-01 06:41:20 -07:00
|
|
|
|
|
|
|
|
|
> .top {
|
|
|
|
|
> .name {
|
|
|
|
|
font-weight: bold;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
> .is-bot {
|
|
|
|
|
flex-shrink: 0;
|
|
|
|
|
align-self: center;
|
|
|
|
|
margin: 0 0.5em;
|
|
|
|
|
padding: 4px 6px;
|
|
|
|
|
font-size: 80%;
|
2021-04-09 21:40:50 -06:00
|
|
|
|
border: solid 0.5px var(--divider);
|
2021-01-01 06:41:20 -07:00
|
|
|
|
border-radius: 4px;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
> .main {
|
|
|
|
|
> .body {
|
|
|
|
|
> .cw {
|
|
|
|
|
cursor: default;
|
|
|
|
|
display: block;
|
|
|
|
|
margin: 0;
|
|
|
|
|
padding: 0;
|
|
|
|
|
overflow-wrap: break-word;
|
|
|
|
|
|
|
|
|
|
> .text {
|
|
|
|
|
margin-right: 8px;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
> .content {
|
|
|
|
|
> .text {
|
|
|
|
|
overflow-wrap: break-word;
|
|
|
|
|
|
|
|
|
|
> .reply {
|
|
|
|
|
color: var(--accent);
|
|
|
|
|
margin-right: 0.5em;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
> .rp {
|
|
|
|
|
margin-left: 4px;
|
|
|
|
|
font-style: oblique;
|
|
|
|
|
color: var(--renote);
|
|
|
|
|
}
|
2021-08-15 05:26:44 -06:00
|
|
|
|
|
|
|
|
|
> .translation {
|
|
|
|
|
border: solid 0.5px var(--divider);
|
|
|
|
|
border-radius: var(--radius);
|
|
|
|
|
padding: 12px;
|
|
|
|
|
margin-top: 8px;
|
|
|
|
|
}
|
2021-01-01 06:41:20 -07:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
> .url-preview {
|
|
|
|
|
margin-top: 8px;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
> .poll {
|
|
|
|
|
font-size: 80%;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
> .renote {
|
|
|
|
|
padding: 8px 0;
|
|
|
|
|
|
|
|
|
|
> * {
|
|
|
|
|
padding: 16px;
|
|
|
|
|
border: dashed 1px var(--renote);
|
|
|
|
|
border-radius: 8px;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
> .channel {
|
|
|
|
|
opacity: 0.7;
|
|
|
|
|
font-size: 80%;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
> .footer {
|
|
|
|
|
> .info {
|
|
|
|
|
margin: 16px 0;
|
|
|
|
|
opacity: 0.7;
|
|
|
|
|
font-size: 0.9em;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
> .button {
|
|
|
|
|
margin: 0;
|
|
|
|
|
padding: 8px;
|
|
|
|
|
opacity: 0.7;
|
|
|
|
|
|
|
|
|
|
&:not(:last-child) {
|
|
|
|
|
margin-right: 28px;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
&:hover {
|
|
|
|
|
color: var(--fgHighlighted);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
> .count {
|
|
|
|
|
display: inline;
|
|
|
|
|
margin: 0 0 0 8px;
|
|
|
|
|
opacity: 0.7;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
&.reacted {
|
|
|
|
|
color: var(--accent);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
> .reply {
|
2021-04-09 21:40:50 -06:00
|
|
|
|
border-top: solid 0.5px var(--divider);
|
2021-01-01 06:41:20 -07:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
&.max-width_500px {
|
|
|
|
|
font-size: 0.9em;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
&.max-width_450px {
|
|
|
|
|
> .renote {
|
|
|
|
|
padding: 8px 16px 0 16px;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
> .article {
|
|
|
|
|
padding: 16px;
|
|
|
|
|
|
|
|
|
|
> .header {
|
|
|
|
|
> .avatar {
|
|
|
|
|
width: 50px;
|
|
|
|
|
height: 50px;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
&.max-width_350px {
|
|
|
|
|
> .article {
|
|
|
|
|
> .main {
|
|
|
|
|
> .footer {
|
|
|
|
|
> .button {
|
|
|
|
|
&:not(:last-child) {
|
|
|
|
|
margin-right: 18px;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
&.max-width_300px {
|
|
|
|
|
font-size: 0.825em;
|
|
|
|
|
|
|
|
|
|
> .article {
|
|
|
|
|
> .header {
|
|
|
|
|
> .avatar {
|
|
|
|
|
width: 50px;
|
|
|
|
|
height: 50px;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
> .main {
|
|
|
|
|
> .footer {
|
|
|
|
|
> .button {
|
|
|
|
|
&:not(:last-child) {
|
|
|
|
|
margin-right: 12px;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.muted {
|
|
|
|
|
padding: 8px;
|
|
|
|
|
text-align: center;
|
|
|
|
|
opacity: 0.7;
|
|
|
|
|
}
|
|
|
|
|
</style>
|