Skip to content

Commit 903ad89

Browse files
Further cleanup
1 parent d5e4802 commit 903ad89

7 files changed

Lines changed: 20 additions & 425 deletions

File tree

src/client.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ import type {
4646
MuteUserOptions,
4747
MuteUserResponse,
4848
OwnUserResponse,
49+
PartializeAllBut,
4950
PartialThreadUpdate,
5051
PartialUserUpdate,
5152
QueryBannedUsersPayload,
@@ -56,7 +57,6 @@ import type {
5657
QueryUserGroupsOptions,
5758
QueryUserGroupsResponse,
5859
ReactionResponse,
59-
RequireLiteral,
6060
SdkIdentifier,
6161
SearchPayload,
6262
StreamChatOptions,
@@ -132,7 +132,7 @@ export type MessageComposerSetupState = {
132132

133133
export type ListenerKeys = CombinedEvents['type'] | 'all';
134134

135-
type ClientUser = RequireLiteral<Partial<OwnUserResponse>, 'id'> & { anon?: boolean };
135+
type ClientUser = PartializeAllBut<OwnUserResponse, 'id'> & { anon?: boolean };
136136

137137
export class StreamChat extends ChatApi {
138138
private static _instance?: unknown | StreamChat; // type is undefined|StreamChat, unknown is due to TS limitations with statics

src/messageComposer/middleware/messageComposer/messageComposerState.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ export const createMessageComposerStateCompositionMiddleware = (
3737
localMessage: {
3838
...state.localMessage,
3939
...payload,
40-
quoted_message: (composer.quotedMessage as LocalMessage) ?? undefined,
40+
quoted_message: composer.quotedMessage ?? undefined,
4141
},
4242
message: {
4343
...state.message,

src/messageComposer/middleware/messageComposer/userDataInjection.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,12 +33,12 @@ export const createUserDataInjectionMiddleware = (
3333
devices: _devices,
3434
mutes: _mutes,
3535
...messageUser
36-
} = composer.client.user as RequireLiteral<OwnUserResponse, 'blocked_user_ids'>; // TODO: drop RequireLiteral once the oapi spec is adjusted
36+
} = composer.client.user;
3737
return next({
3838
...state,
3939
localMessage: {
4040
...state.localMessage,
41-
user: messageUser,
41+
user: messageUser as RequireLiteral<OwnUserResponse, 'blocked_user_ids'>, // TODO: drop RequireLiteral once the oapi spec is adjusted,
4242
user_id: messageUser.id,
4343
},
4444
});

src/messageComposer/middleware/textComposer/mentions.ts

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -664,14 +664,9 @@ export class MentionsSearchSource extends BaseSearchSource<MentionSuggestion> {
664664

665665
return {
666666
items: user_groups.map((userGroup) =>
667-
this.toUserGroupMentionSuggestion(
668-
userGroup as unknown as UserGroupResponse,
669-
searchQuery,
670-
),
671-
),
672-
next: this.buildUserGroupSearchCursor(
673-
user_groups as unknown as UserGroupResponse[],
667+
this.toUserGroupMentionSuggestion(userGroup, searchQuery),
674668
),
669+
next: this.buildUserGroupSearchCursor(user_groups),
675670
};
676671
};
677672

src/pagination/UserGroupPaginator.ts

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,9 @@ import type {
88
import type { QueryUserGroupsOptions, UserGroupResponse } from '../types';
99
import type { StreamChat } from '../client';
1010

11-
type UserGroupListCursor = {
12-
created_at_gt: string;
13-
id_gt: string;
14-
};
11+
type UserGroupListCursor = Required<
12+
Pick<QueryUserGroupsOptions, 'created_at_gt' | 'id_gt'>
13+
>;
1514

1615
const isRecord = (value: unknown): value is Record<string, unknown> =>
1716
typeof value === 'object' && value !== null;
@@ -65,7 +64,7 @@ export class UserGroupPaginator extends BasePaginator<UserGroupResponse> {
6564
if (!lastItem) return undefined;
6665

6766
return JSON.stringify({
68-
created_at_gt: lastItem.created_at,
67+
created_at_gt: lastItem.created_at.toISOString(), // TODO: this should not be the case
6968
id_gt: lastItem.id,
7069
} satisfies UserGroupListCursor);
7170
};

0 commit comments

Comments
 (0)