From 6943c7d2d81625f479c3f8ea9955b5cedc72f786 Mon Sep 17 00:00:00 2001 From: Aya Morisawa Date: Thu, 27 Dec 2018 22:54:50 +0900 Subject: [PATCH] Resolve #3770 Co-authored-by: syuilo --- src/client/app/common/scripts/note-mixin.ts | 4 ++ .../views/components/reactions-viewer.vue | 41 +++++++++++++------ .../app/common/views/directives/particle.ts | 2 + .../desktop/views/components/note-detail.vue | 16 ++++---- .../app/desktop/views/components/note.vue | 4 +- .../mobile/views/components/note-detail.vue | 4 +- .../app/mobile/views/components/note.vue | 4 +- 7 files changed, 49 insertions(+), 26 deletions(-) diff --git a/src/client/app/common/scripts/note-mixin.ts b/src/client/app/common/scripts/note-mixin.ts index dea36cd2a..39e23f94e 100644 --- a/src/client/app/common/scripts/note-mixin.ts +++ b/src/client/app/common/scripts/note-mixin.ts @@ -65,6 +65,10 @@ export default (opts: Opts = {}) => ({ return this.isRenote ? this.note.renote : this.note; }, + isMyNote(): boolean { + return this.$store.getters.isSignedIn && (this.$store.state.i.id === this.appearNote.userId); + }, + reactionsCount(): number { return this.appearNote.reactionCounts ? sum(Object.values(this.appearNote.reactionCounts)) diff --git a/src/client/app/common/views/components/reactions-viewer.vue b/src/client/app/common/views/components/reactions-viewer.vue index a3c421bd3..8fa8ecfdd 100644 --- a/src/client/app/common/views/components/reactions-viewer.vue +++ b/src/client/app/common/views/components/reactions-viewer.vue @@ -1,16 +1,16 @@ @@ -21,10 +21,18 @@ import Icon from './reaction-icon.vue'; import * as anime from 'animejs'; export default Vue.extend({ - props: ['note'], + props: { + note: { + type: Object, + required: true + } + }, computed: { reactions(): any { return this.note.reactionCounts; + }, + isMe(): boolean { + return this.$store.getters.isSignedIn && (this.$store.state.i.id === this.note.userId); } }, watch: { @@ -61,6 +69,8 @@ export default Vue.extend({ }, methods: { toggleReaction(reaction: string) { + if (this.isMe) return; + const oldReaction = this.note.myReaction; if (oldReaction) { this.$root.api('notes/reactions/delete', { @@ -128,6 +138,13 @@ export default Vue.extend({ &:empty display none + &.isMe + > span + cursor default !important + + &:hover + background var(--reactionViewerButtonBg) !important + > span display inline-block height 32px diff --git a/src/client/app/common/views/directives/particle.ts b/src/client/app/common/views/directives/particle.ts index 0bb451e32..5f8413117 100644 --- a/src/client/app/common/views/directives/particle.ts +++ b/src/client/app/common/views/directives/particle.ts @@ -5,6 +5,8 @@ export default { if (vn.context.$store.state.device.reduceMotion) return; el.addEventListener('click', () => { + if (binding.value === false) return; + const rect = el.getBoundingClientRect(); const x = rect.left + (el.clientWidth / 2); diff --git a/src/client/app/desktop/views/components/note-detail.vue b/src/client/app/desktop/views/components/note-detail.vue index bb30cd6a2..d0a625bc1 100644 --- a/src/client/app/desktop/views/components/note-detail.vue +++ b/src/client/app/desktop/views/components/note-detail.vue @@ -70,14 +70,14 @@

{{ appearNote.repliesCount }}

- - - + + - - -