Skip to content

Commit 0b1b773

Browse files
committed
fix: check for message in undefined message draft
1 parent e872576 commit 0b1b773

File tree

3 files changed

+8
-3
lines changed

3 files changed

+8
-3
lines changed

src/channel.ts

+3-1
Original file line numberDiff line numberDiff line change
@@ -1367,7 +1367,9 @@ export class Channel {
13671367

13681368
this.getClient().polls.hydratePollCache(state.messages, true);
13691369

1370-
this.messageComposer.initState({ composition: state.draft });
1370+
if (state.draft) {
1371+
this.messageComposer.initState({ composition: state.draft });
1372+
}
13711373

13721374
const areCapabilitiesChanged =
13731375
[...(state.channel.own_capabilities || [])].sort().join() !==

src/client.ts

+4-1
Original file line numberDiff line numberDiff line change
@@ -1826,7 +1826,10 @@ export class StreamChat {
18261826
};
18271827
this.polls.hydratePollCache(channelState.messages, true);
18281828
}
1829-
c.messageComposer.initState({ composition: channelState.draft });
1829+
1830+
if (channelState.draft) {
1831+
c.messageComposer.initState({ composition: channelState.draft });
1832+
}
18301833

18311834
channels.push(c);
18321835
}

src/messageComposer/messageComposer.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ export type MessageComposerOptions = {
4040
};
4141

4242
const isMessageDraft = (composition: unknown): composition is DraftResponse =>
43-
!!(composition as { message?: DraftMessage }).message;
43+
!!(composition as { message?: DraftMessage })?.message;
4444

4545
const initState = (
4646
composition?: DraftResponse | MessageResponse | FormatMessageResponse,

0 commit comments

Comments
 (0)