Merge pull request #7061 from nextcloud/bugfix/noid/fix-user-has-reacted

Fix detection if the user (not author) reacted already
This commit is contained in:
Marco 2022-03-29 14:31:49 +02:00 коммит произвёл GitHub
Родитель 16d3ac179e 19a6916d0d
Коммит 95001fd9a5
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
3 изменённых файлов: 4 добавлений и 4 удалений

Просмотреть файл

@ -656,7 +656,7 @@ export default {
await this.getReactions()
}
// Check if current user has already added this reaction to the message
const currentUserHasReacted = this.$store.getters.userHasReacted(this.actorId, this.token, this.id, clickedEmoji)
const currentUserHasReacted = this.$store.getters.userHasReacted(this.$store.getters.getActorType(), this.$store.getters.getActorId(), this.token, this.id, clickedEmoji)
if (!currentUserHasReacted) {
this.$store.dispatch('addReactionToMessage', {

Просмотреть файл

@ -404,7 +404,7 @@ export default {
handleReactionClick(selectedEmoji) {
// Add reaction only if user hasn't reacted yet
if (!this.$store.getters.userHasReacted(this.actorId, this.token, this.messageObject.id, selectedEmoji)) {
if (!this.$store.getters.userHasReacted(this.$store.getters.getActorType(), this.$store.getters.getActorId(), this.token, this.messageObject.id, selectedEmoji)) {
this.$store.dispatch('addReactionToMessage', {
token: this.token,
messageId: this.messageObject.id,

Просмотреть файл

@ -42,12 +42,12 @@ const getters = {
},
// Checks if a user has already reacted to a message with a particular reaction
userHasReacted: (state) => (actorId, token, messageId, reaction) => {
userHasReacted: (state) => (actorType, actorId, token, messageId, reaction) => {
if (!state?.reactions?.[token]?.[messageId]?.[reaction]) {
return false
}
return state?.reactions?.[token]?.[messageId]?.[reaction].filter(item => {
return item.actorId === actorId
return item.actorType === actorType && item.actorId === actorId
}).length !== 0
},
}