stream-chat 9.45.1 → 9.45.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/index.browser.js +24 -13
- package/dist/cjs/index.browser.js.map +2 -2
- package/dist/cjs/index.node.js +24 -13
- package/dist/cjs/index.node.js.map +2 -2
- package/dist/esm/index.mjs +24 -13
- package/dist/esm/index.mjs.map +2 -2
- package/dist/types/search/BaseSearchSource.d.ts +2 -0
- package/dist/types/search/types.d.ts +4 -0
- package/package.json +1 -1
- package/src/channel.ts +0 -7
- package/src/search/BaseSearchSource.ts +17 -4
- package/src/search/UserSearchSource.ts +7 -1
- package/src/search/types.ts +4 -0
|
@@ -4418,7 +4418,9 @@ function isErrorResponse(res) {
|
|
|
4418
4418
|
// src/search/BaseSearchSource.ts
|
|
4419
4419
|
var DEFAULT_SEARCH_SOURCE_OPTIONS = {
|
|
4420
4420
|
debounceMs: 300,
|
|
4421
|
-
pageSize: 10
|
|
4421
|
+
pageSize: 10,
|
|
4422
|
+
allowEmptySearchString: false,
|
|
4423
|
+
resetOnNewSearchQuery: true
|
|
4422
4424
|
};
|
|
4423
4425
|
var BaseSearchSourceBase = class {
|
|
4424
4426
|
constructor(options) {
|
|
@@ -4433,10 +4435,15 @@ var BaseSearchSourceBase = class {
|
|
|
4433
4435
|
this.canExecuteQuery = (newSearchString) => {
|
|
4434
4436
|
const hasNewSearchQuery = typeof newSearchString !== "undefined";
|
|
4435
4437
|
const searchString = newSearchString ?? this.searchQuery;
|
|
4436
|
-
return !!(this.isActive && !this.isLoading && (this.hasNext || hasNewSearchQuery) && searchString);
|
|
4438
|
+
return !!(this.isActive && !this.isLoading && (this.hasNext || hasNewSearchQuery) && (this.allowEmptySearchString || searchString));
|
|
4439
|
+
};
|
|
4440
|
+
const { pageSize, allowEmptySearchString, resetOnNewSearchQuery } = {
|
|
4441
|
+
...DEFAULT_SEARCH_SOURCE_OPTIONS,
|
|
4442
|
+
...options
|
|
4437
4443
|
};
|
|
4438
|
-
const { pageSize } = { ...DEFAULT_SEARCH_SOURCE_OPTIONS, ...options };
|
|
4439
4444
|
this.pageSize = pageSize;
|
|
4445
|
+
this.allowEmptySearchString = allowEmptySearchString;
|
|
4446
|
+
this.resetOnNewSearchQuery = resetOnNewSearchQuery;
|
|
4440
4447
|
this.state = new StateStore(this.initialState);
|
|
4441
4448
|
}
|
|
4442
4449
|
get lastQueryError() {
|
|
@@ -4479,10 +4486,14 @@ var BaseSearchSourceBase = class {
|
|
|
4479
4486
|
return this.state.getLatestValue().searchQuery;
|
|
4480
4487
|
}
|
|
4481
4488
|
getStateBeforeFirstQuery(newSearchString) {
|
|
4489
|
+
const initialState = this.initialState;
|
|
4490
|
+
const oldItems = this.items;
|
|
4491
|
+
const items = this.resetOnNewSearchQuery ? initialState.items : oldItems;
|
|
4482
4492
|
return {
|
|
4483
|
-
...
|
|
4493
|
+
...initialState,
|
|
4494
|
+
items,
|
|
4484
4495
|
isActive: this.isActive,
|
|
4485
|
-
isLoading: true,
|
|
4496
|
+
isLoading: this.resetOnNewSearchQuery ? true : !oldItems,
|
|
4486
4497
|
searchQuery: newSearchString
|
|
4487
4498
|
};
|
|
4488
4499
|
}
|
|
@@ -4992,7 +5003,13 @@ var UserSearchSource = class extends BaseSearchSource {
|
|
|
4992
5003
|
baseFilters: this.filters,
|
|
4993
5004
|
context: { searchQuery }
|
|
4994
5005
|
});
|
|
4995
|
-
|
|
5006
|
+
let sort;
|
|
5007
|
+
if (Array.isArray(this.sort)) {
|
|
5008
|
+
const hasIdSort = this.sort.some((entry) => "id" in entry);
|
|
5009
|
+
sort = hasIdSort ? this.sort : [...this.sort, { id: 1 }];
|
|
5010
|
+
} else {
|
|
5011
|
+
sort = { id: 1, ...this.sort };
|
|
5012
|
+
}
|
|
4996
5013
|
const options = { ...this.searchOptions, limit: this.pageSize, offset: this.offset };
|
|
4997
5014
|
const { users } = await this.client.queryUsers(filters, sort, options);
|
|
4998
5015
|
return { items: users };
|
|
@@ -10777,9 +10794,6 @@ var Channel = class {
|
|
|
10777
10794
|
...channelState.members,
|
|
10778
10795
|
[memberCopy.user.id]: memberCopy
|
|
10779
10796
|
};
|
|
10780
|
-
if (channel.data?.member_count && event.type === "member.added") {
|
|
10781
|
-
channel.data.member_count += 1;
|
|
10782
|
-
}
|
|
10783
10797
|
}
|
|
10784
10798
|
const currentUserId = this.getClient().userID;
|
|
10785
10799
|
if (typeof currentUserId === "string" && typeof memberCopy?.user?.id === "string" && memberCopy.user.id === currentUserId) {
|
|
@@ -10794,9 +10808,6 @@ var Channel = class {
|
|
|
10794
10808
|
};
|
|
10795
10809
|
delete newMembers[event.user.id];
|
|
10796
10810
|
channelState.members = newMembers;
|
|
10797
|
-
if (channel.data?.member_count) {
|
|
10798
|
-
channel.data.member_count = Math.max(channel.data.member_count - 1, 0);
|
|
10799
|
-
}
|
|
10800
10811
|
}
|
|
10801
10812
|
break;
|
|
10802
10813
|
case "notification.mark_unread": {
|
|
@@ -16628,7 +16639,7 @@ var StreamChat = class _StreamChat {
|
|
|
16628
16639
|
if (this.userAgent) {
|
|
16629
16640
|
return this.userAgent;
|
|
16630
16641
|
}
|
|
16631
|
-
const version = "9.45.
|
|
16642
|
+
const version = "9.45.3";
|
|
16632
16643
|
const clientBundle = "browser-cjs";
|
|
16633
16644
|
let userAgentString = "";
|
|
16634
16645
|
if (this.sdkIdentifier) {
|