stream-chat
Advanced tools
Comparing version 8.43.0 to 8.44.0
/// <reference types="node" /> | ||
import { ChannelState } from './channel_state'; | ||
import { StreamChat } from './client'; | ||
import { APIResponse, BanUserOptions, ChannelAPIResponse, ChannelData, ChannelMemberAPIResponse, ChannelMemberResponse, ChannelQueryOptions, ChannelResponse, ChannelUpdateOptions, CreateCallOptions, CreateCallResponse, DefaultGenerics, DeleteChannelAPIResponse, Event, EventAPIResponse, EventHandler, EventTypes, ExtendableGenerics, FormatMessageResponse, GetMultipleMessagesAPIResponse, GetReactionsAPIResponse, GetRepliesAPIResponse, InviteOptions, MarkReadOptions, MarkUnreadOptions, MemberSort, Message, MessageFilters, MessagePaginationOptions, MessageResponse, MessageSetType, MuteChannelAPIResponse, PartialUpdateChannel, PartialUpdateChannelAPIResponse, PartialUpdateMember, PinnedMessagePaginationOptions, PinnedMessagesSort, QueryMembersOptions, Reaction, ReactionAPIResponse, SearchAPIResponse, SearchOptions, SendMessageAPIResponse, TruncateChannelAPIResponse, TruncateOptions, UpdateChannelAPIResponse, UserFilters, UserResponse, QueryChannelAPIResponse, PollVoteData, SendMessageOptions, AscDesc, PartialUpdateMemberAPIResponse } from './types'; | ||
import { APIResponse, BanUserOptions, ChannelAPIResponse, ChannelData, ChannelMemberAPIResponse, ChannelMemberResponse, ChannelQueryOptions, ChannelResponse, ChannelUpdateOptions, CreateCallOptions, CreateCallResponse, DefaultGenerics, DeleteChannelAPIResponse, Event, EventAPIResponse, EventHandler, EventTypes, ExtendableGenerics, FormatMessageResponse, GetMultipleMessagesAPIResponse, GetReactionsAPIResponse, GetRepliesAPIResponse, InviteOptions, MarkReadOptions, MarkUnreadOptions, MemberFilters, MemberSort, Message, MessageFilters, MessagePaginationOptions, MessageResponse, MessageSetType, MuteChannelAPIResponse, NewMemberPayload, PartialUpdateChannel, PartialUpdateChannelAPIResponse, PartialUpdateMember, PinnedMessagePaginationOptions, PinnedMessagesSort, QueryMembersOptions, Reaction, ReactionAPIResponse, SearchAPIResponse, SearchOptions, SendMessageAPIResponse, TruncateChannelAPIResponse, TruncateOptions, UpdateChannelAPIResponse, UserResponse, QueryChannelAPIResponse, PollVoteData, SendMessageOptions, AscDesc, PartialUpdateMemberAPIResponse } from './types'; | ||
import { Role } from './permissions'; | ||
@@ -106,3 +106,3 @@ /** | ||
* | ||
* @param {UserFilters<StreamChatGenerics>} filterConditions object MongoDB style filters | ||
* @param {MemberFilters<StreamChatGenerics>} filterConditions object MongoDB style filters | ||
* @param {MemberSort<StreamChatGenerics>} [sort] Sort options, for instance [{created_at: -1}]. | ||
@@ -114,3 +114,3 @@ * When using multiple fields, make sure you use array of objects to guarantee field order, for instance [{name: -1}, {created_at: 1}] | ||
*/ | ||
queryMembers(filterConditions: UserFilters<StreamChatGenerics>, sort?: MemberSort<StreamChatGenerics>, options?: QueryMembersOptions): Promise<ChannelMemberAPIResponse<StreamChatGenerics>>; | ||
queryMembers(filterConditions: MemberFilters<StreamChatGenerics>, sort?: MemberSort<StreamChatGenerics>, options?: QueryMembersOptions): Promise<ChannelMemberAPIResponse<StreamChatGenerics>>; | ||
/** | ||
@@ -124,3 +124,3 @@ * partialUpdateMember - Partial update a member | ||
*/ | ||
partialUpdateMember(user_id: string, updates: PartialUpdateMember): Promise<PartialUpdateMemberAPIResponse<StreamChatGenerics>>; | ||
partialUpdateMember(user_id: string, updates: PartialUpdateMember<StreamChatGenerics>): Promise<PartialUpdateMemberAPIResponse<StreamChatGenerics>>; | ||
/** | ||
@@ -214,3 +214,3 @@ * sendReaction - Send a reaction about a message | ||
* | ||
* @param {{user_id: string, channel_role?: Role}[]} members An array of members to add to the channel | ||
* @param {string[] | Array<NewMemberPayload<StreamChatGenerics>>} members An array of members to add to the channel | ||
* @param {Message<StreamChatGenerics>} [message] Optional message object for channel members notification | ||
@@ -220,6 +220,3 @@ * @param {ChannelUpdateOptions} [options] Option object, configuration to control the behavior while updating | ||
*/ | ||
addMembers(members: string[] | { | ||
user_id: string; | ||
channel_role?: Role; | ||
}[], message?: Message<StreamChatGenerics>, options?: ChannelUpdateOptions): Promise<UpdateChannelAPIResponse<StreamChatGenerics>>; | ||
addMembers(members: string[] | Array<NewMemberPayload<StreamChatGenerics>>, message?: Message<StreamChatGenerics>, options?: ChannelUpdateOptions): Promise<UpdateChannelAPIResponse<StreamChatGenerics>>; | ||
/** | ||
@@ -249,3 +246,3 @@ * addModerators - add moderators to the channel | ||
* | ||
* @param {{user_id: string, channel_role?: Role}[]} members An array of members to invite to the channel | ||
* @param {string[] | Array<NewMemberPayload<StreamChatGenerics>>} members An array of members to invite to the channel | ||
* @param {Message<StreamChatGenerics>} [message] Optional message object for channel members notification | ||
@@ -255,6 +252,3 @@ * @param {ChannelUpdateOptions} [options] Option object, configuration to control the behavior while updating | ||
*/ | ||
inviteMembers(members: { | ||
user_id: string; | ||
channel_role?: Role; | ||
}[] | string[], message?: Message<StreamChatGenerics>, options?: ChannelUpdateOptions): Promise<UpdateChannelAPIResponse<StreamChatGenerics>>; | ||
inviteMembers(members: string[] | Array<NewMemberPayload<StreamChatGenerics>>, message?: Message<StreamChatGenerics>, options?: ChannelUpdateOptions): Promise<UpdateChannelAPIResponse<StreamChatGenerics>>; | ||
/** | ||
@@ -261,0 +255,0 @@ * removeMembers - remove members from channel |
@@ -5,2 +5,16 @@ import { StateStore } from './store'; | ||
import type { DefaultGenerics, ExtendableGenerics, QueryThreadsOptions } from './types'; | ||
export declare const THREAD_MANAGER_INITIAL_STATE: { | ||
active: boolean; | ||
isThreadOrderStale: boolean; | ||
threads: never[]; | ||
unreadThreadCount: number; | ||
unseenThreadIds: never[]; | ||
lastConnectionDropAt: null; | ||
pagination: { | ||
isLoading: boolean; | ||
isLoadingNext: boolean; | ||
nextCursor: null; | ||
}; | ||
ready: boolean; | ||
}; | ||
export declare type ThreadManagerState<SCG extends ExtendableGenerics = DefaultGenerics> = { | ||
@@ -34,2 +48,3 @@ active: boolean; | ||
get threadsById(): Record<string, Thread<SCG> | undefined>; | ||
resetState: () => void; | ||
activate: () => void; | ||
@@ -39,2 +54,3 @@ deactivate: () => void; | ||
private subscribeUnreadThreadsCountChange; | ||
private subscribeChannelDeleted; | ||
private subscribeManageThreadSubscriptions; | ||
@@ -41,0 +57,0 @@ private subscribeReloadOnActivation; |
{ | ||
"name": "stream-chat", | ||
"version": "8.43.0", | ||
"version": "8.44.0", | ||
"description": "JS SDK for the Stream Chat API", | ||
@@ -5,0 +5,0 @@ "author": "GetStream", |
@@ -31,2 +31,3 @@ import { ChannelState } from './channel_state'; | ||
MarkUnreadOptions, | ||
MemberFilters, | ||
MemberSort, | ||
@@ -39,2 +40,3 @@ Message, | ||
MuteChannelAPIResponse, | ||
NewMemberPayload, | ||
PartialUpdateChannel, | ||
@@ -56,3 +58,2 @@ PartialUpdateChannelAPIResponse, | ||
UpdateChannelAPIResponse, | ||
UserFilters, | ||
UserResponse, | ||
@@ -271,3 +272,3 @@ QueryChannelAPIResponse, | ||
* | ||
* @param {UserFilters<StreamChatGenerics>} filterConditions object MongoDB style filters | ||
* @param {MemberFilters<StreamChatGenerics>} filterConditions object MongoDB style filters | ||
* @param {MemberSort<StreamChatGenerics>} [sort] Sort options, for instance [{created_at: -1}]. | ||
@@ -280,3 +281,3 @@ * When using multiple fields, make sure you use array of objects to guarantee field order, for instance [{name: -1}, {created_at: 1}] | ||
async queryMembers( | ||
filterConditions: UserFilters<StreamChatGenerics>, | ||
filterConditions: MemberFilters<StreamChatGenerics>, | ||
sort: MemberSort<StreamChatGenerics> = [], | ||
@@ -317,3 +318,3 @@ options: QueryMembersOptions = {}, | ||
*/ | ||
async partialUpdateMember(user_id: string, updates: PartialUpdateMember) { | ||
async partialUpdateMember(user_id: string, updates: PartialUpdateMember<StreamChatGenerics>) { | ||
if (!user_id) { | ||
@@ -526,3 +527,3 @@ throw Error('Please specify the user id'); | ||
* | ||
* @param {{user_id: string, channel_role?: Role}[]} members An array of members to add to the channel | ||
* @param {string[] | Array<NewMemberPayload<StreamChatGenerics>>} members An array of members to add to the channel | ||
* @param {Message<StreamChatGenerics>} [message] Optional message object for channel members notification | ||
@@ -533,3 +534,3 @@ * @param {ChannelUpdateOptions} [options] Option object, configuration to control the behavior while updating | ||
async addMembers( | ||
members: string[] | { user_id: string; channel_role?: Role }[], | ||
members: string[] | Array<NewMemberPayload<StreamChatGenerics>>, | ||
message?: Message<StreamChatGenerics>, | ||
@@ -572,3 +573,3 @@ options: ChannelUpdateOptions = {}, | ||
* | ||
* @param {{user_id: string, channel_role?: Role}[]} members An array of members to invite to the channel | ||
* @param {string[] | Array<NewMemberPayload<StreamChatGenerics>>} members An array of members to invite to the channel | ||
* @param {Message<StreamChatGenerics>} [message] Optional message object for channel members notification | ||
@@ -579,3 +580,3 @@ * @param {ChannelUpdateOptions} [options] Option object, configuration to control the behavior while updating | ||
async inviteMembers( | ||
members: { user_id: string; channel_role?: Role }[] | string[], | ||
members: string[] | Array<NewMemberPayload<StreamChatGenerics>>, | ||
message?: Message<StreamChatGenerics>, | ||
@@ -717,3 +718,3 @@ options: ChannelUpdateOptions = {}, | ||
if (!uid) { | ||
throw Error('A user_id is required for pinning a channel'); | ||
throw new Error('A user_id is required for pinning a channel'); | ||
} | ||
@@ -740,3 +741,3 @@ const resp = await this.partialUpdateMember(uid, { set: { pinned: true } }); | ||
if (!uid) { | ||
throw Error('A user_id is required for unpinning a channel'); | ||
throw new Error('A user_id is required for unpinning a channel'); | ||
} | ||
@@ -1530,3 +1531,6 @@ const resp = await this.partialUpdateMember(uid, { set: { pinned: false } }); | ||
if (event.member?.user_id) { | ||
channelState.members[event.member.user_id] = event.member; | ||
channelState.members = { | ||
...channelState.members, | ||
[event.member.user_id]: event.member, | ||
}; | ||
} | ||
@@ -1536,3 +1540,9 @@ break; | ||
if (event.user?.id) { | ||
delete channelState.members[event.user.id]; | ||
const newMembers = { | ||
...channelState.members, | ||
}; | ||
delete newMembers[event.user.id]; | ||
channelState.members = newMembers; | ||
} | ||
@@ -1539,0 +1549,0 @@ break; |
@@ -10,2 +10,16 @@ import { StateStore } from './store'; | ||
const MAX_QUERY_THREADS_LIMIT = 25; | ||
export const THREAD_MANAGER_INITIAL_STATE = { | ||
active: false, | ||
isThreadOrderStale: false, | ||
threads: [], | ||
unreadThreadCount: 0, | ||
unseenThreadIds: [], | ||
lastConnectionDropAt: null, | ||
pagination: { | ||
isLoading: false, | ||
isLoadingNext: false, | ||
nextCursor: null, | ||
}, | ||
ready: false, | ||
}; | ||
@@ -44,16 +58,3 @@ export type ThreadManagerState<SCG extends ExtendableGenerics = DefaultGenerics> = { | ||
this.client = client; | ||
this.state = new StateStore<ThreadManagerState<SCG>>({ | ||
active: false, | ||
isThreadOrderStale: false, | ||
threads: [], | ||
unreadThreadCount: 0, | ||
unseenThreadIds: [], | ||
lastConnectionDropAt: null, | ||
pagination: { | ||
isLoading: false, | ||
isLoadingNext: false, | ||
nextCursor: null, | ||
}, | ||
ready: false, | ||
}); | ||
this.state = new StateStore<ThreadManagerState<SCG>>(THREAD_MANAGER_INITIAL_STATE); | ||
@@ -81,2 +82,6 @@ this.threadsByIdGetterCache = { threads: [], threadsById: {} }; | ||
public resetState = () => { | ||
this.state.next(THREAD_MANAGER_INITIAL_STATE); | ||
}; | ||
public activate = () => { | ||
@@ -98,2 +103,3 @@ this.state.partialNext({ active: true }); | ||
this.unsubscribeFunctions.add(this.subscribeRecoverAfterConnectionDrop()); | ||
this.unsubscribeFunctions.add(this.subscribeChannelDeleted()); | ||
}; | ||
@@ -124,2 +130,11 @@ | ||
private subscribeChannelDeleted = () => | ||
this.client.on('notification.channel_deleted', (event) => { | ||
const { cid } = event; | ||
const { threads } = this.state.getLatestValue(); | ||
const newThreads = threads.filter((thread) => thread.channel.cid !== cid); | ||
this.state.partialNext({ threads: newThreads }); | ||
}).unsubscribe; | ||
private subscribeManageThreadSubscriptions = () => | ||
@@ -126,0 +141,0 @@ this.state.subscribeWithSelector( |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
7373952
76784