stream-chat
Advanced tools
Comparing version 6.7.3 to 6.8.0
import { Channel } from './channel'; | ||
import { ChannelMemberResponse, ChannelMembership, FormatMessageResponse, Event, ExtendableGenerics, DefaultGenerics, MessageSetType, MessageResponse, ReactionResponse, UserResponse } from './types'; | ||
import { ChannelMemberResponse, ChannelMembership, FormatMessageResponse, Event, ExtendableGenerics, DefaultGenerics, MessageSetType, MessageResponse, ReactionResponse, UserResponse, PendingMessageResponse } from './types'; | ||
declare type ChannelReadStatus<StreamChatGenerics extends ExtendableGenerics = DefaultGenerics> = Record<string, { | ||
@@ -17,2 +17,3 @@ last_read: Date; | ||
pinnedMessages: Array<ReturnType<ChannelState<StreamChatGenerics>['formatMessage']>>; | ||
pending_messages: Array<PendingMessageResponse<StreamChatGenerics>>; | ||
threads: Record<string, Array<ReturnType<ChannelState<StreamChatGenerics>['formatMessage']>>>; | ||
@@ -186,2 +187,11 @@ mutedUsers: Array<UserResponse<StreamChatGenerics>>; | ||
loadMessageIntoState(messageId: string | 'latest', parentMessageId?: string): Promise<void>; | ||
/** | ||
* findMessage - Finds a message inside the state | ||
* | ||
* @param {string} messageId The id of the message | ||
* @param {string} parentMessageId The id of the parent message, if we want load a thread reply | ||
* | ||
* @return {ReturnType<ChannelState<StreamChatGenerics>['formatMessage']>} Returns the message, or undefined if the message wasn't found | ||
*/ | ||
findMessage(messageId: string, parentMessageId?: string): FormatMessageResponse<StreamChatGenerics> | undefined; | ||
private switchToMessageSet; | ||
@@ -188,0 +198,0 @@ private areMessageSetsOverlap; |
@@ -54,2 +54,4 @@ /// <reference types="node" /> | ||
* @param {boolean} [options.skip_push] Skip sending push notifications | ||
* @param {boolean} [options.is_pending_message] Make this message pending | ||
* @param {Record<string,string>} [options.pending_message_metadata] Metadata for the pending message | ||
* | ||
@@ -59,2 +61,4 @@ * @return {Promise<SendMessageAPIResponse<StreamChatGenerics>>} The Server Response | ||
sendMessage(message: Message<StreamChatGenerics>, options?: { | ||
is_pending_message?: boolean; | ||
pending_message_metadata?: Record<string, string>; | ||
skip_enrich_url?: boolean; | ||
@@ -500,4 +504,5 @@ skip_push?: boolean; | ||
_initializeState(state: ChannelAPIResponse<StreamChatGenerics>, messageSetToAddToIfDoesNotExist?: MessageSetType): void; | ||
_extendEventWithOwnReactions(event: Event<StreamChatGenerics>): void; | ||
_disconnect(): void; | ||
} | ||
//# sourceMappingURL=channel.d.ts.map |
@@ -9,3 +9,3 @@ /// <reference types="node" /> | ||
import { WSConnectionFallback } from './connection_fallback'; | ||
import { APIResponse, AppSettings, AppSettingsAPIResponse, BaseDeviceFields, BannedUsersFilters, BannedUsersPaginationOptions, BannedUsersResponse, BannedUsersSort, BanUserOptions, BlockList, BlockListResponse, ChannelAPIResponse, ChannelData, ChannelFilters, ChannelMute, ChannelOptions, ChannelSort, ChannelStateOptions, CheckPushResponse, CheckSQSResponse, Configs, ConnectAPIResponse, CreateChannelOptions, CreateChannelResponse, CreateCommandOptions, CreateCommandResponse, CustomPermissionOptions, DeleteCommandResponse, Device, EndpointName, Event, EventHandler, ExportChannelOptions, ExportChannelRequest, ExportChannelResponse, ExportChannelStatusResponse, MessageFlagsFilters, MessageFlagsPaginationOptions, MessageFlagsResponse, FlagMessageResponse, FlagUserResponse, GetChannelTypeResponse, GetCommandResponse, GetRateLimitsResponse, ListChannelResponse, ListCommandsResponse, Logger, MarkChannelsReadOptions, MessageFilters, MessageResponse, Mute, MuteUserOptions, MuteUserResponse, OwnUserResponse, PartialMessageUpdate, PartialUserUpdate, PermissionAPIResponse, PermissionsAPIResponse, PushProvider, PushProviderID, PushProviderConfig, PushProviderUpsertResponse, PushProviderListResponse, ReactionResponse, SearchOptions, SearchAPIResponse, SendFileAPIResponse, StreamChatOptions, TestPushDataInput, TestSQSDataInput, TokenOrProvider, UnBanUserOptions, UpdateChannelOptions, UpdateChannelResponse, UpdateCommandOptions, UpdateCommandResponse, UpdatedMessage, UpdateMessageAPIResponse, UserCustomEvent, UserFilters, UserOptions, UserResponse, UserSort, SegmentData, Segment, Campaign, CampaignData, OGAttachment, TaskStatus, DeleteUserOptions, TaskResponse, ExtendableGenerics, DefaultGenerics, ReviewFlagReportResponse, FlagReportsFilters, FlagReportsResponse, ReviewFlagReportOptions, FlagReportsPaginationOptions, ExportUsersRequest, ExportUsersResponse, CreateImportResponse, CreateImportOptions, CreateImportURLResponse, GetImportResponse, ListImportsResponse, ListImportsPaginationOptions, FlagsFilters, FlagsPaginationOptions, FlagsResponse, TestCampaignResponse, GetCallTokenResponse, APIErrorResponse, ErrorFromResponse } from './types'; | ||
import { APIResponse, AppSettings, AppSettingsAPIResponse, BaseDeviceFields, BannedUsersFilters, BannedUsersPaginationOptions, BannedUsersResponse, BannedUsersSort, BanUserOptions, BlockList, BlockListResponse, ChannelAPIResponse, ChannelData, ChannelFilters, ChannelMute, ChannelOptions, ChannelSort, ChannelStateOptions, CheckPushResponse, CheckSQSResponse, Configs, ConnectAPIResponse, CreateChannelOptions, CreateChannelResponse, CreateCommandOptions, CreateCommandResponse, CustomPermissionOptions, DeleteCommandResponse, Device, EndpointName, Event, EventHandler, ExportChannelOptions, ExportChannelRequest, ExportChannelResponse, ExportChannelStatusResponse, MessageFlagsFilters, MessageFlagsPaginationOptions, MessageFlagsResponse, FlagMessageResponse, FlagUserResponse, GetChannelTypeResponse, GetCommandResponse, GetMessageAPIResponse, GetRateLimitsResponse, ListChannelResponse, ListCommandsResponse, Logger, MarkChannelsReadOptions, MessageFilters, MessageResponse, Mute, MuteUserOptions, MuteUserResponse, OwnUserResponse, PartialMessageUpdate, PartialUserUpdate, PermissionAPIResponse, PermissionsAPIResponse, PushProvider, PushProviderID, PushProviderConfig, PushProviderUpsertResponse, PushProviderListResponse, ReactionResponse, SearchOptions, SearchAPIResponse, SendFileAPIResponse, StreamChatOptions, TestPushDataInput, TestSQSDataInput, TokenOrProvider, UnBanUserOptions, UpdateChannelOptions, UpdateChannelResponse, UpdateCommandOptions, UpdateCommandResponse, UpdatedMessage, UpdateMessageAPIResponse, UserCustomEvent, UserFilters, UserOptions, UserResponse, UserSort, SegmentData, Segment, Campaign, CampaignData, OGAttachment, TaskStatus, DeleteUserOptions, TaskResponse, ExtendableGenerics, DefaultGenerics, ReviewFlagReportResponse, FlagReportsFilters, FlagReportsResponse, ReviewFlagReportOptions, FlagReportsPaginationOptions, ExportUsersRequest, ExportUsersResponse, CreateImportResponse, CreateImportOptions, CreateImportURLResponse, GetImportResponse, ListImportsResponse, ListImportsPaginationOptions, FlagsFilters, FlagsPaginationOptions, FlagsResponse, TestCampaignResponse, GetCallTokenResponse, APIErrorResponse, ErrorFromResponse, SyncOptions, SyncResponse } from './types'; | ||
import { InsightMetrics } from './insights'; | ||
@@ -858,3 +858,3 @@ export declare class StreamChat<StreamChatGenerics extends ExtendableGenerics = DefaultGenerics> { | ||
deleted_at?: string | undefined; | ||
i18n?: (import("./types").RequireAtLeastOne<Record<"_text" | "so_text" | "hr_text" | "th_text" | "tr_text" | "no_text" | "af_text" | "am_text" | "ar_text" | "az_text" | "bg_text" | "bn_text" | "bs_text" | "cs_text" | "da_text" | "de_text" | "el_text" | "en_text" | "es_text" | "es-MX_text" | "et_text" | "fa_text" | "fa-AF_text" | "fi_text" | "fr_text" | "fr-CA_text" | "ha_text" | "he_text" | "hi_text" | "hu_text" | "id_text" | "it_text" | "ja_text" | "ka_text" | "ko_text" | "lv_text" | "ms_text" | "nl_text" | "pl_text" | "ps_text" | "pt_text" | "ro_text" | "ru_text" | "sk_text" | "sl_text" | "sq_text" | "sr_text" | "sv_text" | "sw_text" | "ta_text" | "tl_text" | "uk_text" | "ur_text" | "vi_text" | "zh_text" | "zh-TW_text", string>> & { | ||
i18n?: (import("./types").RequireAtLeastOne<Record<"_text" | "so_text" | "hr_text" | "th_text" | "tr_text" | "af_text" | "am_text" | "ar_text" | "az_text" | "bg_text" | "bn_text" | "bs_text" | "cs_text" | "da_text" | "de_text" | "el_text" | "en_text" | "es_text" | "es-MX_text" | "et_text" | "fa_text" | "fa-AF_text" | "fi_text" | "fr_text" | "fr-CA_text" | "ha_text" | "he_text" | "hi_text" | "hu_text" | "id_text" | "it_text" | "ja_text" | "ka_text" | "ko_text" | "lv_text" | "ms_text" | "nl_text" | "no_text" | "pl_text" | "ps_text" | "pt_text" | "ro_text" | "ru_text" | "sk_text" | "sl_text" | "sq_text" | "sr_text" | "sv_text" | "sw_text" | "ta_text" | "tl_text" | "uk_text" | "ur_text" | "vi_text" | "zh_text" | "zh-TW_text", string>> & { | ||
language: import("./types").TranslationLanguages; | ||
@@ -954,5 +954,3 @@ }) | undefined; | ||
}>; | ||
getMessage(messageID: string): Promise<APIResponse & { | ||
message: MessageResponse<StreamChatGenerics>; | ||
}>; | ||
getMessage(messageID: string): Promise<GetMessageAPIResponse<StreamChatGenerics>>; | ||
getUserAgent(): string; | ||
@@ -1026,6 +1024,7 @@ setUserAgent(userAgent: string): void; | ||
* @param {string} last_sync_at last time the user was online and in sync. RFC3339 ie. "2020-05-06T15:05:01.207Z" | ||
* @param {SyncOptions} options See JSDoc in the type fields for more info | ||
* | ||
* @returns {Promise<SyncResponse>} | ||
*/ | ||
sync(channel_cids: string[], last_sync_at: string): Promise<APIResponse & { | ||
events: Event<StreamChatGenerics>[]; | ||
}>; | ||
sync(channel_cids: string[], last_sync_at: string, options?: SyncOptions): Promise<SyncResponse<DefaultGenerics>>; | ||
/** | ||
@@ -1032,0 +1031,0 @@ * sendUserCustomEvent - Send a custom event to a user |
@@ -51,2 +51,3 @@ /// <reference types="node" /> | ||
_log(msg: string, extra?: UR, level?: LogLevel): void; | ||
setClient(client: StreamChat<StreamChatGenerics>): void; | ||
/** | ||
@@ -53,0 +54,0 @@ * connect - Connect to the WS URL |
{ | ||
"name": "stream-chat", | ||
"version": "6.7.3", | ||
"version": "6.8.0", | ||
"description": "JS SDK for the Stream Chat API", | ||
@@ -5,0 +5,0 @@ "author": "GetStream", |
@@ -13,2 +13,3 @@ import { Channel } from './channel'; | ||
UserResponse, | ||
PendingMessageResponse, | ||
} from './types'; | ||
@@ -30,2 +31,3 @@ | ||
pinnedMessages: Array<ReturnType<ChannelState<StreamChatGenerics>['formatMessage']>>; | ||
pending_messages: Array<PendingMessageResponse<StreamChatGenerics>>; | ||
threads: Record<string, Array<ReturnType<ChannelState<StreamChatGenerics>['formatMessage']>>>; | ||
@@ -63,2 +65,3 @@ mutedUsers: Array<UserResponse<StreamChatGenerics>>; | ||
this.pinnedMessages = []; | ||
this.pending_messages = []; | ||
this.threads = {}; | ||
@@ -700,2 +703,26 @@ // a list of users to hide messages from | ||
/** | ||
* findMessage - Finds a message inside the state | ||
* | ||
* @param {string} messageId The id of the message | ||
* @param {string} parentMessageId The id of the parent message, if we want load a thread reply | ||
* | ||
* @return {ReturnType<ChannelState<StreamChatGenerics>['formatMessage']>} Returns the message, or undefined if the message wasn't found | ||
*/ | ||
findMessage(messageId: string, parentMessageId?: string) { | ||
if (parentMessageId) { | ||
const messages = this.threads[parentMessageId]; | ||
if (!messages) { | ||
return undefined; | ||
} | ||
return messages.find((m) => m.id === messageId); | ||
} | ||
const messageSetIndex = this.findMessageSetIndex({ id: messageId }); | ||
if (messageSetIndex === -1) { | ||
return undefined; | ||
} | ||
return this.messageSets[messageSetIndex].messages.find((m) => m.id === messageId); | ||
} | ||
private switchToMessageSet(index: number) { | ||
@@ -702,0 +729,0 @@ const currentMessages = this.messageSets.find((s) => s.isCurrent); |
@@ -147,2 +147,4 @@ import { ChannelState } from './channel_state'; | ||
* @param {boolean} [options.skip_push] Skip sending push notifications | ||
* @param {boolean} [options.is_pending_message] Make this message pending | ||
* @param {Record<string,string>} [options.pending_message_metadata] Metadata for the pending message | ||
* | ||
@@ -153,3 +155,8 @@ * @return {Promise<SendMessageAPIResponse<StreamChatGenerics>>} The Server Response | ||
message: Message<StreamChatGenerics>, | ||
options?: { skip_enrich_url?: boolean; skip_push?: boolean }, | ||
options?: { | ||
is_pending_message?: boolean; | ||
pending_message_metadata?: Record<string, string>; | ||
skip_enrich_url?: boolean; | ||
skip_push?: boolean; | ||
}, | ||
) { | ||
@@ -1216,2 +1223,3 @@ const sendMessageResponse = await this.getClient().post<SendMessageAPIResponse<StreamChatGenerics>>( | ||
if (event.message) { | ||
this._extendEventWithOwnReactions(event); | ||
if (event.hard_delete) channelState.removeMessage(event.message); | ||
@@ -1254,2 +1262,3 @@ else channelState.addMessageSorted(event.message, false, false); | ||
if (event.message) { | ||
this._extendEventWithOwnReactions(event); | ||
channelState.addMessageSorted(event.message, false, false); | ||
@@ -1405,2 +1414,5 @@ if (event.message.pinned) { | ||
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; | ||
@@ -1455,2 +1467,12 @@ // convert the arrays into objects for easier syncing... | ||
_extendEventWithOwnReactions(event: Event<StreamChatGenerics>) { | ||
if (!event.message) { | ||
return; | ||
} | ||
const message = this.state.findMessage(event.message.id, event.message.parent_id); | ||
if (message) { | ||
event.message.own_reactions = message.own_reactions; | ||
} | ||
} | ||
_disconnect() { | ||
@@ -1457,0 +1479,0 @@ this._client.logger('info', `channel:disconnect() - Disconnecting the channel ${this.cid}`, { |
@@ -95,2 +95,6 @@ import WebSocket from 'isomorphic-ws'; | ||
setClient(client: StreamChat<StreamChatGenerics>) { | ||
this.client = client; | ||
} | ||
/** | ||
@@ -97,0 +101,0 @@ * connect - Connect to the WS URL |
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 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
4824317
50893