Skip to content

Commit f909bc3

Browse files
fix: make poll type optional on message response
1 parent ef21c10 commit f909bc3

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

src/channel_state.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -500,7 +500,7 @@ export class ChannelState<StreamChatGenerics extends ExtendableGenerics = Defaul
500500
if (message.poll_id !== pollVote.poll_id) return;
501501

502502
const updatedPoll = { ...poll };
503-
let ownVotes = [...(message.poll.own_votes || [])];
503+
let ownVotes = [...(message.poll?.own_votes || [])];
504504

505505
if (pollVote.user_id === this._channel.getClient().userID) {
506506
if (pollVote.option_id && poll.enforce_unique_vote) {
@@ -527,7 +527,7 @@ export class ChannelState<StreamChatGenerics extends ExtendableGenerics = Defaul
527527
if (message.poll_id !== pollVote.poll_id) return;
528528

529529
const updatedPoll = { ...poll };
530-
const ownVotes = [...(message.poll.own_votes || [])];
530+
const ownVotes = [...(message.poll?.own_votes || [])];
531531

532532
if (pollVote.user_id === this._channel.getClient().userID) {
533533
ownVotes.push(pollVote);
@@ -550,7 +550,7 @@ export class ChannelState<StreamChatGenerics extends ExtendableGenerics = Defaul
550550
if (message.poll_id !== pollVote.poll_id) return;
551551

552552
const updatedPoll = { ...poll };
553-
const ownVotes = [...(message.poll.own_votes || [])];
553+
const ownVotes = [...(message.poll?.own_votes || [])];
554554
if (pollVote.user_id === this._channel.getClient().userID) {
555555
const index = ownVotes.findIndex((vote) => vote.option_id === pollVote.option_id);
556556
if (index > -1) {

src/types.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -627,7 +627,7 @@ export type MessageResponse<
627627
export type MessageResponseBase<
628628
StreamChatGenerics extends ExtendableGenerics = DefaultGenerics
629629
> = MessageBase<StreamChatGenerics> & {
630-
poll: PollResponse<StreamChatGenerics>;
630+
poll?: PollResponse<StreamChatGenerics>;
631631
type: MessageLabel;
632632
args?: string;
633633
before_message_send_failed?: boolean;

0 commit comments

Comments
 (0)