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.
@@ -4391,7 +4391,9 @@ function isErrorResponse(res) {
4391
4391
  // src/search/BaseSearchSource.ts
4392
4392
  var DEFAULT_SEARCH_SOURCE_OPTIONS = {
4393
4393
  debounceMs: 300,
4394
- pageSize: 10
4394
+ pageSize: 10,
4395
+ allowEmptySearchString: false,
4396
+ resetOnNewSearchQuery: true
4395
4397
  };
4396
4398
  var BaseSearchSourceBase = class {
4397
4399
  constructor(options) {
@@ -4406,10 +4408,15 @@ var BaseSearchSourceBase = class {
4406
4408
  this.canExecuteQuery = (newSearchString) => {
4407
4409
  const hasNewSearchQuery = typeof newSearchString !== "undefined";
4408
4410
  const searchString = newSearchString ?? this.searchQuery;
4409
- return !!(this.isActive && !this.isLoading && (this.hasNext || hasNewSearchQuery) && searchString);
4411
+ return !!(this.isActive && !this.isLoading && (this.hasNext || hasNewSearchQuery) && (this.allowEmptySearchString || searchString));
4412
+ };
4413
+ const { pageSize, allowEmptySearchString, resetOnNewSearchQuery } = {
4414
+ ...DEFAULT_SEARCH_SOURCE_OPTIONS,
4415
+ ...options
4410
4416
  };
4411
- const { pageSize } = { ...DEFAULT_SEARCH_SOURCE_OPTIONS, ...options };
4412
4417
  this.pageSize = pageSize;
4418
+ this.allowEmptySearchString = allowEmptySearchString;
4419
+ this.resetOnNewSearchQuery = resetOnNewSearchQuery;
4413
4420
  this.state = new StateStore(this.initialState);
4414
4421
  }
4415
4422
  get lastQueryError() {
@@ -4452,10 +4459,14 @@ var BaseSearchSourceBase = class {
4452
4459
  return this.state.getLatestValue().searchQuery;
4453
4460
  }
4454
4461
  getStateBeforeFirstQuery(newSearchString) {
4462
+ const initialState = this.initialState;
4463
+ const oldItems = this.items;
4464
+ const items = this.resetOnNewSearchQuery ? initialState.items : oldItems;
4455
4465
  return {
4456
- ...this.initialState,
4466
+ ...initialState,
4467
+ items,
4457
4468
  isActive: this.isActive,
4458
- isLoading: true,
4469
+ isLoading: this.resetOnNewSearchQuery ? true : !oldItems,
4459
4470
  searchQuery: newSearchString
4460
4471
  };
4461
4472
  }
@@ -4965,7 +4976,13 @@ var UserSearchSource = class extends BaseSearchSource {
4965
4976
  baseFilters: this.filters,
4966
4977
  context: { searchQuery }
4967
4978
  });
4968
- const sort = { id: 1, ...this.sort };
4979
+ let sort;
4980
+ if (Array.isArray(this.sort)) {
4981
+ const hasIdSort = this.sort.some((entry) => "id" in entry);
4982
+ sort = hasIdSort ? this.sort : [...this.sort, { id: 1 }];
4983
+ } else {
4984
+ sort = { id: 1, ...this.sort };
4985
+ }
4969
4986
  const options = { ...this.searchOptions, limit: this.pageSize, offset: this.offset };
4970
4987
  const { users } = await this.client.queryUsers(filters, sort, options);
4971
4988
  return { items: users };
@@ -10750,9 +10767,6 @@ var Channel = class {
10750
10767
  ...channelState.members,
10751
10768
  [memberCopy.user.id]: memberCopy
10752
10769
  };
10753
- if (channel.data?.member_count && event.type === "member.added") {
10754
- channel.data.member_count += 1;
10755
- }
10756
10770
  }
10757
10771
  const currentUserId = this.getClient().userID;
10758
10772
  if (typeof currentUserId === "string" && typeof memberCopy?.user?.id === "string" && memberCopy.user.id === currentUserId) {
@@ -10767,9 +10781,6 @@ var Channel = class {
10767
10781
  };
10768
10782
  delete newMembers[event.user.id];
10769
10783
  channelState.members = newMembers;
10770
- if (channel.data?.member_count) {
10771
- channel.data.member_count = Math.max(channel.data.member_count - 1, 0);
10772
- }
10773
10784
  }
10774
10785
  break;
10775
10786
  case "notification.mark_unread": {
@@ -16601,7 +16612,7 @@ var StreamChat = class _StreamChat {
16601
16612
  if (this.userAgent) {
16602
16613
  return this.userAgent;
16603
16614
  }
16604
- const version = "9.45.1";
16615
+ const version = "9.45.3";
16605
16616
  const clientBundle = "node-cjs";
16606
16617
  let userAgentString = "";
16607
16618
  if (this.sdkIdentifier) {