Skip to content

Commit abb1b3a

Browse files
committed
fix: drafts messages in channel without parent id
1 parent 9d85db5 commit abb1b3a

File tree

2 files changed

+15
-3
lines changed

2 files changed

+15
-3
lines changed

examples/TypeScriptMessaging/App.tsx

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ type ChannelScreenProps = {
104104
const EmptyHeader = () => <></>;
105105

106106
const ChannelScreen: React.FC<ChannelScreenProps> = ({ navigation }) => {
107-
const { channel, setThread } = useContext(AppContext);
107+
const { channel, setThread, thread } = useContext(AppContext);
108108
const headerHeight = useHeaderHeight();
109109
const { overlay } = useOverlayContext();
110110

@@ -120,7 +120,12 @@ const ChannelScreen: React.FC<ChannelScreenProps> = ({ navigation }) => {
120120

121121
return (
122122
<SafeAreaView>
123-
<Channel audioRecordingEnabled={true} channel={channel} keyboardVerticalOffset={headerHeight}>
123+
<Channel
124+
audioRecordingEnabled={true}
125+
channel={channel}
126+
keyboardVerticalOffset={headerHeight}
127+
thread={thread}
128+
>
124129
<View style={{ flex: 1 }}>
125130
<MessageList
126131
onThreadSelect={(selectedThread) => {

package/src/store/apis/getDraftsForChannels.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,16 @@ export const getDraftForChannels = async ({
2020

2121
const rows = await SqliteClient.executeSql.apply(null, query);
2222

23+
/**
24+
* Filter out drafts without a parent ID, as we will not show them in the channel.
25+
* The above `createSelectQuery` was not able to filter out drafts without a parent ID.
26+
* TODO: Fix the query to filter out drafts without a parent ID. This can be a bit faster.
27+
*/
28+
const rowsWithoutParentID = rows.filter((row) => row.parentId === null);
29+
2330
const cidVsDrafts: Record<string, DraftResponse> = {};
2431

25-
for (const row of rows) {
32+
for (const row of rowsWithoutParentID) {
2633
const draftMessageQuery = createSelectQuery('draftMessage', ['*'], {
2734
id: row.draftMessageId,
2835
});

0 commit comments

Comments
 (0)