Skip to content

Commit 3a85fb8

Browse files
tmp8
1 parent c2b3593 commit 3a85fb8

34 files changed

Lines changed: 238 additions & 288 deletions

src/LiveLocationManager.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ export class LiveLocationManager extends WithSubscriptions {
123123
const { active_live_locations } = await this.client.getSharedLocations();
124124
this.state.next({
125125
messages: new Map(
126-
active_live_locations
126+
(active_live_locations as SharedLiveLocationResponse[])
127127
.filter((location) => !isExpiredLocation(location))
128128
.map((location) => [
129129
location.message_id,
@@ -189,7 +189,8 @@ export class LiveLocationManager extends WithSubscriptions {
189189
if (location.latitude === latitude && location.longitude === longitude)
190190
continue;
191191
const promise = this.client.updateLocation({
192-
created_by_device_id: location.created_by_device_id,
192+
// TODO: this is missing from the OAPI spec
193+
// created_by_device_id: location.created_by_device_id,
193194
message_id: messageId,
194195
latitude,
195196
longitude,

src/channel.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ import type {
5151
QueryMembersOptions,
5252
Reaction,
5353
ReactionAPIResponse,
54+
ReactionResponse,
5455
SearchMessageSortBase,
5556
SearchOptions,
5657
SearchPayload,
@@ -523,11 +524,9 @@ export class Channel {
523524
if (offlineDb) {
524525
const message = this.state.messages.find(({ id }) => id === messageId);
525526
const reaction = {
526-
created_at: '',
527-
updated_at: '',
528527
message_id: messageId,
529528
type: reactionType,
530-
};
529+
} as ReactionResponse;
531530

532531
if (message) {
533532
await offlineDb.deleteReaction({

src/channel_manager.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,8 @@ const mapPredefinedFilterSortToChannelSort = (
163163
sort: NonNullable<QueryChannelsAPIResponse['predefined_filter']>['sort'],
164164
): ChannelSort =>
165165
(sort ?? []).map(({ direction = 1, field }) => ({
166-
[field]: direction,
166+
// TODO: OAPI discrepancy, should not be optional (both direction and field)
167+
[field as string]: direction,
167168
})) as ChannelSort;
168169

169170
const getResponsePaginationParams = ({

src/client.ts

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,7 @@ import type {
152152
PushProviderID,
153153
PushProviderListResponse,
154154
PushProviderUpsertResponse,
155+
QueryChannelsAPIResponse,
155156
QueryFutureChannelBansOptions,
156157
QueryMessageHistoryFilters,
157158
QueryMessageHistoryOptions,
@@ -240,14 +241,14 @@ import type { MessageComposer } from './messageComposer';
240241
import type { AbstractOfflineDB } from './offline-support';
241242
import { getPendingTaskChannelData } from './offline-support/util';
242243
import type {
243-
PushPreferenceInput,
244-
TranslateMessageRequest,
245-
UpdateMessageRequest,
244+
GetApplicationResponse as Gen_GetApplicationResponse,
245+
PushPreferenceInput as Gen_PushPreferenceInput,
246+
TranslateMessageRequest as Gen_TranslateMessageRequest,
247+
UpdateMessageRequest as Gen_UpdateMessageRequest,
246248
WSEvent,
247249
} from './gen/models';
248250
import { ChatApi } from './gen-imports';
249251
import type { StreamResponse } from './types';
250-
import type { GetApplicationResponse } from './gen/models';
251252

252253
function isString(value: unknown): value is string {
253254
return typeof value === 'string' || value instanceof String;
@@ -296,7 +297,7 @@ export class StreamChat {
296297
*/
297298
uploadManager: UploadManager;
298299
_user?: ClientUser;
299-
appSettingsPromise?: Promise<StreamResponse<GetApplicationResponse>>;
300+
appSettingsPromise?: Promise<StreamResponse<Gen_GetApplicationResponse>>;
300301
activeChannels: {
301302
[key: string]: Channel;
302303
};
@@ -2054,7 +2055,7 @@ export class StreamChat {
20542055
*
20552056
* @return {<UpsertPushPreferencesResponse>}
20562057
*/
2057-
async setPushPreferences(preferences: PushPreferenceInput[]) {
2058+
async setPushPreferences(preferences: Gen_PushPreferenceInput[]) {
20582059
return await this.chatApi.updatePushNotificationPreferences({
20592060
preferences,
20602061
});
@@ -2814,7 +2815,7 @@ export class StreamChat {
28142815
*/
28152816
async translateMessage(
28162817
messageId: string,
2817-
language: TranslateMessageRequest['language'],
2818+
language: Gen_TranslateMessageRequest['language'],
28182819
) {
28192820
return await this.chatApi.translateMessage({
28202821
id: messageId,
@@ -2942,7 +2943,7 @@ export class StreamChat {
29422943
* @return {{ message: LocalMessage | MessageResponse }} Response that includes the message
29432944
*/
29442945
async updateMessage(
2945-
message: UpdateMessageRequest['message'] & { cid?: string },
2946+
message: Gen_UpdateMessageRequest['message'] & { cid?: string; status?: string },
29462947
options?: UpdateMessageOptions,
29472948
) {
29482949
if (!message.id) {
@@ -2973,7 +2974,7 @@ export class StreamChat {
29732974
}
29742975

29752976
async _updateMessage(
2976-
message: UpdateMessageRequest['message'],
2977+
message: Gen_UpdateMessageRequest['message'],
29772978
options?: UpdateMessageOptions,
29782979
) {
29792980
if (!message.id) {

src/connection_fallback.ts

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@ import {
88
sleep,
99
} from './utils';
1010
import { isAPIError, isConnectionIDError, isErrorRetryable } from './errors';
11-
import type { ConnectionOpen, Event, LogLevel, UR } from './types';
11+
import type { ConnectionOpen, LogLevel, UR } from './types';
12+
import type { WSEvent } from './gen/models';
1213

1314
export enum ConnectionState {
1415
Closed = 'CLOSED',
@@ -85,14 +86,11 @@ export class WSConnectionFallback {
8586
}
8687

8788
try {
88-
const res = await this.client.doAxiosRequest<T>(
89+
const res = await this.client.api.doAxiosRequest<T>(
8990
'get',
9091
(this.client.baseURL as string).replace(':3030', ':8900') + '/longpoll', // replace port if present for testing with local API
9192
undefined,
92-
{
93-
config: { ...config, cancelToken: this.cancelToken?.token },
94-
params,
95-
},
93+
{ ...config, cancelToken: this.cancelToken?.token, params },
9694
);
9795

9896
this.consecutiveFailures = 0; // always reset in case of no error
@@ -115,7 +113,7 @@ export class WSConnectionFallback {
115113
while (this.state === ConnectionState.Connected) {
116114
try {
117115
const data = await this._req<{
118-
events: Event[];
116+
events: WSEvent[];
119117
}>({}, { timeout: 30000 }, true); // 30s => API responds in 20s if there is no event
120118

121119
if (data.events?.length) {
@@ -173,7 +171,6 @@ export class WSConnectionFallback {
173171

174172
this._setState(ConnectionState.Connected);
175173
this.connectionID = event.connection_id;
176-
// @ts-expect-error type mismatch
177174
this.client.dispatchEvent(event);
178175
this._poll();
179176
if (reconnect) {

src/events.ts

Whitespace-only changes.

src/gen/models/filter-conditions.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -373,7 +373,7 @@ export type QueryThreadsRequestFilter = {
373373
};
374374

375375
export type QueryUsersPayloadFilterConditions = {
376-
banned: { type: boolean; operators: '$eq' };
376+
banned: { type: boolean; operators: '$eq' | '$ne' };
377377
bypass_moderation: { type: boolean; operators: '$eq' | '$ne' };
378378
created_at: {
379379
type: Date;
@@ -667,6 +667,7 @@ export type SearchPayloadMessageFilterConditions = {
667667
| '$ne'
668668
| '$nin';
669669
};
670+
670671
id: {
671672
type: string;
672673
operators:

src/index.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ export * from './channel';
77
export * from './channel_state';
88
export * from './connection';
99
export { type CooldownTimerState } from './CooldownTimer';
10-
export * from './events';
1110
export * from './insights';
1211
export * from './messageComposer';
1312
export * from './messageDelivery';

src/messageComposer/LocationComposer.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,13 @@ export type LocationComposerOptions = {
1414
message?: DraftMessage | LocalMessage;
1515
};
1616

17-
export type StaticLocationPreview = StaticLocationPayload;
17+
export type StaticLocationPreview = StaticLocationPayload & {
18+
message_id?: string;
19+
};
1820

1921
export type LiveLocationPreview = Omit<LiveLocationPayload, 'end_at'> & {
2022
durationMs?: number;
23+
message_id?: string;
2124
};
2225

2326
export type LocationComposerState = {

src/messageComposer/attachmentIdentity.ts

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,10 @@ export const isFileAttachment = (
3333
): attachment is FileAttachment =>
3434
attachment.type === 'file' ||
3535
!!(
36-
attachment.mime_type &&
37-
supportedVideoFormat.indexOf(attachment.mime_type) === -1 &&
36+
(attachment as FileAttachment).custom.mime_type &&
37+
supportedVideoFormat.indexOf(
38+
(attachment as FileAttachment).custom.mime_type as string,
39+
) === -1 &&
3840
attachment.type !== 'video'
3941
);
4042

@@ -76,7 +78,12 @@ export const isVideoAttachment = (
7678
supportedVideoFormat: string[] = [],
7779
): attachment is VideoAttachment =>
7880
attachment.type === 'video' ||
79-
!!(attachment.mime_type && supportedVideoFormat.indexOf(attachment.mime_type) !== -1);
81+
!!(
82+
(attachment as VideoAttachment).custom.mime_type &&
83+
supportedVideoFormat.indexOf(
84+
(attachment as VideoAttachment).custom.mime_type as string,
85+
) !== -1
86+
);
8087

8188
export const isLocalVideoAttachment = (
8289
attachment: Attachment | LocalAttachment,

0 commit comments

Comments
 (0)