diff options
| author | Johann150 <johann.galle@protonmail.com> | 2021-11-12 15:15:14 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-11-12 23:15:14 +0900 |
| commit | 0e3213ff6dea77bff64bee2f46cde49ef80dafe4 (patch) | |
| tree | e362f77fa450c489337e325504d2dd5b4568ce8a /packages/client/src/components/note.vue | |
| parent | refactoring (diff) | |
| download | sharkey-0e3213ff6dea77bff64bee2f46cde49ef80dafe4.tar.gz sharkey-0e3213ff6dea77bff64bee2f46cde49ef80dafe4.tar.bz2 sharkey-0e3213ff6dea77bff64bee2f46cde49ef80dafe4.zip | |
enhance: show renoters (#7954)
* refactor: deduplicate renote button into component
For now the renoters tooltip just uses the reaction viewer component
with a fixed emoji symbol instead.
* chore: remove unnecessary CSS
* fix: forgot to rename variable
* enhance: use own tooltip instead of reaction viewer
* clean up style
* fix additional renoters number
* rename file to better represent content
Diffstat (limited to 'packages/client/src/components/note.vue')
| -rw-r--r-- | packages/client/src/components/note.vue | 63 |
1 files changed, 16 insertions, 47 deletions
diff --git a/packages/client/src/components/note.vue b/packages/client/src/components/note.vue index b1ec674b67..19486c4dff 100644 --- a/packages/client/src/components/note.vue +++ b/packages/client/src/components/note.vue @@ -78,12 +78,7 @@ <template v-else><i class="fas fa-reply"></i></template> <p class="count" v-if="appearNote.repliesCount > 0">{{ appearNote.repliesCount }}</p> </button> - <button v-if="canRenote" @click="renote()" class="button _button" ref="renoteButton"> - <i class="fas fa-retweet"></i><p class="count" v-if="appearNote.renoteCount > 0">{{ appearNote.renoteCount }}</p> - </button> - <button v-else class="button _button"> - <i class="fas fa-ban"></i> - </button> + <XRenoteButton :note="appearNote" :count="appearNote.renoteCount" ref="renoteButton"/> <button v-if="appearNote.myReaction == null" class="button _button" @click="react()" ref="reactButton"> <i class="fas fa-plus"></i> </button> @@ -119,16 +114,17 @@ import XReactionsViewer from './reactions-viewer.vue'; import XMediaList from './media-list.vue'; import XCwButton from './cw-button.vue'; import XPoll from './poll.vue'; -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'; -import * as os from '@/os'; -import { noteActions, noteViewInterruptors } from '@/store'; -import { reactionPicker } from '@/scripts/reaction-picker'; -import { extractUrlFromMfm } from '@/scripts/extract-url-from-mfm'; +import XRenoteButton from './renote-button.vue'; +import { pleaseLogin } from '@client/scripts/please-login'; +import { focusPrev, focusNext } from '@client/scripts/focus'; +import { url } from '@client/config'; +import copyToClipboard from '@client/scripts/copy-to-clipboard'; +import { checkWordMute } from '@client/scripts/check-word-mute'; +import { userPage } from '@client/filters/user'; +import * as os from '@client/os'; +import { noteActions, noteViewInterruptors } from '@client/store'; +import { reactionPicker } from '@client/scripts/reaction-picker'; +import { extractUrlFromMfm } from '@/misc/extract-url-from-mfm'; export default defineComponent({ components: { @@ -139,8 +135,9 @@ export default defineComponent({ XMediaList, XCwButton, XPoll, - MkUrlPreview: defineAsyncComponent(() => import('@/components/url-preview.vue')), - MkInstanceTicker: defineAsyncComponent(() => import('@/components/instance-ticker.vue')), + XRenoteButton, + MkUrlPreview: defineAsyncComponent(() => import('@client/components/url-preview.vue')), + MkInstanceTicker: defineAsyncComponent(() => import('@client/components/instance-ticker.vue')), }, inject: { @@ -184,7 +181,7 @@ export default defineComponent({ return { 'r': () => this.reply(true), 'e|a|plus': () => this.react(true), - 'q': () => this.renote(true), + 'q': () => this.$refs.renoteButton.renote(true), 'f|b': this.favorite, 'delete|ctrl+d': this.del, 'ctrl+q': this.renoteDirectly, @@ -225,10 +222,6 @@ export default defineComponent({ return this.$i && (this.$i.id === this.note.userId); }, - canRenote(): boolean { - return ['public', 'home'].includes(this.appearNote.visibility) || this.isMyNote; - }, - reactionsCount(): number { return this.appearNote.reactions ? sum(Object.values(this.appearNote.reactions)) @@ -435,30 +428,6 @@ export default defineComponent({ }); }, - renote(viaKeyboard = false) { - pleaseLogin(); - this.blur(); - os.popupMenu([{ - text: this.$ts.renote, - icon: 'fas fa-retweet', - action: () => { - os.api('notes/create', { - renoteId: this.appearNote.id - }); - } - }, { - text: this.$ts.quote, - icon: 'fas fa-quote-right', - action: () => { - os.post({ - renote: this.appearNote, - }); - } - }], this.$refs.renoteButton, { - viaKeyboard - }); - }, - renoteDirectly() { os.apiWithDialog('notes/create', { renoteId: this.appearNote.id |