summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAya Morisawa <AyaMorisawa4869@gmail.com>2018-12-27 22:54:50 +0900
committerAya Morisawa <AyaMorisawa4869@gmail.com>2018-12-27 22:54:50 +0900
commit6943c7d2d81625f479c3f8ea9955b5cedc72f786 (patch)
treebb6eab817440c31cc45b803be05755798abd5391 /src
parentFix kao (diff)
downloadsharkey-6943c7d2d81625f479c3f8ea9955b5cedc72f786.tar.gz
sharkey-6943c7d2d81625f479c3f8ea9955b5cedc72f786.tar.bz2
sharkey-6943c7d2d81625f479c3f8ea9955b5cedc72f786.zip
Resolve #3770
Co-authored-by: syuilo <syuilotan@yahoo.co.jp>
Diffstat (limited to 'src')
-rw-r--r--src/client/app/common/scripts/note-mixin.ts4
-rw-r--r--src/client/app/common/views/components/reactions-viewer.vue41
-rw-r--r--src/client/app/common/views/directives/particle.ts2
-rw-r--r--src/client/app/desktop/views/components/note-detail.vue16
-rw-r--r--src/client/app/desktop/views/components/note.vue4
-rw-r--r--src/client/app/mobile/views/components/note-detail.vue4
-rw-r--r--src/client/app/mobile/views/components/note.vue4
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 dea36cd2a5..39e23f94ea 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 a3c421bd34..8fa8ecfddd 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 @@
<template>
-<div class="mk-reactions-viewer">
+<div class="mk-reactions-viewer" :class="{ isMe }">
<template v-if="reactions">
- <span :class="{ reacted: note.myReaction == 'like' }" @click="toggleReaction('like')" v-if="reactions.like" v-particle><mk-reaction-icon reaction="like" ref="like"/><span>{{ reactions.like }}</span></span>
- <span :class="{ reacted: note.myReaction == 'love' }" @click="toggleReaction('love')" v-if="reactions.love" v-particle><mk-reaction-icon reaction="love" ref="love"/><span>{{ reactions.love }}</span></span>
- <span :class="{ reacted: note.myReaction == 'laugh' }" @click="toggleReaction('laugh')" v-if="reactions.laugh" v-particle><mk-reaction-icon reaction="laugh" ref="laugh"/><span>{{ reactions.laugh }}</span></span>
- <span :class="{ reacted: note.myReaction == 'hmm' }" @click="toggleReaction('hmm')" v-if="reactions.hmm" v-particle><mk-reaction-icon reaction="hmm" ref="hmm"/><span>{{ reactions.hmm }}</span></span>
- <span :class="{ reacted: note.myReaction == 'surprise' }" @click="toggleReaction('surprise')" v-if="reactions.surprise" v-particle><mk-reaction-icon reaction="surprise" ref="surprise"/><span>{{ reactions.surprise }}</span></span>
- <span :class="{ reacted: note.myReaction == 'congrats' }" @click="toggleReaction('congrats')" v-if="reactions.congrats" v-particle><mk-reaction-icon reaction="congrats" ref="congrats"/><span>{{ reactions.congrats }}</span></span>
- <span :class="{ reacted: note.myReaction == 'angry' }" @click="toggleReaction('angry')" v-if="reactions.angry" v-particle><mk-reaction-icon reaction="angry" ref="angry"/><span>{{ reactions.angry }}</span></span>
- <span :class="{ reacted: note.myReaction == 'confused' }" @click="toggleReaction('confused')" v-if="reactions.confused" v-particle><mk-reaction-icon reaction="confused" ref="confused"/><span>{{ reactions.confused }}</span></span>
- <span :class="{ reacted: note.myReaction == 'rip' }" @click="toggleReaction('rip')" v-if="reactions.rip" v-particle><mk-reaction-icon reaction="rip" ref="rip"/><span>{{ reactions.rip }}</span></span>
- <span :class="{ reacted: note.myReaction == 'pudding' }" @click="toggleReaction('pudding')" v-if="reactions.pudding" v-particle><mk-reaction-icon reaction="pudding" ref="pudding"/><span>{{ reactions.pudding }}</span></span>
+ <span :class="{ reacted: note.myReaction == 'like' }" @click="toggleReaction('like')" v-if="reactions.like" v-particle="!isMe"><mk-reaction-icon reaction="like" ref="like"/><span>{{ reactions.like }}</span></span>
+ <span :class="{ reacted: note.myReaction == 'love' }" @click="toggleReaction('love')" v-if="reactions.love" v-particle="!isMe"><mk-reaction-icon reaction="love" ref="love"/><span>{{ reactions.love }}</span></span>
+ <span :class="{ reacted: note.myReaction == 'laugh' }" @click="toggleReaction('laugh')" v-if="reactions.laugh" v-particle="!isMe"><mk-reaction-icon reaction="laugh" ref="laugh"/><span>{{ reactions.laugh }}</span></span>
+ <span :class="{ reacted: note.myReaction == 'hmm' }" @click="toggleReaction('hmm')" v-if="reactions.hmm" v-particle="!isMe"><mk-reaction-icon reaction="hmm" ref="hmm"/><span>{{ reactions.hmm }}</span></span>
+ <span :class="{ reacted: note.myReaction == 'surprise' }" @click="toggleReaction('surprise')" v-if="reactions.surprise" v-particle="!isMe"><mk-reaction-icon reaction="surprise" ref="surprise"/><span>{{ reactions.surprise }}</span></span>
+ <span :class="{ reacted: note.myReaction == 'congrats' }" @click="toggleReaction('congrats')" v-if="reactions.congrats" v-particle="!isMe"><mk-reaction-icon reaction="congrats" ref="congrats"/><span>{{ reactions.congrats }}</span></span>
+ <span :class="{ reacted: note.myReaction == 'angry' }" @click="toggleReaction('angry')" v-if="reactions.angry" v-particle="!isMe"><mk-reaction-icon reaction="angry" ref="angry"/><span>{{ reactions.angry }}</span></span>
+ <span :class="{ reacted: note.myReaction == 'confused' }" @click="toggleReaction('confused')" v-if="reactions.confused" v-particle="!isMe"><mk-reaction-icon reaction="confused" ref="confused"/><span>{{ reactions.confused }}</span></span>
+ <span :class="{ reacted: note.myReaction == 'rip' }" @click="toggleReaction('rip')" v-if="reactions.rip" v-particle="!isMe"><mk-reaction-icon reaction="rip" ref="rip"/><span>{{ reactions.rip }}</span></span>
+ <span :class="{ reacted: note.myReaction == 'pudding' }" @click="toggleReaction('pudding')" v-if="reactions.pudding" v-particle="!isMe"><mk-reaction-icon reaction="pudding" ref="pudding"/><span>{{ reactions.pudding }}</span></span>
</template>
</div>
</template>
@@ -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 0bb451e323..5f8413117f 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 bb30cd6a20..d0a625bc14 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 @@
<template v-else><fa icon="reply"/></template>
<p class="count" v-if="appearNote.repliesCount > 0">{{ appearNote.repliesCount }}</p>
</button>
- <button v-if="['public', 'home'].includes(appearNote.visibility)" class="renoteButton" @click="renote()" :title="$t('renote')">
- <fa icon="retweet"/><p class="count" v-if="appearNote.renoteCount > 0">{{ appearNote.renoteCount }}</p>
- </button>
- <button v-else class="inhibitedButton">
- <fa icon="ban"/>
- </button>
- <button class="reactionButton" :class="{ reacted: appearNote.myReaction != null }" @click="react()" ref="reactButton" :title="$t('add-reaction')">
- <fa icon="plus"/><p class="count" v-if="appearNote.reactions_count > 0">{{ appearNote.reactions_count }}</p>
+ <button v-if="['public', 'home'].includes(appearNote.visibility)" class="renoteButton" @click="renote()" :title="$t('renote')">
+ <fa icon="retweet"/><p class="count" v-if="appearNote.renoteCount > 0">{{ appearNote.renoteCount }}</p>
+ </button>
+ <button v-else class="inhibitedButton">
+ <fa icon="ban"/>
+ </button>
+ <button class="reactionButton" :class="{ reacted: appearNote.myReaction != null }" v-if="!isMyNote" @click="react()" ref="reactButton" :title="$t('add-reaction')">
+ <fa icon="plus"/>
</button>
<button @click="menu()" ref="menuButton">
<fa icon="ellipsis-h"/>
diff --git a/src/client/app/desktop/views/components/note.vue b/src/client/app/desktop/views/components/note.vue
index 880d9f8d91..2c8dccd496 100644
--- a/src/client/app/desktop/views/components/note.vue
+++ b/src/client/app/desktop/views/components/note.vue
@@ -53,8 +53,8 @@
<button v-else class="inhibitedButton">
<fa icon="ban"/>
</button>
- <button class="reactionButton" :class="{ reacted: appearNote.myReaction != null }" @click="react()" ref="reactButton" :title="$t('add-reaction')">
- <fa icon="plus"/><p class="count" v-if="appearNote.reactions_count > 0">{{ appearNote.reactions_count }}</p>
+ <button class="reactionButton" :class="{ reacted: appearNote.myReaction != null }" v-if="!isMyNote" @click="react()" ref="reactButton" :title="$t('add-reaction')">
+ <fa icon="plus"/>
</button>
<button @click="menu()" ref="menuButton">
<fa icon="ellipsis-h"/>
diff --git a/src/client/app/mobile/views/components/note-detail.vue b/src/client/app/mobile/views/components/note-detail.vue
index 4b062c8f14..e0ce26e194 100644
--- a/src/client/app/mobile/views/components/note-detail.vue
+++ b/src/client/app/mobile/views/components/note-detail.vue
@@ -72,8 +72,8 @@
<button v-else>
<fa icon="ban"/>
</button>
- <button :class="{ reacted: appearNote.myReaction != null }" @click="react()" ref="reactButton" :title="$t('title')">
- <fa icon="plus"/><p class="count" v-if="appearNote.reactions_count > 0">{{ appearNote.reactions_count }}</p>
+ <button :class="{ reacted: appearNote.myReaction != null }" @click="react()" v-if="!isMyNote" ref="reactButton" :title="$t('title')">
+ <fa icon="plus"/>
</button>
<button @click="menu()" ref="menuButton">
<fa icon="ellipsis-h"/>
diff --git a/src/client/app/mobile/views/components/note.vue b/src/client/app/mobile/views/components/note.vue
index 1815cff4f3..c0f0f49d59 100644
--- a/src/client/app/mobile/views/components/note.vue
+++ b/src/client/app/mobile/views/components/note.vue
@@ -49,8 +49,8 @@
<button v-else>
<fa icon="ban"/>
</button>
- <button :class="{ reacted: appearNote.myReaction != null }" @click="react()" ref="reactButton">
- <fa icon="plus"/><p class="count" v-if="appearNote.reactions_count > 0">{{ appearNote.reactions_count }}</p>
+ <button :class="{ reacted: appearNote.myReaction != null }" @click="react()" v-if="!isMyNote" ref="reactButton">
+ <fa icon="plus"/>
</button>
<button class="menu" @click="menu()" ref="menuButton">
<fa icon="ellipsis-h"/>