Skip to content

Commit

Permalink
Fix: Remove Keys that are Empty (#190)
Browse files Browse the repository at this point in the history
* remove keys that are empty

* formatting

* More clear variable name
  • Loading branch information
tance77 authored Nov 26, 2024
1 parent 93ad9f2 commit 7539ab6
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion lib/src/entities/message.ts
Original file line number Diff line number Diff line change
Expand Up @@ -127,9 +127,17 @@ export class Message {
const newActions = this.actions || {}
newActions[type] ||= {}
newActions[type][value] ||= []
newActions[type][value] = newActions[type][value].filter(
const updatedActions = newActions[type][value].filter(
(r) => r.actionTimetoken !== actionTimetoken || r.uuid !== uuid
)

// Don't have an object with a key that is empty specifically for reactions like emojis
if (updatedActions.length === 0) {
delete newActions[type][value]
} else {
newActions[type][value] = updatedActions
}

return newActions
}

Expand Down

0 comments on commit 7539ab6

Please sign in to comment.