Skip to content

Commit 6421a45

Browse files
committed
fix: avoid upserting faulty channel
1 parent 8b1e40d commit 6421a45

File tree

1 file changed

+8
-12
lines changed

1 file changed

+8
-12
lines changed

package/src/components/Channel/Channel.tsx

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1305,7 +1305,7 @@ const ChannelWithContext = (props: PropsWithChildren<ChannelPropsWithContext>) =
13051305
db.updateMessage({
13061306
message: { ...updatedMessage, cid: channel.cid },
13071307
}),
1308-
{ method: 'upsertAppSettings' },
1308+
{ method: 'updateMessage' },
13091309
);
13101310
}
13111311

@@ -1330,7 +1330,7 @@ const ChannelWithContext = (props: PropsWithChildren<ChannelPropsWithContext>) =
13301330
db.updateMessage({
13311331
message: { ...updatedMessage, cid: channel.cid },
13321332
}),
1333-
{ method: 'upsertAppSettings' },
1333+
{ method: 'updateMessage' },
13341334
);
13351335
}
13361336
}
@@ -1368,7 +1368,7 @@ const ChannelWithContext = (props: PropsWithChildren<ChannelPropsWithContext>) =
13681368
db.updateMessage({
13691369
message: updatedMessage,
13701370
}),
1371-
{ method: 'upsertAppSettings' },
1371+
{ method: 'updateMessage' },
13721372
);
13731373

13741374
failedMessageUpdated = true;
@@ -1412,7 +1412,7 @@ const ChannelWithContext = (props: PropsWithChildren<ChannelPropsWithContext>) =
14121412
db.updateMessage({
14131413
message: { ...newMessageResponse, cid: channel.cid },
14141414
}),
1415-
{ method: 'upsertAppSettings' },
1415+
{ method: 'updateMessage' },
14161416
);
14171417

14181418
if (retrying) {
@@ -1443,16 +1443,12 @@ const ChannelWithContext = (props: PropsWithChildren<ChannelPropsWithContext>) =
14431443
// then user can see that message in failed state and can retry.
14441444
// If succesfull, it will be updated with received status.
14451445
client.offlineDb?.executeQuerySafely(
1446-
async (db) => {
1447-
if (channel.data) {
1448-
await db.upsertChannelData({ channel: channel.data as unknown as ChannelResponse });
1449-
}
1450-
await db.upsertMessages({
1446+
(db) =>
1447+
db.upsertMessages({
14511448
// @ts-ignore
14521449
messages: [{ ...localMessage, cid: channel.cid, status: MessageStatusTypes.FAILED }],
1453-
});
1454-
},
1455-
{ method: 'upsertAppSettings' },
1450+
}),
1451+
{ method: 'upsertMessages' },
14561452
);
14571453

14581454
await sendMessageRequest({ localMessage, message, options });

0 commit comments

Comments
 (0)