Skip to content

Commit ca10b36

Browse files
committed
feat: move message deleting to llc completely
1 parent 5934018 commit ca10b36

File tree

2 files changed

+16
-6
lines changed

2 files changed

+16
-6
lines changed

package/src/components/Chat/hooks/handleEventToSyncDB.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ export const handleEventToSyncDB = async (event: Event, client: StreamChat, flus
146146
// }
147147
// }
148148

149-
if (type === 'message.updated' || type === 'message.deleted') {
149+
if (type === 'message.updated') {
150150
const message = event.message;
151151
if (message && !message.parent_id) {
152152
// Update only if it exists, otherwise event could be related

package/src/store/apis/deleteMessage.ts

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,28 @@ import { createDeleteQuery } from '../sqlite-utils/createDeleteQuery';
22
import { SqliteClient } from '../SqliteClient';
33

44
export const deleteMessage = async ({ flush = true, id }: { id: string; flush?: boolean }) => {
5-
const query = createDeleteQuery('messages', {
6-
id,
7-
});
5+
const queries = [];
6+
7+
queries.push(
8+
createDeleteQuery('reactions', {
9+
messageId: id,
10+
}),
11+
);
12+
13+
queries.push(
14+
createDeleteQuery('messages', {
15+
id,
16+
}),
17+
);
818

919
SqliteClient.logger?.('info', 'deleteMessage', {
1020
flush,
1121
id,
1222
});
1323

1424
if (flush) {
15-
await SqliteClient.executeSql.apply(null, query);
25+
await SqliteClient.executeSqlBatch(queries);
1626
}
1727

18-
return [query];
28+
return queries;
1929
};

0 commit comments

Comments
 (0)