Skip to content

Commit

Permalink
feat: pending messages in channel state (#1023)
Browse files Browse the repository at this point in the history
  • Loading branch information
miagilepner committed Aug 3, 2022
1 parent 1db90fe commit 252c6e3
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/channel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1407,6 +1407,9 @@ export class Channel<StreamChatGenerics extends ExtendableGenerics = DefaultGene
this.state.pinnedMessages = [];
}
this.state.addPinnedMessages(state.pinned_messages || []);
if (state.pending_messages) {
this.state.pending_messages = state.pending_messages;
}
this.state.watcher_count = state.watcher_count || 0;
// convert the arrays into objects for easier syncing...
if (state.watchers) {
Expand Down
3 changes: 3 additions & 0 deletions src/channel_state.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import {
MessageResponse,
ReactionResponse,
UserResponse,
PendingMessageResponse,
} from './types';

type ChannelReadStatus<StreamChatGenerics extends ExtendableGenerics = DefaultGenerics> = Record<
Expand All @@ -26,6 +27,7 @@ export class ChannelState<StreamChatGenerics extends ExtendableGenerics = Defaul
typing: Record<string, Event<StreamChatGenerics>>;
read: ChannelReadStatus<StreamChatGenerics>;
pinnedMessages: Array<ReturnType<ChannelState<StreamChatGenerics>['formatMessage']>>;
pending_messages: Array<PendingMessageResponse<StreamChatGenerics>>;
threads: Record<string, Array<ReturnType<ChannelState<StreamChatGenerics>['formatMessage']>>>;
mutedUsers: Array<UserResponse<StreamChatGenerics>>;
watchers: Record<string, UserResponse<StreamChatGenerics>>;
Expand Down Expand Up @@ -58,6 +60,7 @@ export class ChannelState<StreamChatGenerics extends ExtendableGenerics = Defaul
this.read = {};
this.initMessages();
this.pinnedMessages = [];
this.pending_messages = [];
this.threads = {};
// a list of users to hide messages from
this.mutedUsers = [];
Expand Down

0 comments on commit 252c6e3

Please sign in to comment.