Skip to content

Commit 5ea33e4

Browse files
committed
feat: add delete channel api
1 parent d356bbf commit 5ea33e4

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

src/offline_support_api.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,8 @@ export type DeleteMemberType = {
137137

138138
export type DeleteMessageType = { id: string; flush?: boolean };
139139

140+
export type DeleteChannelType = { cid: string; flush?: boolean };
141+
140142
export type ChannelExistsType = { cid: string };
141143

142144
export type ExecuteBatchQueriesType = PreparedBatchQueries[];
@@ -172,6 +174,7 @@ export interface OfflineDBApi {
172174
deletePendingTask: (options: DeletePendingTaskType) => Promise<ExecuteBatchQueriesType>;
173175
deleteReaction: (options: DeleteReactionType) => Promise<ExecuteBatchQueriesType>;
174176
deleteMember: (options: DeleteMemberType) => Promise<ExecuteBatchQueriesType>;
177+
deleteChannel: (options: DeleteChannelType) => Promise<ExecuteBatchQueriesType>;
175178
hardDeleteMessage: (options: DeleteMessageType) => Promise<ExecuteBatchQueriesType>;
176179
softDeleteMessage: (options: DeleteMessageType) => Promise<ExecuteBatchQueriesType>;
177180
resetDB: () => Promise<unknown>;
@@ -235,6 +238,8 @@ export abstract class AbstractOfflineDB implements OfflineDBApi {
235238

236239
abstract deleteMember: OfflineDBApi['deleteMember'];
237240

241+
abstract deleteChannel: OfflineDBApi['deleteChannel'];
242+
238243
abstract hardDeleteMessage: OfflineDBApi['hardDeleteMessage'];
239244

240245
abstract softDeleteMessage: OfflineDBApi['softDeleteMessage'];
@@ -253,7 +258,7 @@ export abstract class AbstractOfflineDB implements OfflineDBApi {
253258
if (!cid) {
254259
return await createQueries(flush);
255260
}
256-
const channelExists = this.channelExists({ cid });
261+
const channelExists = await this.channelExists({ cid });
257262
// a channel is not present in the db, we first fetch the channel data from the channel object.
258263
// this can happen for example when a message.new event is received for a channel that is not in the db due to a channel being hidden.
259264
if (!channelExists) {

0 commit comments

Comments
 (0)