Skip to content

Commit deec2f1

Browse files
committed
fix: pending tasks type
1 parent ee06fc3 commit deec2f1

File tree

1 file changed

+9
-11
lines changed

1 file changed

+9
-11
lines changed

src/offline_support_api.ts

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -145,11 +145,11 @@ export abstract class AbstractOfflineDB implements OfflineDBApi {
145145
return await this.client._deleteMessage(...task.payload);
146146
}
147147

148-
const channel = this.client.channel(task.channelType, task.channelId);
149-
150148
const { channelType, channelId } = task;
151149

152150
if (channelType && channelId) {
151+
const channel = this.client.channel(channelType, channelId);
152+
153153
if (task.type === 'send-reaction') {
154154
return await channel._sendReaction(...task.payload);
155155
}
@@ -212,27 +212,25 @@ export type PendingTaskTypes = {
212212
sendReaction: 'send-reaction';
213213
};
214214

215-
export type PendingTaskChannelCommonType = {
216-
channelId: string;
217-
channelType: string;
218-
};
219-
215+
// TODO: Please rethink the definition of PendingTasks as it seems awkward
220216
export type PendingTask = {
217+
channelId?: string;
218+
channelType?: string;
221219
messageId: string;
222220
id?: number;
223221
} & (
224-
| (PendingTaskChannelCommonType & {
222+
| {
225223
payload: Parameters<Channel['sendReaction']>;
226224
type: PendingTaskTypes['sendReaction'];
227-
})
225+
}
228226
| {
229227
payload: Parameters<StreamChat['deleteMessage']>;
230228
type: PendingTaskTypes['deleteMessage'];
231229
}
232-
| (PendingTaskChannelCommonType & {
230+
| {
233231
payload: Parameters<Channel['deleteReaction']>;
234232
type: PendingTaskTypes['deleteReaction'];
235-
})
233+
}
236234
);
237235

238236
/**

0 commit comments

Comments
 (0)