Skip to content

Commit 6eb02c5

Browse files
authored
Merge pull request #11586 from nextcloud/fix/11585/follow-up-all-reactions-button
Fix/11585/follow up all reactions button
2 parents db77116 + 6edead4 commit 6eb02c5

File tree

3 files changed

+31
-20
lines changed

3 files changed

+31
-20
lines changed

Diff for: src/components/MessagesList/MessagesGroup/Message/Message.vue

+1
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@
4646
:id="id"
4747
:token="token"
4848
:can-react="canReact"
49+
:show-controls="isHovered || isFollowUpEmojiPickerOpen"
4950
@emoji-picker-toggled="toggleFollowUpEmojiPicker" />
5051
</div>
5152

Diff for: src/components/MessagesList/MessagesGroup/Message/MessagePart/Reactions.spec.js

+10-7
Original file line numberDiff line numberDiff line change
@@ -157,10 +157,10 @@ describe('Reactions.vue', () => {
157157
// Assert
158158
expect(showError).toHaveBeenCalled()
159159
expect(emojiPicker).toHaveLength(0)
160-
expect(reactionButtons).toHaveLength(4) // "All" + "🎄" + "🔥" + "🔒" buttons
161-
expect(reactionButtons.at(1).text()).toBe('🎄 2')
162-
expect(reactionButtons.at(2).text()).toBe('🔥 2')
163-
expect(reactionButtons.at(3).text()).toBe('🔒 2')
160+
expect(reactionButtons).toHaveLength(3) // "🎄" + "🔥" + "🔒" buttons
161+
expect(reactionButtons.at(0).text()).toBe('🎄 2')
162+
expect(reactionButtons.at(1).text()).toBe('🔥 2')
163+
expect(reactionButtons.at(2).text()).toBe('🔒 2')
164164
})
165165

166166
test('doesn\'t mount emoji picker when there are no reactions', () => {
@@ -203,7 +203,10 @@ describe('Reactions.vue', () => {
203203
vuexStore.dispatch('processMessage', { token, message })
204204

205205
const wrapper = shallowMount(Reactions, {
206-
propsData: reactionsProps,
206+
propsData: {
207+
...reactionsProps,
208+
showControls: true,
209+
},
207210
localVue,
208211
store,
209212
stubs: {
@@ -255,8 +258,8 @@ describe('Reactions.vue', () => {
255258

256259
// Act
257260
const reactionButtons = wrapper.findAllComponents(NcButton)
258-
reactionButtons.at(1).vm.$emit('click') // 🎄
259-
reactionButtons.at(2).vm.$emit('click') // 🔥
261+
reactionButtons.at(0).vm.$emit('click') // 🎄
262+
reactionButtons.at(1).vm.$emit('click') // 🔥
260263

261264
// Assert
262265
expect(reactionsStore.addReactionToMessage).toHaveBeenCalledWith({

Diff for: src/components/MessagesList/MessagesGroup/Message/MessagePart/Reactions.vue

+20-13
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,6 @@
2323
<template>
2424
<!-- reactions buttons and popover with details -->
2525
<div class="reactions-wrapper">
26-
<!-- all reactions button -->
27-
<NcButton class="reaction-button"
28-
:title="t('spreed', 'Show all reactions')"
29-
@click="showAllReactions = true">
30-
<HeartOutlineIcon :size="15" />
31-
</NcButton>
3226
<NcPopover v-for="reaction in reactionsSorted"
3327
:key="reaction"
3428
:delay="200"
@@ -44,7 +38,7 @@
4438
</NcButton>
4539
</template>
4640

47-
<div v-if="hasReactions" class="reaction-details">
41+
<div v-if="hasReactionsLoaded" class="reaction-details">
4842
<span>{{ getReactionSummary(reaction) }}</span>
4943
<NcButton v-if="reactionsCount(reaction) > 3"
5044
type="tertiary-no-background"
@@ -57,8 +51,16 @@
5751
</div>
5852
</NcPopover>
5953

54+
<!-- all reactions button -->
55+
<NcButton v-if="showControls"
56+
class="reaction-button"
57+
:title="t('spreed', 'Show all reactions')"
58+
@click="showAllReactions = true">
59+
<HeartOutlineIcon :size="15" />
60+
</NcButton>
61+
6062
<!-- More reactions picker -->
61-
<NcEmojiPicker v-if="canReact && hasReactions"
63+
<NcEmojiPicker v-if="canReact && showControls"
6264
:per-line="5"
6365
:container="`#message_${id}`"
6466
@select="handleReactionClick"
@@ -73,7 +75,7 @@
7375
</NcButton>
7476
</NcEmojiPicker>
7577

76-
<!-- all reactions -->
78+
<!-- all reactions modal-->
7779
<ReactionsList v-if="showAllReactions"
7880
:token="token"
7981
:detailed-reactions="detailedReactions"
@@ -131,6 +133,11 @@ export default {
131133
type: [String, Number],
132134
required: true,
133135
},
136+
137+
showControls: {
138+
type: Boolean,
139+
default: false,
140+
},
134141
},
135142

136143
emits: ['emoji-picker-toggled'],
@@ -151,7 +158,7 @@ export default {
151158
},
152159

153160
computed: {
154-
hasReactions() {
161+
hasReactionsLoaded() {
155162
return Object.keys(Object(this.detailedReactions)).length !== 0
156163
},
157164

@@ -184,14 +191,14 @@ export default {
184191
.sort() // Plain reactions come sorted
185192
.map(([key, value]) => [key, value.length])
186193
)
187-
return this.hasReactions
194+
return this.hasReactionsLoaded
188195
&& JSON.stringify(this.plainReactions) !== JSON.stringify(detailedReactionsSimplified)
189196
},
190197
},
191198

192199
methods: {
193200
fetchReactions() {
194-
if (!this.hasReactions || this.hasOutdatedDetails) {
201+
if (!this.hasReactionsLoaded || this.hasOutdatedDetails) {
195202
this.reactionsStore.fetchReactions(this.token, this.id)
196203
}
197204
},
@@ -243,7 +250,7 @@ export default {
243250

244251
getReactionSummary(reaction) {
245252
// Check if the reaction details are loaded
246-
if (!this.hasReactions) {
253+
if (!this.hasReactionsLoaded) {
247254
return ''
248255
}
249256
const list = this.detailedReactions[reaction].slice(0, 3)

0 commit comments

Comments
 (0)