Skip to content

Commit 7539ab6

Browse files
authored
Fix: Remove Keys that are Empty (#190)
* remove keys that are empty * formatting * More clear variable name
1 parent 93ad9f2 commit 7539ab6

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

lib/src/entities/message.ts

+9-1
Original file line numberDiff line numberDiff line change
@@ -127,9 +127,17 @@ export class Message {
127127
const newActions = this.actions || {}
128128
newActions[type] ||= {}
129129
newActions[type][value] ||= []
130-
newActions[type][value] = newActions[type][value].filter(
130+
const updatedActions = newActions[type][value].filter(
131131
(r) => r.actionTimetoken !== actionTimetoken || r.uuid !== uuid
132132
)
133+
134+
// Don't have an object with a key that is empty specifically for reactions like emojis
135+
if (updatedActions.length === 0) {
136+
delete newActions[type][value]
137+
} else {
138+
newActions[type][value] = updatedActions
139+
}
140+
133141
return newActions
134142
}
135143

0 commit comments

Comments
 (0)