Skip to content

Commit 65ac267

Browse files
Normalize queryDrafts sort
1 parent 2ad1ac2 commit 65ac267

1 file changed

Lines changed: 31 additions & 22 deletions

File tree

src/client.ts

Lines changed: 31 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1464,8 +1464,8 @@ export class StreamChat<StreamChatGenerics extends ExtendableGenerics = DefaultG
14641464
// The StableWSConnection handles all the reconnection logic.
14651465
if (this.options.wsConnection && this.node) {
14661466
// Intentionally avoiding adding ts generics on wsConnection in options since its only useful for unit test purpose.
1467-
((this.options.wsConnection as unknown) as StableWSConnection<StreamChatGenerics>).setClient(this);
1468-
this.wsConnection = (this.options.wsConnection as unknown) as StableWSConnection<StreamChatGenerics>;
1467+
(this.options.wsConnection as unknown as StableWSConnection<StreamChatGenerics>).setClient(this);
1468+
this.wsConnection = this.options.wsConnection as unknown as StableWSConnection<StreamChatGenerics>;
14691469
} else {
14701470
this.wsConnection = new StableWSConnection<StreamChatGenerics>({
14711471
client: this,
@@ -1967,7 +1967,7 @@ export class StreamChat<StreamChatGenerics extends ExtendableGenerics = DefaultG
19671967
// Check if the channel already exists.
19681968
// Only allow 1 channel object per cid
19691969
const memberIds = (custom.members ?? []).map((member: string | NewMemberPayload<StreamChatGenerics>) =>
1970-
typeof member === 'string' ? member : member.user_id ?? '',
1970+
typeof member === 'string' ? member : (member.user_id ?? ''),
19711971
);
19721972
const membersStr = memberIds.sort().join(',');
19731973
const tempCid = generateChannelTempCid(channelType, memberIds);
@@ -2647,13 +2647,13 @@ export class StreamChat<StreamChatGenerics extends ExtendableGenerics = DefaultG
26472647
);
26482648
return this.partialUpdateMessage(
26492649
messageId,
2650-
({
2650+
{
26512651
set: {
26522652
pinned: true,
26532653
pin_expires: this._normalizeExpiration(timeoutOrExpirationDate),
26542654
pinned_at: this._normalizeExpiration(pinnedAt),
26552655
},
2656-
} as unknown) as PartialMessageUpdate<StreamChatGenerics>,
2656+
} as unknown as PartialMessageUpdate<StreamChatGenerics>,
26572657
pinnedBy,
26582658
);
26592659
}
@@ -2670,9 +2670,9 @@ export class StreamChat<StreamChatGenerics extends ExtendableGenerics = DefaultG
26702670
);
26712671
return this.partialUpdateMessage(
26722672
messageId,
2673-
({
2673+
{
26742674
set: { pinned: false },
2675-
} as unknown) as PartialMessageUpdate<StreamChatGenerics>,
2675+
} as unknown as PartialMessageUpdate<StreamChatGenerics>,
26762676
userId,
26772677
);
26782678
}
@@ -2735,7 +2735,7 @@ export class StreamChat<StreamChatGenerics extends ExtendableGenerics = DefaultG
27352735
* SDK missed this conversion.
27362736
*/
27372737
if (Array.isArray(clonedMessage.mentioned_users) && !isString(clonedMessage.mentioned_users[0])) {
2738-
clonedMessage.mentioned_users = clonedMessage.mentioned_users.map((mu) => ((mu as unknown) as UserResponse).id);
2738+
clonedMessage.mentioned_users = clonedMessage.mentioned_users.map((mu) => (mu as unknown as UserResponse).id);
27392739
}
27402740

27412741
return await this.post<UpdateMessageAPIResponse<StreamChatGenerics>>(
@@ -2846,9 +2846,7 @@ export class StreamChat<StreamChatGenerics extends ExtendableGenerics = DefaultG
28462846
);
28472847

28482848
return {
2849-
threads: response.threads.map(
2850-
(thread) => new Thread<StreamChatGenerics>({ client: this, threadData: thread }),
2851-
),
2849+
threads: response.threads.map((thread) => new Thread<StreamChatGenerics>({ client: this, threadData: thread })),
28522850
next: response.next,
28532851
};
28542852
}
@@ -2943,14 +2941,16 @@ export class StreamChat<StreamChatGenerics extends ExtendableGenerics = DefaultG
29432941

29442942
const { os, model } = this.deviceIdentifier ?? {};
29452943

2946-
return ([
2947-
// reports the device OS, if provided
2948-
['os', os],
2949-
// reports the device model, if provided
2950-
['device_model', model],
2951-
// reports which bundle is being picked from the exports
2952-
['client_bundle', clientBundle],
2953-
] as const).reduce(
2944+
return (
2945+
[
2946+
// reports the device OS, if provided
2947+
['os', os],
2948+
// reports the device model, if provided
2949+
['device_model', model],
2950+
// reports which bundle is being picked from the exports
2951+
['client_bundle', clientBundle],
2952+
] as const
2953+
).reduce(
29542954
(withArguments, [key, value]) =>
29552955
value && value.length > 0 ? withArguments.concat(`|${key}=${value}`) : withArguments,
29562956
userAgentString,
@@ -2994,8 +2994,11 @@ export class StreamChat<StreamChatGenerics extends ExtendableGenerics = DefaultG
29942994
};
29952995
}
29962996

2997-
const { params: axiosRequestConfigParams, headers: axiosRequestConfigHeaders, ...axiosRequestConfigRest } =
2998-
this.options.axiosRequestConfig || {};
2997+
const {
2998+
params: axiosRequestConfigParams,
2999+
headers: axiosRequestConfigHeaders,
3000+
...axiosRequestConfigRest
3001+
} = this.options.axiosRequestConfig || {};
29993002

30003003
return {
30013004
params: {
@@ -4071,6 +4074,12 @@ export class StreamChat<StreamChatGenerics extends ExtendableGenerics = DefaultG
40714074
user_id?: string;
40724075
} = {},
40734076
) {
4074-
return await this.post<QueryDraftsResponse<StreamChatGenerics>>(this.baseURL + '/drafts/query', options);
4077+
const payload = {
4078+
filter: options.filter,
4079+
user_id: options.user_id,
4080+
sort: options.sort ? normalizeQuerySort(options.sort) : undefined,
4081+
};
4082+
4083+
return await this.post<QueryDraftsResponse<StreamChatGenerics>>(this.baseURL + '/drafts/query', payload);
40754084
}
40764085
}

0 commit comments

Comments
 (0)