@connectedxm/client 9.0.1 → 10.0.0

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.
Files changed (3) hide show
  1. package/dist/index.d.ts +274 -268
  2. package/dist/index.js +650 -807
  3. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -1,5 +1,11 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __export = (target, all) => {
3
+ for (var name in all)
4
+ __defProp(target, name, { get: all[name], enumerable: true });
5
+ };
6
+
1
7
  // src/ConnectedProvider.tsx
2
- import React2 from "react";
8
+ import React4 from "react";
3
9
 
4
10
  // src/websockets/useConnectedWebsocket.tsx
5
11
  import React from "react";
@@ -59,25 +65,6 @@ import {
59
65
  useInfiniteQuery
60
66
  } from "@tanstack/react-query";
61
67
 
62
- // src/utilities/AppendInfiniteQuery.ts
63
- import { produce } from "immer";
64
- var AppendInfiniteQuery = (queryClient, key, newData) => {
65
- queryClient.setQueryData(
66
- key,
67
- (oldData) => {
68
- return produce(oldData, (draft) => {
69
- if (draft?.pages?.[0]?.data) {
70
- if (draft?.pages?.[0]?.data && draft?.pages?.[0]?.data?.length > 0 && newData) {
71
- draft?.pages?.[0]?.data?.unshift(newData);
72
- } else {
73
- draft.pages[0].data = [newData];
74
- }
75
- }
76
- });
77
- }
78
- );
79
- };
80
-
81
68
  // src/utilities/GetErrorMessage.ts
82
69
  import axios from "axios";
83
70
  var ERR_NOT_GROUP_MEMBER = 453;
@@ -136,6 +123,97 @@ var isUUID = (id) => {
136
123
  return uuidRegex.test(id);
137
124
  };
138
125
 
126
+ // src/utilities/InfiniteQueryHelpers.ts
127
+ var InfiniteQueryHelpers_exports = {};
128
+ __export(InfiniteQueryHelpers_exports, {
129
+ prepend: () => prepend,
130
+ remove: () => remove,
131
+ update: () => update
132
+ });
133
+ import { produce } from "immer";
134
+ var prepend = (queryClient, key, item) => {
135
+ queryClient.setQueryData(
136
+ key,
137
+ (oldData) => {
138
+ if (!oldData) return oldData;
139
+ return produce(oldData, (draft) => {
140
+ if (draft?.pages?.[0]?.data) {
141
+ draft.pages[0].data.unshift(item);
142
+ }
143
+ });
144
+ }
145
+ );
146
+ };
147
+ var update = (queryClient, key, item) => {
148
+ queryClient.setQueryData(
149
+ key,
150
+ (oldData) => {
151
+ if (!oldData) return oldData;
152
+ return produce(oldData, (draft) => {
153
+ for (const page of draft.pages) {
154
+ if (page?.data) {
155
+ const idx = page.data.findIndex(
156
+ (entry) => entry.id === item.id
157
+ );
158
+ if (idx !== -1) {
159
+ page.data[idx] = item;
160
+ return;
161
+ }
162
+ }
163
+ }
164
+ });
165
+ }
166
+ );
167
+ };
168
+ var remove = (queryClient, key, itemId) => {
169
+ queryClient.setQueryData(
170
+ key,
171
+ (oldData) => {
172
+ if (!oldData) return oldData;
173
+ return produce(oldData, (draft) => {
174
+ for (const page of draft.pages) {
175
+ if (page?.data) {
176
+ const idx = page.data.findIndex(
177
+ (entry) => entry.id === itemId
178
+ );
179
+ if (idx !== -1) {
180
+ page.data.splice(idx, 1);
181
+ return;
182
+ }
183
+ }
184
+ }
185
+ });
186
+ }
187
+ );
188
+ };
189
+
190
+ // src/utilities/SingleQueryHelpers.ts
191
+ var SingleQueryHelpers_exports = {};
192
+ __export(SingleQueryHelpers_exports, {
193
+ remove: () => remove2,
194
+ update: () => update2
195
+ });
196
+ import { produce as produce2 } from "immer";
197
+ var update2 = (queryClient, key, updater) => {
198
+ queryClient.setQueryData(
199
+ key,
200
+ (oldData) => {
201
+ if (!oldData) return oldData;
202
+ return produce2(oldData, (draft) => {
203
+ if (draft?.data) {
204
+ const next = updater(draft.data);
205
+ if (next !== void 0) {
206
+ draft.data = next;
207
+ }
208
+ }
209
+ });
210
+ }
211
+ );
212
+ };
213
+ var remove2 = (queryClient, key) => {
214
+ queryClient.removeQueries({ queryKey: key });
215
+ };
216
+
139
217
  // src/queries/useConnectedInfiniteQuery.ts
140
218
  var GetBaseInfiniteQueryKeys = (locale, search = "") => {
141
219
  return [locale, search];
@@ -5685,196 +5763,6 @@ var useGetSelfLeadCounts = (options = {}) => {
5685
5763
  );
5686
5764
  };
5687
5765
 
5688
- // src/queries/self/chat/useGetSelfChatChannels.ts
5689
- var SELF_CHAT_CHANNELS_QUERY_KEY = () => [
5690
- ...SELF_QUERY_KEY(),
5691
- "CHANNELS"
5692
- ];
5693
- var SET_SELF_CHAT_CHANNELS_QUERY_DATA = (client, keyParams, response, baseKeys = ["en"]) => {
5694
- client.setQueryData(
5695
- [
5696
- ...SELF_CHAT_CHANNELS_QUERY_KEY(...keyParams),
5697
- ...GetBaseInfiniteQueryKeys(...baseKeys)
5698
- ],
5699
- setFirstPageData(response)
5700
- );
5701
- };
5702
- var GetSelfChatChannels = async ({
5703
- pageParam,
5704
- pageSize,
5705
- orderBy,
5706
- search,
5707
- clientApiParams
5708
- }) => {
5709
- const clientApi = await GetClientAPI(clientApiParams);
5710
- const { data } = await clientApi.get(`/self/chat/channels`, {
5711
- params: {
5712
- page: pageParam || void 0,
5713
- pageSize: pageSize || void 0,
5714
- orderBy: orderBy || void 0,
5715
- search: search || void 0
5716
- }
5717
- });
5718
- return data;
5719
- };
5720
- var useGetSelfChatChannels = (params = {}, options = {}) => {
5721
- const { authenticated } = useConnected();
5722
- return useConnectedInfiniteQuery(
5723
- SELF_CHAT_CHANNELS_QUERY_KEY(),
5724
- (params2) => GetSelfChatChannels(params2),
5725
- params,
5726
- {
5727
- ...options,
5728
- enabled: !!authenticated && (options?.enabled ?? true)
5729
- }
5730
- );
5731
- };
5732
-
5733
- // src/queries/self/chat/useGetSelfChatChannel.ts
5734
- var SELF_CHAT_CHANNEL_QUERY_KEY = (channelId) => [
5735
- ...SELF_CHAT_CHANNELS_QUERY_KEY(),
5736
- channelId
5737
- ];
5738
- var SET_SELF_CHAT_CHANNEL_QUERY_DATA = (client, keyParams, response, baseKeys = ["en"]) => {
5739
- client.setQueryData(
5740
- [
5741
- ...SELF_CHAT_CHANNEL_QUERY_KEY(...keyParams),
5742
- ...GetBaseSingleQueryKeys(...baseKeys)
5743
- ],
5744
- response
5745
- );
5746
- };
5747
- var GetSelfChatChannel = async ({
5748
- channelId,
5749
- clientApiParams
5750
- }) => {
5751
- const clientApi = await GetClientAPI(clientApiParams);
5752
- const { data } = await clientApi.get(`/self/chat/channels/${channelId}`);
5753
- return data;
5754
- };
5755
- var useGetSelfChatChannel = (channelId = "", options = {}) => {
5756
- const { authenticated } = useConnected();
5757
- return useConnectedSingleQuery(
5758
- SELF_CHAT_CHANNEL_QUERY_KEY(channelId),
5759
- (params) => GetSelfChatChannel({
5760
- channelId: channelId || "unknown",
5761
- ...params
5762
- }),
5763
- {
5764
- staleTime: Infinity,
5765
- ...options,
5766
- enabled: !!authenticated && !!channelId && (options?.enabled ?? true)
5767
- }
5768
- );
5769
- };
5770
-
5771
- // src/queries/self/chat/useGetSelfChatChannelMembers.ts
5772
- var SELF_CHAT_CHANNEL_MEMBERS_QUERY_KEY = (channelId) => [...SELF_CHAT_CHANNEL_QUERY_KEY(channelId), "MEMBERS"];
5773
- var SET_SELF_CHAT_CHANNEL_MEMBERS_QUERY_DATA = (client, keyParams, response, baseKeys = ["en"]) => {
5774
- client.setQueryData(
5775
- [
5776
- ...SELF_CHAT_CHANNEL_MEMBERS_QUERY_KEY(...keyParams),
5777
- ...GetBaseInfiniteQueryKeys(...baseKeys)
5778
- ],
5779
- setFirstPageData(response)
5780
- );
5781
- };
5782
- var GetSelfChatChannelMembers = async ({
5783
- channelId,
5784
- pageParam,
5785
- pageSize,
5786
- orderBy,
5787
- search,
5788
- clientApiParams
5789
- }) => {
5790
- const clientApi = await GetClientAPI(clientApiParams);
5791
- const { data } = await clientApi.get(
5792
- `/self/chat/channels/${channelId}/members`,
5793
- {
5794
- params: {
5795
- page: pageParam || void 0,
5796
- pageSize: pageSize || void 0,
5797
- orderBy: orderBy || void 0,
5798
- search: search || void 0
5799
- }
5800
- }
5801
- );
5802
- return data;
5803
- };
5804
- var useGetSelfChatChannelMembers = (channelId = "", params = {}, options = {}) => {
5805
- const { authenticated } = useConnected();
5806
- return useConnectedInfiniteQuery(
5807
- SELF_CHAT_CHANNEL_MEMBERS_QUERY_KEY(channelId),
5808
- (params2) => GetSelfChatChannelMembers({ ...params2, channelId }),
5809
- params,
5810
- {
5811
- ...options,
5812
- enabled: !!authenticated && !!channelId && (options?.enabled ?? true)
5813
- }
5814
- );
5815
- };
5816
-
5817
- // src/queries/self/chat/useGetSelfChatChannelMessages.ts
5818
- var SELF_CHAT_CHANNEL_MESSAGES_QUERY_KEY = (channelId) => [...SELF_CHAT_CHANNEL_QUERY_KEY(channelId), "MESSAGES"];
5819
- var SET_SELF_CHAT_CHANNEL_MESSAGES_QUERY_DATA = (client, keyParams, response, baseKeys = ["en"]) => {
5820
- client.setQueryData(
5821
- [
5822
- ...SELF_CHAT_CHANNEL_MESSAGES_QUERY_KEY(...keyParams),
5823
- ...GetBaseInfiniteQueryKeys(...baseKeys)
5824
- ],
5825
- setFirstPageData(response)
5826
- );
5827
- };
5828
- var GetSelfChatChannelMessages = async ({
5829
- channelId,
5830
- pageParam,
5831
- pageSize,
5832
- orderBy,
5833
- search,
5834
- queryClient,
5835
- clientApiParams
5836
- }) => {
5837
- const clientApi = await GetClientAPI(clientApiParams);
5838
- const { data } = await clientApi.get(
5839
- `/self/chat/channels/${channelId}/messages`,
5840
- {
5841
- params: {
5842
- page: pageParam || void 0,
5843
- pageSize: pageSize || void 0,
5844
- orderBy: orderBy || void 0,
5845
- search: search || void 0
5846
- }
5847
- }
5848
- );
5849
- if (queryClient && data.status === "ok") {
5850
- SET_SELF_CHAT_CHANNEL_QUERY_DATA(queryClient, [channelId], (old) => {
5851
- if (old && old.data) {
5852
- return {
5853
- ...old,
5854
- data: {
5855
- ...old.data,
5856
- read: true
5857
- }
5858
- };
5859
- }
5860
- return old;
5861
- });
5862
- }
5863
- return data;
5864
- };
5865
- var useGetSelfChatChannelMessages = (channelId = "", params = {}, options = {}) => {
5866
- const { authenticated } = useConnected();
5867
- return useConnectedInfiniteQuery(
5868
- SELF_CHAT_CHANNEL_MESSAGES_QUERY_KEY(channelId),
5869
- (params2) => GetSelfChatChannelMessages({ ...params2, channelId }),
5870
- params,
5871
- {
5872
- ...options,
5873
- enabled: !!authenticated && !!channelId && (options?.enabled ?? true)
5874
- }
5875
- );
5876
- };
5877
-
5878
5766
  // src/queries/self/useGetSelfProfile.ts
5879
5767
  var SELF_PROFILE_QUERY_KEY = (ignoreExecuteAs) => {
5880
5768
  const keys = ["SELF_PROFILE"];
@@ -6955,46 +6843,40 @@ var useGetStreamChatMessages = (streamId = "", sessionId = "", params = {}, opti
6955
6843
  );
6956
6844
  };
6957
6845
 
6958
- // src/queries/threads/useGetThreadCircles.ts
6846
+ // src/queries/threads/useGetThreads.ts
6959
6847
  var THREADS_QUERY_KEY = () => ["THREADS"];
6960
- var THREAD_CIRCLES_QUERY_KEY = () => [
6961
- ...THREADS_QUERY_KEY(),
6962
- "CIRCLES"
6963
- ];
6964
- var SET_THREAD_CIRCLES_QUERY_DATA = (client, keyParams, response, baseKeys = ["en"]) => {
6848
+ var SET_THREADS_QUERY_DATA = (client, keyParams, response, baseKeys = ["en"]) => {
6965
6849
  client.setQueryData(
6966
6850
  [
6967
- ...THREAD_CIRCLES_QUERY_KEY(...keyParams),
6851
+ ...THREADS_QUERY_KEY(...keyParams),
6968
6852
  ...GetBaseInfiniteQueryKeys(...baseKeys)
6969
6853
  ],
6970
6854
  setFirstPageData(response)
6971
6855
  );
6972
6856
  };
6973
- var GetThreadCircles = async ({
6857
+ var GetThreads = async ({
6974
6858
  pageParam,
6975
6859
  pageSize,
6976
6860
  orderBy,
6977
6861
  search,
6978
- type,
6979
6862
  clientApiParams
6980
6863
  }) => {
6981
6864
  const clientApi = await GetClientAPI(clientApiParams);
6982
- const { data } = await clientApi.get(`/threads/circles`, {
6865
+ const { data } = await clientApi.get(`/threads`, {
6983
6866
  params: {
6984
6867
  page: pageParam || void 0,
6985
6868
  pageSize: pageSize || void 0,
6986
6869
  orderBy: orderBy || void 0,
6987
- search: search || void 0,
6988
- type: type || void 0
6870
+ search: search || void 0
6989
6871
  }
6990
6872
  });
6991
6873
  return data;
6992
6874
  };
6993
- var useGetThreadCircles = (params = {}, options = {}) => {
6875
+ var useGetThreads = (params = {}, options = {}) => {
6994
6876
  const { authenticated } = useConnected();
6995
6877
  return useConnectedInfiniteQuery(
6996
- THREAD_CIRCLES_QUERY_KEY(),
6997
- (params2) => GetThreadCircles(params2),
6878
+ THREADS_QUERY_KEY(),
6879
+ (params2) => GetThreads(params2),
6998
6880
  params,
6999
6881
  {
7000
6882
  ...options,
@@ -7003,162 +6885,92 @@ var useGetThreadCircles = (params = {}, options = {}) => {
7003
6885
  );
7004
6886
  };
7005
6887
 
7006
- // src/queries/threads/useGetThreadCircle.ts
7007
- var THREAD_CIRCLE_QUERY_KEY = (circleId) => [
7008
- ...THREAD_CIRCLES_QUERY_KEY(),
7009
- circleId
7010
- ];
7011
- var SET_THREAD_CIRCLE_QUERY_DATA = (client, keyParams, response, baseKeys = ["en"], options) => {
6888
+ // src/queries/threads/useGetThread.ts
6889
+ var THREAD_QUERY_KEY = (threadId, accountId) => [...THREADS_QUERY_KEY(), threadId, accountId];
6890
+ var SET_THREAD_QUERY_DATA = (client, keyParams, response, baseKeys = ["en"], options) => {
7012
6891
  client.setQueryData(
7013
- [
7014
- ...THREAD_CIRCLE_QUERY_KEY(...keyParams),
7015
- ...GetBaseSingleQueryKeys(...baseKeys)
7016
- ],
6892
+ [...THREAD_QUERY_KEY(...keyParams), ...GetBaseSingleQueryKeys(...baseKeys)],
7017
6893
  response,
7018
6894
  options
7019
6895
  );
7020
6896
  };
7021
- var GetThreadCircle = async ({
7022
- circleId,
6897
+ var GetThread = async ({
6898
+ threadId,
7023
6899
  clientApiParams
7024
6900
  }) => {
7025
6901
  const clientApi = await GetClientAPI(clientApiParams);
7026
- const { data } = await clientApi.get(`/threads/circles/${circleId}`);
6902
+ const { data } = await clientApi.get(`/threads/${threadId}`);
7027
6903
  return data;
7028
6904
  };
7029
- var useGetThreadCircle = (circleId = "", options = {}) => {
6905
+ var useGetThread = (threadId = "", options = {}) => {
7030
6906
  return useConnectedSingleQuery(
7031
- THREAD_CIRCLE_QUERY_KEY(circleId),
7032
- (params) => GetThreadCircle({ circleId, ...params }),
6907
+ THREAD_QUERY_KEY(threadId),
6908
+ (params) => GetThread({ threadId, ...params }),
7033
6909
  {
7034
6910
  ...options,
7035
- enabled: !!circleId && (options?.enabled ?? true)
6911
+ enabled: !!threadId && (options?.enabled ?? true)
7036
6912
  }
7037
6913
  );
7038
6914
  };
7039
6915
 
7040
- // src/queries/threads/useGetThreadCircleAccounts.ts
7041
- var THREAD_CIRCLE_ACCOUNTS_QUERY_KEY = (circleId) => [...THREAD_CIRCLE_QUERY_KEY(circleId), "ACCOUNTS"];
7042
- var SET_THREAD_CIRCLE_ACCOUNTS_QUERY_DATA = (client, keyParams, response, baseKeys = ["en"]) => {
6916
+ // src/queries/threads/useGetThreadAccounts.ts
6917
+ var THREAD_ACCOUNTS_QUERY_KEY = (threadId) => [
6918
+ ...THREAD_QUERY_KEY(threadId),
6919
+ "ACCOUNTS"
6920
+ ];
6921
+ var SET_THREAD_ACCOUNTS_QUERY_DATA = (client, keyParams, response, baseKeys = ["en"]) => {
7043
6922
  client.setQueryData(
7044
6923
  [
7045
- ...THREAD_CIRCLE_ACCOUNTS_QUERY_KEY(...keyParams),
6924
+ ...THREAD_ACCOUNTS_QUERY_KEY(...keyParams),
7046
6925
  ...GetBaseInfiniteQueryKeys(...baseKeys)
7047
6926
  ],
7048
6927
  setFirstPageData(response)
7049
6928
  );
7050
6929
  };
7051
- var GetThreadCircleAccounts = async ({
7052
- circleId,
6930
+ var GetThreadAccounts = async ({
6931
+ threadId,
7053
6932
  pageParam,
7054
6933
  pageSize,
7055
6934
  orderBy,
7056
6935
  search,
7057
- role,
7058
6936
  clientApiParams
7059
6937
  }) => {
7060
6938
  const clientApi = await GetClientAPI(clientApiParams);
7061
- const { data } = await clientApi.get(
7062
- `/threads/circles/${circleId}/accounts`,
7063
- {
7064
- params: {
7065
- page: pageParam || void 0,
7066
- pageSize: pageSize || void 0,
7067
- orderBy: orderBy || void 0,
7068
- search: search || void 0,
7069
- role: role || void 0
7070
- }
6939
+ const { data } = await clientApi.get(`/threads/${threadId}/accounts`, {
6940
+ params: {
6941
+ page: pageParam || void 0,
6942
+ pageSize: pageSize || void 0,
6943
+ orderBy: orderBy || void 0,
6944
+ search: search || void 0
7071
6945
  }
7072
- );
6946
+ });
7073
6947
  return data;
7074
6948
  };
7075
- var useGetThreadCircleAccounts = (circleId = "", params = {}, options = {}) => {
6949
+ var useGetThreadAccounts = (threadId = "", params = {}, options = {}) => {
7076
6950
  const { authenticated } = useConnected();
7077
6951
  return useConnectedInfiniteQuery(
7078
- THREAD_CIRCLE_ACCOUNTS_QUERY_KEY(circleId),
7079
- (params2) => GetThreadCircleAccounts({ ...params2, circleId }),
6952
+ THREAD_ACCOUNTS_QUERY_KEY(threadId),
6953
+ (params2) => GetThreadAccounts({ ...params2, threadId }),
7080
6954
  params,
7081
6955
  {
7082
6956
  ...options,
7083
- enabled: !!authenticated && !!circleId && (options?.enabled ?? true)
6957
+ enabled: !!authenticated && !!threadId && (options?.enabled ?? true)
7084
6958
  }
7085
6959
  );
7086
6960
  };
7087
6961
 
7088
- // src/queries/threads/useGetThreadCircleAccount.ts
7089
- var THREAD_CIRCLE_ACCOUNT_QUERY_KEY = (circleId, accountId) => [...THREAD_CIRCLE_ACCOUNTS_QUERY_KEY(circleId), accountId];
7090
- var SET_THREAD_CIRCLE_ACCOUNT_QUERY_DATA = (client, keyParams, response, baseKeys = ["en"], options) => {
6962
+ // src/queries/threads/useGetThreadMessages.ts
6963
+ var THREAD_MESSAGES_QUERY_KEY = (threadId) => [
6964
+ ...THREAD_QUERY_KEY(threadId),
6965
+ "MESSAGES"
6966
+ ];
6967
+ var SET_THREAD_MESSAGES_QUERY_DATA = (client, keyParams, response, baseKeys = ["en"]) => {
7091
6968
  client.setQueryData(
7092
6969
  [
7093
- ...THREAD_CIRCLE_ACCOUNT_QUERY_KEY(...keyParams),
7094
- ...GetBaseSingleQueryKeys(...baseKeys)
6970
+ ...THREAD_MESSAGES_QUERY_KEY(...keyParams),
6971
+ ...GetBaseInfiniteQueryKeys(...baseKeys)
7095
6972
  ],
7096
- response,
7097
- options
7098
- );
7099
- };
7100
- var GetThreadCircleAccount = async ({
7101
- circleId,
7102
- accountId,
7103
- clientApiParams
7104
- }) => {
7105
- const clientApi = await GetClientAPI(clientApiParams);
7106
- const { data } = await clientApi.get(
7107
- `/threads/circles/${circleId}/accounts/${accountId}`
7108
- );
7109
- return data;
7110
- };
7111
- var useGetThreadCircleAccount = (circleId = "", accountId = "", options = {}) => {
7112
- return useConnectedSingleQuery(
7113
- THREAD_CIRCLE_ACCOUNT_QUERY_KEY(circleId, accountId),
7114
- (params) => GetThreadCircleAccount({ circleId, accountId, ...params }),
7115
- {
7116
- ...options,
7117
- enabled: !!circleId && !!accountId && (options?.enabled ?? true)
7118
- }
7119
- );
7120
- };
7121
-
7122
- // src/queries/threads/useGetThread.ts
7123
- var THREAD_QUERY_KEY = (threadId, accountId) => [...THREADS_QUERY_KEY(), threadId, accountId];
7124
- var SET_THREAD_QUERY_DATA = (client, keyParams, response, baseKeys = ["en"], options) => {
7125
- client.setQueryData(
7126
- [...THREAD_QUERY_KEY(...keyParams), ...GetBaseSingleQueryKeys(...baseKeys)],
7127
- response,
7128
- options
7129
- );
7130
- };
7131
- var GetThread = async ({
7132
- threadId,
7133
- clientApiParams
7134
- }) => {
7135
- const clientApi = await GetClientAPI(clientApiParams);
7136
- const { data } = await clientApi.get(`/threads/${threadId}`);
7137
- return data;
7138
- };
7139
- var useGetThread = (threadId = "", options = {}) => {
7140
- return useConnectedSingleQuery(
7141
- THREAD_QUERY_KEY(threadId),
7142
- (params) => GetThread({ threadId, ...params }),
7143
- {
7144
- ...options,
7145
- enabled: !!threadId && (options?.enabled ?? true)
7146
- }
7147
- );
7148
- };
7149
-
7150
- // src/queries/threads/useGetThreadMessages.ts
7151
- var THREAD_MESSAGES_QUERY_KEY = (threadId) => [
7152
- ...THREAD_QUERY_KEY(threadId),
7153
- "MESSAGES"
7154
- ];
7155
- var SET_THREAD_MESSAGES_QUERY_DATA = (client, keyParams, response, baseKeys = ["en"]) => {
7156
- client.setQueryData(
7157
- [
7158
- ...THREAD_MESSAGES_QUERY_KEY(...keyParams),
7159
- ...GetBaseInfiniteQueryKeys(...baseKeys)
7160
- ],
7161
- setFirstPageData(response)
6973
+ setFirstPageData(response)
7162
6974
  );
7163
6975
  };
7164
6976
  var GetThreadMessages = async ({
@@ -7675,96 +7487,6 @@ var useGetSupportTicketActivityLog = (supportTicketId = "", params = {}, options
7675
7487
  );
7676
7488
  };
7677
7489
 
7678
- // src/websockets/chat/ChatMessageCreated.ts
7679
- var ChatMessageCreated = (queryClient, locale, message) => {
7680
- const QueryKey4 = [
7681
- ...SELF_CHAT_CHANNEL_MESSAGES_QUERY_KEY(message.body.channelId.toString()),
7682
- ...GetBaseInfiniteQueryKeys(locale || "en")
7683
- ];
7684
- const existingMessages = queryClient.getQueryData(QueryKey4);
7685
- const exists = existingMessages ? MergeInfinitePages(existingMessages).find(
7686
- (msg) => msg.id === message.body.message.id
7687
- ) : false;
7688
- if (!exists) {
7689
- AppendInfiniteQuery(queryClient, QueryKey4, message.body.message);
7690
- }
7691
- };
7692
- var ChatMessageCreated_default = ChatMessageCreated;
7693
-
7694
- // src/websockets/chat/ChatMessageDeleted.ts
7695
- import { produce as produce2 } from "immer";
7696
- var ChatMessageDeleted = (queryClient, locale, message) => {
7697
- const QueryKey4 = [
7698
- ...SELF_CHAT_CHANNEL_MESSAGES_QUERY_KEY(message.body.channelId.toString()),
7699
- ...GetBaseInfiniteQueryKeys(locale || "en")
7700
- ];
7701
- queryClient.setQueryData(
7702
- QueryKey4,
7703
- (oldData) => {
7704
- return produce2(oldData, (draft) => {
7705
- if (draft?.pages) {
7706
- for (const page of draft.pages) {
7707
- if (page?.data) {
7708
- page.data = page.data.filter(
7709
- (msg) => msg.id !== message.body.messageId
7710
- );
7711
- }
7712
- }
7713
- }
7714
- });
7715
- }
7716
- );
7717
- };
7718
- var ChatMessageDeleted_default = ChatMessageDeleted;
7719
-
7720
- // src/websockets/chat/ChatMessageUpdated.ts
7721
- import { produce as produce3 } from "immer";
7722
- var ChatMessageUpdated = (queryClient, locale, message) => {
7723
- const QueryKey4 = [
7724
- ...SELF_CHAT_CHANNEL_MESSAGES_QUERY_KEY(message.body.channelId.toString()),
7725
- ...GetBaseInfiniteQueryKeys(locale || "en")
7726
- ];
7727
- queryClient.setQueryData(
7728
- QueryKey4,
7729
- (oldData) => {
7730
- return produce3(oldData, (draft) => {
7731
- if (draft?.pages) {
7732
- for (const page of draft.pages) {
7733
- if (page?.data) {
7734
- const index = page.data.findIndex(
7735
- (msg) => msg.id === message.body.message.id
7736
- );
7737
- if (index !== -1) {
7738
- page.data[index] = message.body.message;
7739
- break;
7740
- }
7741
- }
7742
- }
7743
- }
7744
- });
7745
- }
7746
- );
7747
- };
7748
- var ChatMessageUpdated_default = ChatMessageUpdated;
7749
-
7750
- // src/websockets/threads/messages/ThreadMessageCreated.ts
7751
- var ThreadMessageCreated = (_queryClient, _locale, _message) => {
7752
- return;
7753
- };
7754
- var ThreadMessageCreated_default = ThreadMessageCreated;
7755
-
7756
- // src/websockets/threads/messages/ThreadMessageDeleted.ts
7757
- var ThreadMessageDeleted = (_queryClient, _locale, _message) => {
7758
- return;
7759
- };
7760
- var ThreadMessageDeleted_default = ThreadMessageDeleted;
7761
-
7762
- // src/websockets/threads/messages/ThreadMessageUpdated.ts
7763
- var ThreadMessageUpdated = (_queryClient, _locale, _message) => {
7764
- return;
7765
- };
7766
- var ThreadMessageUpdated_default = ThreadMessageUpdated;
7767
-
7768
7490
  // src/websockets/stream/StreamChatCreated.ts
7769
7491
  var StreamChatCreated = (queryClient, locale, message) => {
7770
7492
  const QueryKey4 = [
@@ -7779,13 +7501,13 @@ var StreamChatCreated = (queryClient, locale, message) => {
7779
7501
  (msg) => msg.messageId === message.body.message.messageId
7780
7502
  ) : false;
7781
7503
  if (!exists) {
7782
- AppendInfiniteQuery(queryClient, QueryKey4, message.body.message);
7504
+ InfiniteQueryHelpers_exports.prepend(queryClient, QueryKey4, message.body.message);
7783
7505
  }
7784
7506
  };
7785
7507
  var StreamChatCreated_default = StreamChatCreated;
7786
7508
 
7787
7509
  // src/websockets/stream/StreamChatDeleted.ts
7788
- import { produce as produce4 } from "immer";
7510
+ import { produce as produce3 } from "immer";
7789
7511
  var StreamChatDeleted = (queryClient, locale, message) => {
7790
7512
  const QueryKey4 = [
7791
7513
  ...STREAM_CHAT_MESSAGES_QUERY_KEY(
@@ -7797,7 +7519,7 @@ var StreamChatDeleted = (queryClient, locale, message) => {
7797
7519
  queryClient.setQueryData(
7798
7520
  QueryKey4,
7799
7521
  (oldData) => {
7800
- return produce4(oldData, (draft) => {
7522
+ return produce3(oldData, (draft) => {
7801
7523
  if (draft?.pages) {
7802
7524
  for (const page of draft.pages) {
7803
7525
  if (page?.data) {
@@ -7814,7 +7536,7 @@ var StreamChatDeleted = (queryClient, locale, message) => {
7814
7536
  var StreamChatDeleted_default = StreamChatDeleted;
7815
7537
 
7816
7538
  // src/websockets/stream/StreamChatUpdated.ts
7817
- import { produce as produce5 } from "immer";
7539
+ import { produce as produce4 } from "immer";
7818
7540
  var StreamChatUpdated = (queryClient, locale, message) => {
7819
7541
  const QueryKey4 = [
7820
7542
  ...STREAM_CHAT_MESSAGES_QUERY_KEY(
@@ -7826,7 +7548,7 @@ var StreamChatUpdated = (queryClient, locale, message) => {
7826
7548
  queryClient.setQueryData(
7827
7549
  QueryKey4,
7828
7550
  (oldData) => {
7829
- return produce5(oldData, (draft) => {
7551
+ return produce4(oldData, (draft) => {
7830
7552
  if (draft?.pages) {
7831
7553
  for (const page of draft.pages) {
7832
7554
  if (page?.data) {
@@ -7872,7 +7594,8 @@ var useConnectedWebsocket = (useWebSocket, {
7872
7594
  getToken,
7873
7595
  getExecuteAs,
7874
7596
  websocketUrl,
7875
- organizationId
7597
+ organizationId,
7598
+ bus
7876
7599
  }) => {
7877
7600
  const queryClient = useQueryClient();
7878
7601
  const [socketUrl, setSocketUrl] = React.useState(null);
@@ -7928,21 +7651,15 @@ var useConnectedWebsocket = (useWebSocket, {
7928
7651
  const sendWSMessage = (message) => {
7929
7652
  sendJsonMessage(message);
7930
7653
  };
7654
+ const lastDispatchedRef = React.useRef(null);
7931
7655
  React.useEffect(() => {
7932
7656
  if (!lastWSMessage) return;
7933
- if (lastWSMessage.type === "chat.message.created") {
7934
- ChatMessageCreated_default(queryClient, locale, lastWSMessage);
7935
- } else if (lastWSMessage.type === "chat.message.deleted") {
7936
- ChatMessageDeleted_default(queryClient, locale, lastWSMessage);
7937
- } else if (lastWSMessage.type === "chat.message.updated") {
7938
- ChatMessageUpdated_default(queryClient, locale, lastWSMessage);
7939
- } else if (lastWSMessage.type === "thread.message.created") {
7940
- ThreadMessageCreated_default(queryClient, locale, lastWSMessage);
7941
- } else if (lastWSMessage.type === "thread.message.updated") {
7942
- ThreadMessageUpdated_default(queryClient, locale, lastWSMessage);
7943
- } else if (lastWSMessage.type === "thread.message.deleted") {
7944
- ThreadMessageDeleted_default(queryClient, locale, lastWSMessage);
7945
- } else if (lastWSMessage.type === "stream.chat.created") {
7657
+ if (lastDispatchedRef.current === lastWSMessage) return;
7658
+ lastDispatchedRef.current = lastWSMessage;
7659
+ if (bus) {
7660
+ bus.dispatch(lastWSMessage);
7661
+ }
7662
+ if (lastWSMessage.type === "stream.chat.created") {
7946
7663
  StreamChatCreated_default(queryClient, locale, lastWSMessage);
7947
7664
  } else if (lastWSMessage.type === "stream.chat.deleted") {
7948
7665
  StreamChatDeleted_default(queryClient, locale, lastWSMessage);
@@ -7955,24 +7672,193 @@ var useConnectedWebsocket = (useWebSocket, {
7955
7672
  } else if (lastWSMessage.type === "pulse") {
7956
7673
  PulseMessage_default(queryClient, locale, lastWSMessage);
7957
7674
  }
7958
- });
7675
+ }, [lastWSMessage, bus, queryClient, locale]);
7959
7676
  return { sendWSMessage, lastWSMessage, readyState };
7960
7677
  };
7961
7678
 
7679
+ // src/socket/WSMessageBus.tsx
7680
+ import React2 from "react";
7681
+ var WSMessageBus = class {
7682
+ constructor() {
7683
+ this.handlers = /* @__PURE__ */ new Map();
7684
+ }
7685
+ register(event, handler) {
7686
+ let set = this.handlers.get(event);
7687
+ if (!set) {
7688
+ set = /* @__PURE__ */ new Set();
7689
+ this.handlers.set(event, set);
7690
+ }
7691
+ set.add(handler);
7692
+ return () => {
7693
+ const current = this.handlers.get(event);
7694
+ if (current) {
7695
+ current.delete(handler);
7696
+ if (current.size === 0) {
7697
+ this.handlers.delete(event);
7698
+ }
7699
+ }
7700
+ };
7701
+ }
7702
+ dispatch(envelope) {
7703
+ if (!envelope) return;
7704
+ const eventName = envelope.event ?? envelope.type;
7705
+ if (!eventName) return;
7706
+ const handlers = this.handlers.get(eventName);
7707
+ if (!handlers || handlers.size === 0) return;
7708
+ const payload = envelope.body ?? envelope.payload;
7709
+ if (payload === void 0) {
7710
+ console.warn(
7711
+ `[WSMessageBus] envelope for "${eventName}" had no body/payload; skipping`
7712
+ );
7713
+ return;
7714
+ }
7715
+ handlers.forEach((handler) => {
7716
+ try {
7717
+ handler(payload);
7718
+ } catch (err) {
7719
+ console.error(`[WSMessageBus] handler for "${eventName}" threw`, err);
7720
+ }
7721
+ });
7722
+ }
7723
+ clear() {
7724
+ this.handlers.clear();
7725
+ }
7726
+ };
7727
+ var WSMessageBusContext = React2.createContext(null);
7728
+ var WSMessageBusProvider = ({
7729
+ bus,
7730
+ children
7731
+ }) => {
7732
+ const ref = React2.useRef(null);
7733
+ if (!ref.current) {
7734
+ ref.current = bus ?? new WSMessageBus();
7735
+ }
7736
+ return /* @__PURE__ */ React2.createElement(WSMessageBusContext.Provider, { value: ref.current }, children);
7737
+ };
7738
+ var useWSMessageBus = () => {
7739
+ const ctx = React2.useContext(WSMessageBusContext);
7740
+ if (!ctx) {
7741
+ throw new Error(
7742
+ "useWSMessageBus must be used within a WSMessageBusProvider"
7743
+ );
7744
+ }
7745
+ return ctx;
7746
+ };
7747
+ var useWSEvent = (event, handler) => {
7748
+ const bus = useWSMessageBus();
7749
+ React2.useEffect(() => {
7750
+ return bus.register(event, handler);
7751
+ }, [bus, event, handler]);
7752
+ };
7753
+
7754
+ // src/socket/threads/ThreadTypingEffect.tsx
7755
+ import React3 from "react";
7756
+ var TYPING_TTL_MS = 6e3;
7757
+ var EMPTY_THREAD_TYPING = Object.freeze({});
7758
+ var ThreadTypingStore = class {
7759
+ constructor() {
7760
+ this.state = {};
7761
+ this.listeners = /* @__PURE__ */ new Set();
7762
+ this.expiryTimers = /* @__PURE__ */ new Map();
7763
+ this.subscribe = (listener) => {
7764
+ this.listeners.add(listener);
7765
+ return () => {
7766
+ this.listeners.delete(listener);
7767
+ };
7768
+ };
7769
+ this.getSnapshot = () => this.state;
7770
+ }
7771
+ setState(next) {
7772
+ this.state = next;
7773
+ this.listeners.forEach((listener) => listener(this.state));
7774
+ }
7775
+ scheduleExpiry(threadId, accountId) {
7776
+ const key = `${threadId}::${accountId}`;
7777
+ const existing = this.expiryTimers.get(key);
7778
+ if (existing) clearTimeout(existing);
7779
+ const timer = setTimeout(() => {
7780
+ this.expiryTimers.delete(key);
7781
+ const threadMap = this.state[threadId];
7782
+ if (!threadMap || !(accountId in threadMap)) return;
7783
+ const nextThreadMap = { ...threadMap };
7784
+ delete nextThreadMap[accountId];
7785
+ const next = { ...this.state };
7786
+ if (Object.keys(nextThreadMap).length === 0) {
7787
+ delete next[threadId];
7788
+ } else {
7789
+ next[threadId] = nextThreadMap;
7790
+ }
7791
+ this.setState(next);
7792
+ }, TYPING_TTL_MS);
7793
+ this.expiryTimers.set(key, timer);
7794
+ }
7795
+ record(threadId, accountId, typingAt) {
7796
+ const nextThreadMap = {
7797
+ ...this.state[threadId] ?? {},
7798
+ [accountId]: typingAt
7799
+ };
7800
+ this.setState({ ...this.state, [threadId]: nextThreadMap });
7801
+ this.scheduleExpiry(threadId, accountId);
7802
+ }
7803
+ };
7804
+ var ThreadTypingStoreContext = React3.createContext(
7805
+ null
7806
+ );
7807
+ var ThreadTypingStoreProvider = ({
7808
+ store,
7809
+ children
7810
+ }) => {
7811
+ const ref = React3.useRef(null);
7812
+ if (!ref.current) {
7813
+ ref.current = store ?? new ThreadTypingStore();
7814
+ }
7815
+ return /* @__PURE__ */ React3.createElement(ThreadTypingStoreContext.Provider, { value: ref.current }, children);
7816
+ };
7817
+ var useThreadTypingStore = () => {
7818
+ const store = React3.useContext(ThreadTypingStoreContext);
7819
+ if (!store) {
7820
+ throw new Error(
7821
+ "useThreadTypingStore must be used within a ConnectedProvider"
7822
+ );
7823
+ }
7824
+ return store;
7825
+ };
7826
+ var useThreadTyping = (threadId) => {
7827
+ const store = useThreadTypingStore();
7828
+ const fullState = React3.useSyncExternalStore(
7829
+ store.subscribe,
7830
+ store.getSnapshot,
7831
+ store.getSnapshot
7832
+ );
7833
+ return fullState[threadId] ?? EMPTY_THREAD_TYPING;
7834
+ };
7835
+ var ThreadTypingEffect = () => {
7836
+ const store = useThreadTypingStore();
7837
+ const handler = React3.useCallback(
7838
+ (payload) => {
7839
+ store.record(payload.threadId, payload.accountId, payload.typingAt);
7840
+ },
7841
+ [store]
7842
+ );
7843
+ useWSEvent("thread.typing", handler);
7844
+ return null;
7845
+ };
7846
+
7962
7847
  // src/ConnectedProvider.tsx
7963
- var ConnectedXMClientContext = React2.createContext(
7848
+ var ConnectedXMClientContext = React4.createContext(
7964
7849
  {}
7965
7850
  );
7966
- var ConnectedProvider = ({
7851
+ var ConnectedProviderInner = ({
7967
7852
  children,
7968
7853
  useWebSocket,
7854
+ bus,
7969
7855
  ...state
7970
7856
  }) => {
7971
7857
  const { sendWSMessage, lastWSMessage, readyState } = useConnectedWebsocket(
7972
7858
  useWebSocket,
7973
- state
7859
+ { ...state, bus }
7974
7860
  );
7975
- return /* @__PURE__ */ React2.createElement(
7861
+ return /* @__PURE__ */ React4.createElement(
7976
7862
  ConnectedXMClientContext.Provider,
7977
7863
  {
7978
7864
  value: {
@@ -7985,11 +7871,22 @@ var ConnectedProvider = ({
7985
7871
  children
7986
7872
  );
7987
7873
  };
7874
+ var ConnectedProvider = (props) => {
7875
+ const busRef = React4.useRef(null);
7876
+ if (!busRef.current) {
7877
+ busRef.current = new WSMessageBus();
7878
+ }
7879
+ const typingStoreRef = React4.useRef(null);
7880
+ if (!typingStoreRef.current) {
7881
+ typingStoreRef.current = new ThreadTypingStore();
7882
+ }
7883
+ return /* @__PURE__ */ React4.createElement(WSMessageBusProvider, { bus: busRef.current }, /* @__PURE__ */ React4.createElement(ThreadTypingStoreProvider, { store: typingStoreRef.current }, /* @__PURE__ */ React4.createElement(ConnectedProviderInner, { ...props, bus: busRef.current })));
7884
+ };
7988
7885
 
7989
7886
  // src/hooks/useConnected.ts
7990
- import React3 from "react";
7887
+ import React5 from "react";
7991
7888
  var useConnected = () => {
7992
- const context = React3.useContext(
7889
+ const context = React5.useContext(
7993
7890
  ConnectedXMClientContext
7994
7891
  );
7995
7892
  if (!context) {
@@ -8424,12 +8321,6 @@ var PaymentIntentSource = /* @__PURE__ */ ((PaymentIntentSource2) => {
8424
8321
  PaymentIntentSource2["booking"] = "booking";
8425
8322
  return PaymentIntentSource2;
8426
8323
  })(PaymentIntentSource || {});
8427
- var ThreadCircleAccountRole = /* @__PURE__ */ ((ThreadCircleAccountRole2) => {
8428
- ThreadCircleAccountRole2["member"] = "member";
8429
- ThreadCircleAccountRole2["manager"] = "manager";
8430
- ThreadCircleAccountRole2["invited"] = "invited";
8431
- return ThreadCircleAccountRole2;
8432
- })(ThreadCircleAccountRole || {});
8433
8324
  var ThreadMessageType = /* @__PURE__ */ ((ThreadMessageType2) => {
8434
8325
  ThreadMessageType2["user"] = "user";
8435
8326
  ThreadMessageType2["bot"] = "bot";
@@ -8575,7 +8466,7 @@ var useConnectedMutation = (mutation, options) => {
8575
8466
  var useConnectedMutation_default = useConnectedMutation;
8576
8467
 
8577
8468
  // src/mutations/accounts/useFollowAccount.ts
8578
- import { produce as produce6 } from "immer";
8469
+ import { produce as produce5 } from "immer";
8579
8470
  var FollowAccount = async ({
8580
8471
  accountId,
8581
8472
  clientApiParams,
@@ -8588,7 +8479,7 @@ var FollowAccount = async ({
8588
8479
  if (queryClient && data.status === "ok") {
8589
8480
  queryClient.setQueryData(
8590
8481
  [...ACCOUNT_FOLLOW_STATS_QUERY_KEY(data.data.id), clientApiParams.locale],
8591
- (prev) => produce6(prev, (data2) => {
8482
+ (prev) => produce5(prev, (data2) => {
8592
8483
  if (data2?.data) {
8593
8484
  data2.data.followers = data2.data.followers + 1;
8594
8485
  }
@@ -8599,7 +8490,7 @@ var FollowAccount = async ({
8599
8490
  ...ACCOUNT_FOLLOW_STATS_QUERY_KEY(data.data.username),
8600
8491
  clientApiParams.locale
8601
8492
  ],
8602
- (prev) => produce6(prev, (data2) => {
8493
+ (prev) => produce5(prev, (data2) => {
8603
8494
  if (data2?.data) {
8604
8495
  data2.data.followers = data2.data.followers + 1;
8605
8496
  }
@@ -8622,7 +8513,7 @@ var useFollowAccount = (options = {}) => {
8622
8513
  };
8623
8514
 
8624
8515
  // src/mutations/accounts/useUnfollowAccount.ts
8625
- import { produce as produce7 } from "immer";
8516
+ import { produce as produce6 } from "immer";
8626
8517
  var UnfollowAccount = async ({
8627
8518
  accountId,
8628
8519
  clientApiParams,
@@ -8635,7 +8526,7 @@ var UnfollowAccount = async ({
8635
8526
  if (queryClient && data.status === "ok") {
8636
8527
  queryClient.setQueryData(
8637
8528
  [...ACCOUNT_FOLLOW_STATS_QUERY_KEY(data.data.id), clientApiParams.locale],
8638
- (prev) => produce7(prev, (data2) => {
8529
+ (prev) => produce6(prev, (data2) => {
8639
8530
  if (data2?.data) {
8640
8531
  data2.data.followers = data2.data.followers - 1;
8641
8532
  }
@@ -8646,7 +8537,7 @@ var UnfollowAccount = async ({
8646
8537
  ...ACCOUNT_FOLLOW_STATS_QUERY_KEY(data.data.username),
8647
8538
  clientApiParams.locale
8648
8539
  ],
8649
- (prev) => produce7(prev, (data2) => {
8540
+ (prev) => produce6(prev, (data2) => {
8650
8541
  if (data2?.data) {
8651
8542
  data2.data.followers = data2.data.followers - 1;
8652
8543
  }
@@ -8717,11 +8608,11 @@ var useUnblockAccount = (options = {}) => {
8717
8608
  };
8718
8609
 
8719
8610
  // src/mutations/activities/optimistic/UpdateComments.ts
8720
- import { produce as produce8 } from "immer";
8611
+ import { produce as produce7 } from "immer";
8721
8612
  var UpdateCommentsSingle = (increment, queryClient, KEY) => {
8722
8613
  queryClient.setQueryData(
8723
8614
  KEY,
8724
- (originalData) => produce8(originalData, (draft) => {
8615
+ (originalData) => produce7(originalData, (draft) => {
8725
8616
  if (!draft?.data) {
8726
8617
  return;
8727
8618
  }
@@ -8733,7 +8624,7 @@ var UpdateCommentsSingle = (increment, queryClient, KEY) => {
8733
8624
  var UpdateCommentsInfinite = (increment, queryClient, KEY, activityId) => {
8734
8625
  queryClient.setQueriesData(
8735
8626
  { queryKey: KEY, exact: false },
8736
- (originalData) => produce8(originalData, (draft) => {
8627
+ (originalData) => produce7(originalData, (draft) => {
8737
8628
  if (!draft?.pages || draft.pages.length === 0) {
8738
8629
  return;
8739
8630
  }
@@ -8778,7 +8669,7 @@ var CreateActivity = async ({
8778
8669
  let nested = false;
8779
8670
  if (activity.commentedId) {
8780
8671
  nested = true;
8781
- AppendInfiniteQuery(
8672
+ InfiniteQueryHelpers_exports.prepend(
8782
8673
  queryClient,
8783
8674
  [
8784
8675
  ...ACTIVITY_COMMENTS_QUERY_KEY(activity.commentedId),
@@ -8817,22 +8708,22 @@ var CreateActivity = async ({
8817
8708
  ),
8818
8709
  ...GetBaseInfiniteQueryKeys(clientApiParams.locale)
8819
8710
  ];
8820
- AppendInfiniteQuery(
8711
+ InfiniteQueryHelpers_exports.prepend(
8821
8712
  queryClient,
8822
8713
  iDIDKey,
8823
8714
  data.data
8824
8715
  );
8825
- AppendInfiniteQuery(
8716
+ InfiniteQueryHelpers_exports.prepend(
8826
8717
  queryClient,
8827
8718
  iDSlugKey,
8828
8719
  data.data
8829
8720
  );
8830
- AppendInfiniteQuery(
8721
+ InfiniteQueryHelpers_exports.prepend(
8831
8722
  queryClient,
8832
8723
  slugIDKey,
8833
8724
  data.data
8834
8725
  );
8835
- AppendInfiniteQuery(
8726
+ InfiniteQueryHelpers_exports.prepend(
8836
8727
  queryClient,
8837
8728
  slugSlugKey,
8838
8729
  data.data
@@ -8848,12 +8739,12 @@ var CreateActivity = async ({
8848
8739
  ...EVENT_ACTIVITIES_QUERY_KEY(data.data.event?.slug || ""),
8849
8740
  ...GetBaseInfiniteQueryKeys(clientApiParams.locale)
8850
8741
  ];
8851
- AppendInfiniteQuery(
8742
+ InfiniteQueryHelpers_exports.prepend(
8852
8743
  queryClient,
8853
8744
  iDKey,
8854
8745
  data.data
8855
8746
  );
8856
- AppendInfiniteQuery(
8747
+ InfiniteQueryHelpers_exports.prepend(
8857
8748
  queryClient,
8858
8749
  slugKey,
8859
8750
  data.data
@@ -8869,19 +8760,19 @@ var CreateActivity = async ({
8869
8760
  ...GROUP_ACTIVITIES_QUERY_KEY(data.data.group?.slug || ""),
8870
8761
  ...GetBaseInfiniteQueryKeys(clientApiParams.locale)
8871
8762
  ];
8872
- AppendInfiniteQuery(
8763
+ InfiniteQueryHelpers_exports.prepend(
8873
8764
  queryClient,
8874
8765
  iDKey,
8875
8766
  data.data
8876
8767
  );
8877
- AppendInfiniteQuery(
8768
+ InfiniteQueryHelpers_exports.prepend(
8878
8769
  queryClient,
8879
8770
  slugKey,
8880
8771
  data.data
8881
8772
  );
8882
8773
  }
8883
8774
  if (!nested) {
8884
- AppendInfiniteQuery(
8775
+ InfiniteQueryHelpers_exports.prepend(
8885
8776
  queryClient,
8886
8777
  [
8887
8778
  ...ACTIVITIES_QUERY_KEY(),
@@ -8917,11 +8808,11 @@ var useDeleteActivity = (options = {}) => {
8917
8808
  };
8918
8809
 
8919
8810
  // src/mutations/activities/optimistic/UpdateLikes.ts
8920
- import { produce as produce9 } from "immer";
8811
+ import { produce as produce8 } from "immer";
8921
8812
  var UpdateLikesSingle = (increment, queryClient, KEY) => {
8922
8813
  queryClient.setQueryData(
8923
8814
  KEY,
8924
- (originalData) => produce9(originalData, (draft) => {
8815
+ (originalData) => produce8(originalData, (draft) => {
8925
8816
  if (!draft?.data) {
8926
8817
  return;
8927
8818
  }
@@ -8933,7 +8824,7 @@ var UpdateLikesSingle = (increment, queryClient, KEY) => {
8933
8824
  var UpdateLikesInfinite = (increment, queryClient, KEY, activityId) => {
8934
8825
  queryClient.setQueriesData(
8935
8826
  { queryKey: KEY, exact: false },
8936
- (originalData) => produce9(originalData, (draft) => {
8827
+ (originalData) => produce8(originalData, (draft) => {
8937
8828
  if (!draft?.pages || draft.pages.length === 0) {
8938
8829
  return;
8939
8830
  }
@@ -10406,170 +10297,6 @@ var useUpdateSelfLead = (options = {}) => {
10406
10297
  return useConnectedMutation_default(UpdateSelfLead, options);
10407
10298
  };
10408
10299
 
10409
- // src/mutations/self/chat/useAddSelfChatChannelMember.ts
10410
- var AddSelfChatChannelMember = async ({
10411
- channelId,
10412
- accountId,
10413
- clientApiParams,
10414
- queryClient
10415
- }) => {
10416
- const clientApi = await GetClientAPI(clientApiParams);
10417
- const { data } = await clientApi.post(
10418
- `/self/chat/channels/${channelId}/members/${accountId}`
10419
- );
10420
- if (queryClient && data.status === "ok") {
10421
- queryClient.invalidateQueries({
10422
- queryKey: SELF_CHAT_CHANNEL_MEMBERS_QUERY_KEY(channelId)
10423
- });
10424
- }
10425
- return data;
10426
- };
10427
- var useAddSelfChatChannelMember = (options = {}) => {
10428
- return useConnectedMutation_default(AddSelfChatChannelMember, options);
10429
- };
10430
-
10431
- // src/mutations/self/chat/useCreateSelfChatChannel.ts
10432
- var CreateSelfChatChannel = async ({
10433
- name,
10434
- accountIds,
10435
- clientApiParams,
10436
- queryClient
10437
- }) => {
10438
- const clientApi = await GetClientAPI(clientApiParams);
10439
- const { data } = await clientApi.post(
10440
- `/self/chat/channels`,
10441
- {
10442
- name,
10443
- accountIds
10444
- }
10445
- );
10446
- if (queryClient && data.status === "ok") {
10447
- queryClient.invalidateQueries({
10448
- queryKey: SELF_CHAT_CHANNELS_QUERY_KEY()
10449
- });
10450
- }
10451
- return data;
10452
- };
10453
- var useCreateSelfChatChannel = (options = {}) => {
10454
- return useConnectedMutation_default(CreateSelfChatChannel, options);
10455
- };
10456
-
10457
- // src/mutations/self/chat/useCreateSelfChatChannelMessage.ts
10458
- var CreateSelfChatChannelMessage = async ({
10459
- channelId,
10460
- text,
10461
- queryClient,
10462
- clientApiParams
10463
- }) => {
10464
- const clientApi = await GetClientAPI(clientApiParams);
10465
- const { data } = await clientApi.post(`/self/chat/channels/${channelId}/messages`, {
10466
- text
10467
- });
10468
- if (queryClient && data.status === "ok") {
10469
- queryClient.invalidateQueries({
10470
- queryKey: SELF_CHAT_CHANNEL_MESSAGES_QUERY_KEY(channelId.toString())
10471
- });
10472
- }
10473
- return data;
10474
- };
10475
- var useCreateSelfChatChannelMessage = (options = {}) => {
10476
- return useConnectedMutation_default(CreateSelfChatChannelMessage, options);
10477
- };
10478
-
10479
- // src/mutations/self/chat/useDeleteSelfChatChannel.ts
10480
- var DeleteSelfChatChannel = async ({
10481
- channelId,
10482
- clientApiParams,
10483
- queryClient
10484
- }) => {
10485
- const clientApi = await GetClientAPI(clientApiParams);
10486
- const { data } = await clientApi.delete(
10487
- `/self/chat/channels/${channelId}`
10488
- );
10489
- if (queryClient && data.status === "ok") {
10490
- queryClient.invalidateQueries({ queryKey: SELF_CHAT_CHANNELS_QUERY_KEY() });
10491
- queryClient.removeQueries({
10492
- queryKey: SELF_CHAT_CHANNEL_QUERY_KEY(channelId)
10493
- });
10494
- }
10495
- return data;
10496
- };
10497
- var useDeleteSelfChatChannel = (options = {}) => {
10498
- return useConnectedMutation_default(DeleteSelfChatChannel, options);
10499
- };
10500
-
10501
- // src/mutations/self/chat/useDeleteSelfChatChannelMessage.ts
10502
- var DeleteSelfChatChannelMessage = async ({
10503
- channelId,
10504
- messageId,
10505
- clientApiParams,
10506
- queryClient
10507
- }) => {
10508
- const clientApi = await GetClientAPI(clientApiParams);
10509
- const { data } = await clientApi.delete(
10510
- `/self/chat/channels/${channelId}/messages/${messageId}`
10511
- );
10512
- if (queryClient && data.status === "ok") {
10513
- queryClient.invalidateQueries({
10514
- queryKey: SELF_CHAT_CHANNEL_MESSAGES_QUERY_KEY(channelId)
10515
- });
10516
- }
10517
- return data;
10518
- };
10519
- var useDeleteSelfChatChannelMessage = (options = {}) => {
10520
- return useConnectedMutation_default(DeleteSelfChatChannelMessage, options);
10521
- };
10522
-
10523
- // src/mutations/self/chat/useLeaveSelfChatChannel.ts
10524
- var LeaveSelfChatChannel = async ({
10525
- channelId,
10526
- clientApiParams,
10527
- queryClient
10528
- }) => {
10529
- const clientApi = await GetClientAPI(clientApiParams);
10530
- const { data } = await clientApi.delete(
10531
- `/self/chat/channels/${channelId}/leave`
10532
- );
10533
- if (queryClient && data.status === "ok") {
10534
- queryClient.invalidateQueries({ queryKey: SELF_CHAT_CHANNELS_QUERY_KEY() });
10535
- queryClient.removeQueries({
10536
- queryKey: SELF_CHAT_CHANNEL_QUERY_KEY(channelId)
10537
- });
10538
- }
10539
- return data;
10540
- };
10541
- var useLeaveSelfChatChannel = (options = {}) => {
10542
- return useConnectedMutation_default(LeaveSelfChatChannel, options);
10543
- };
10544
-
10545
- // src/mutations/self/chat/useUpdateSelfChatChannelNotifications.ts
10546
- var UpdateSelfChatChannelNotifications = async ({
10547
- channelId,
10548
- notifications,
10549
- clientApiParams,
10550
- queryClient
10551
- }) => {
10552
- const clientApi = await GetClientAPI(clientApiParams);
10553
- const { data } = await clientApi.put(
10554
- `/self/chat/channels/${channelId}/notifications`,
10555
- {
10556
- notifications
10557
- }
10558
- );
10559
- if (queryClient && data.status === "ok") {
10560
- SET_SELF_CHAT_CHANNEL_QUERY_DATA(queryClient, [channelId], data, [
10561
- clientApiParams.locale
10562
- ]);
10563
- queryClient.invalidateQueries({
10564
- queryKey: SELF_CHAT_CHANNELS_QUERY_KEY()
10565
- });
10566
- }
10567
- return data;
10568
- };
10569
- var useUpdateSelfChatChannelNotifications = (options = {}) => {
10570
- return useConnectedMutation_default(UpdateSelfChatChannelNotifications, options);
10571
- };
10572
-
10573
10300
  // src/mutations/self/useAddSelfEventSession.ts
10574
10301
  var AddSelfEventSession = async ({
10575
10302
  eventId,
@@ -10866,7 +10593,7 @@ var CreateSupportTicket = async ({
10866
10593
  SET_SUPPORT_TICKET_QUERY_DATA(queryClient, [data.data.id], data, [
10867
10594
  clientApiParams.locale
10868
10595
  ]);
10869
- AppendInfiniteQuery(
10596
+ InfiniteQueryHelpers_exports.prepend(
10870
10597
  queryClient,
10871
10598
  [
10872
10599
  ...SUPPORT_TICKETS_QUERY_KEY(type, data.data.state),
@@ -10874,7 +10601,7 @@ var CreateSupportTicket = async ({
10874
10601
  ],
10875
10602
  data.data
10876
10603
  );
10877
- AppendInfiniteQuery(
10604
+ InfiniteQueryHelpers_exports.prepend(
10878
10605
  queryClient,
10879
10606
  [
10880
10607
  ...SUPPORT_TICKETS_QUERY_KEY(),
@@ -10899,7 +10626,7 @@ var CreateSupportTicketMessage = async ({
10899
10626
  const clientApi = await GetClientAPI(clientApiParams);
10900
10627
  const { data } = await clientApi.post(`/supportTickets/${supportTicketId}/messages`, { message });
10901
10628
  if (queryClient && data.status === "ok") {
10902
- AppendInfiniteQuery(
10629
+ InfiniteQueryHelpers_exports.prepend(
10903
10630
  queryClient,
10904
10631
  [
10905
10632
  ...SUPPORT_TICKET_MESSAGES_QUERY_KEY(supportTicketId),
@@ -12316,7 +12043,7 @@ var CreateStreamChatMessage = async ({
12316
12043
  ...STREAM_CHAT_MESSAGES_QUERY_KEY(streamId, sessionId),
12317
12044
  ...GetBaseInfiniteQueryKeys(clientApiParams.locale)
12318
12045
  ];
12319
- AppendInfiniteQuery(queryClient, QueryKey4, data.data);
12046
+ InfiniteQueryHelpers_exports.prepend(queryClient, QueryKey4, data.data);
12320
12047
  }
12321
12048
  return data;
12322
12049
  };
@@ -12325,7 +12052,7 @@ var useCreateStreamChatMessage = (options = {}) => {
12325
12052
  };
12326
12053
 
12327
12054
  // src/mutations/streams/useUpdateStreamChatMessage.ts
12328
- import { produce as produce10 } from "immer";
12055
+ import { produce as produce9 } from "immer";
12329
12056
  var UpdateStreamChatMessage = async ({
12330
12057
  streamId,
12331
12058
  sessionId,
@@ -12349,7 +12076,7 @@ var UpdateStreamChatMessage = async ({
12349
12076
  queryClient.setQueryData(
12350
12077
  QueryKey4,
12351
12078
  (oldData) => {
12352
- return produce10(oldData, (draft) => {
12079
+ return produce9(oldData, (draft) => {
12353
12080
  if (draft?.pages) {
12354
12081
  for (const page of draft.pages) {
12355
12082
  if (page?.data) {
@@ -12396,6 +12123,31 @@ var useDeleteStreamChatMessage = (options = {}) => {
12396
12123
  return useConnectedMutation(DeleteStreamChatMessage, options);
12397
12124
  };
12398
12125
 
12126
+ // src/mutations/threads/useCreateThread.ts
12127
+ var CreateThread = async ({
12128
+ accountIds,
12129
+ subject,
12130
+ imageId,
12131
+ clientApiParams,
12132
+ queryClient
12133
+ }) => {
12134
+ const clientApi = await GetClientAPI(clientApiParams);
12135
+ const { data } = await clientApi.post(`/threads`, {
12136
+ accountIds,
12137
+ subject,
12138
+ imageId
12139
+ });
12140
+ if (queryClient && data.status === "ok") {
12141
+ queryClient.invalidateQueries({
12142
+ queryKey: THREADS_QUERY_KEY()
12143
+ });
12144
+ }
12145
+ return data;
12146
+ };
12147
+ var useCreateThread = (options = {}) => {
12148
+ return useConnectedMutation(CreateThread, options);
12149
+ };
12150
+
12399
12151
  // src/mutations/threads/useUpdateThread.ts
12400
12152
  var UpdateThread = async ({
12401
12153
  threadId,
@@ -12420,6 +12172,51 @@ var useUpdateThread = (options = {}) => {
12420
12172
  return useConnectedMutation(UpdateThread, options);
12421
12173
  };
12422
12174
 
12175
+ // src/mutations/threads/useMarkThreadRead.ts
12176
+ var MarkThreadRead = async ({
12177
+ threadId,
12178
+ messageId,
12179
+ clientApiParams
12180
+ }) => {
12181
+ const clientApi = await GetClientAPI(clientApiParams);
12182
+ const { data } = await clientApi.post(`/threads/${threadId}/read`, {
12183
+ messageId
12184
+ });
12185
+ return data;
12186
+ };
12187
+ var useMarkThreadRead = (options = {}) => {
12188
+ return useConnectedMutation(MarkThreadRead, options);
12189
+ };
12190
+
12191
+ // src/mutations/threads/useMarkThreadMessageRead.ts
12192
+ var MarkThreadMessageRead = async ({
12193
+ threadId,
12194
+ messageId,
12195
+ clientApiParams
12196
+ }) => {
12197
+ const clientApi = await GetClientAPI(clientApiParams);
12198
+ const { data } = await clientApi.post(
12199
+ `/threads/${threadId}/messages/${messageId}/read`
12200
+ );
12201
+ return data;
12202
+ };
12203
+ var useMarkThreadMessageRead = (options = {}) => {
12204
+ return useConnectedMutation(MarkThreadMessageRead, options);
12205
+ };
12206
+
12207
+ // src/mutations/threads/useSendThreadTyping.ts
12208
+ var SendThreadTyping = async ({
12209
+ threadId,
12210
+ clientApiParams
12211
+ }) => {
12212
+ const clientApi = await GetClientAPI(clientApiParams);
12213
+ const { data } = await clientApi.post(`/threads/${threadId}/typing`, {});
12214
+ return data;
12215
+ };
12216
+ var useSendThreadTyping = (options = {}) => {
12217
+ return useConnectedMutation(SendThreadTyping, options);
12218
+ };
12219
+
12423
12220
  // src/mutations/threads/useCreateThreadMessage.ts
12424
12221
  var CreateThreadMessage = async ({
12425
12222
  threadId,
@@ -12434,7 +12231,7 @@ var CreateThreadMessage = async ({
12434
12231
  entities
12435
12232
  });
12436
12233
  if (queryClient && data.status === "ok") {
12437
- AppendInfiniteQuery(
12234
+ InfiniteQueryHelpers_exports.prepend(
12438
12235
  queryClient,
12439
12236
  THREAD_MESSAGES_QUERY_KEY(threadId),
12440
12237
  data.data
@@ -12543,106 +12340,6 @@ var useRemoveThreadMessageReaction = (options = {}) => {
12543
12340
  return useConnectedMutation(RemoveThreadMessageReaction, options);
12544
12341
  };
12545
12342
 
12546
- // src/mutations/threads/useUpdateThreadCircle.ts
12547
- var UpdateThreadCircle = async ({
12548
- circleId,
12549
- name,
12550
- clientApiParams,
12551
- queryClient
12552
- }) => {
12553
- const clientApi = await GetClientAPI(clientApiParams);
12554
- const { data } = await clientApi.put(`/threads/circles/${circleId}`, {
12555
- name
12556
- });
12557
- if (queryClient && data.status === "ok") {
12558
- SET_THREAD_CIRCLE_QUERY_DATA(queryClient, [circleId], data, [
12559
- clientApiParams.locale
12560
- ]);
12561
- }
12562
- return data;
12563
- };
12564
- var useUpdateThreadCircle = (options = {}) => {
12565
- return useConnectedMutation(UpdateThreadCircle, options);
12566
- };
12567
-
12568
- // src/mutations/threads/useAddThreadCircleAccount.ts
12569
- var AddThreadCircleAccount = async ({
12570
- circleId,
12571
- accountId,
12572
- role,
12573
- clientApiParams,
12574
- queryClient
12575
- }) => {
12576
- const clientApi = await GetClientAPI(clientApiParams);
12577
- const { data } = await clientApi.post(
12578
- `/threads/circles/${circleId}/accounts`,
12579
- {
12580
- accountId,
12581
- role
12582
- }
12583
- );
12584
- if (queryClient && data.status === "ok") {
12585
- queryClient.invalidateQueries({
12586
- queryKey: THREAD_CIRCLE_ACCOUNTS_QUERY_KEY(circleId)
12587
- });
12588
- }
12589
- return data;
12590
- };
12591
- var useAddThreadCircleAccount = (options = {}) => {
12592
- return useConnectedMutation(AddThreadCircleAccount, options);
12593
- };
12594
-
12595
- // src/mutations/threads/useUpdateThreadCircleAccount.ts
12596
- var UpdateThreadCircleAccount = async ({
12597
- circleId,
12598
- accountId,
12599
- role,
12600
- clientApiParams,
12601
- queryClient
12602
- }) => {
12603
- const clientApi = await GetClientAPI(clientApiParams);
12604
- const { data } = await clientApi.put(
12605
- `/threads/circles/${circleId}/accounts/${accountId}`,
12606
- {
12607
- role
12608
- }
12609
- );
12610
- if (queryClient && data.status === "ok") {
12611
- SET_THREAD_CIRCLE_ACCOUNT_QUERY_DATA(
12612
- queryClient,
12613
- [circleId, accountId],
12614
- data,
12615
- [clientApiParams.locale]
12616
- );
12617
- }
12618
- return data;
12619
- };
12620
- var useUpdateThreadCircleAccount = (options = {}) => {
12621
- return useConnectedMutation(UpdateThreadCircleAccount, options);
12622
- };
12623
-
12624
- // src/mutations/threads/useDeleteThreadCircleAccount.ts
12625
- var DeleteThreadCircleAccount = async ({
12626
- circleId,
12627
- accountId,
12628
- clientApiParams,
12629
- queryClient
12630
- }) => {
12631
- const clientApi = await GetClientAPI(clientApiParams);
12632
- const { data } = await clientApi.delete(
12633
- `/threads/circles/${circleId}/accounts/${accountId}`
12634
- );
12635
- if (queryClient && data.status === "ok") {
12636
- queryClient.invalidateQueries({
12637
- queryKey: THREAD_CIRCLE_ACCOUNTS_QUERY_KEY(circleId)
12638
- });
12639
- }
12640
- return data;
12641
- };
12642
- var useDeleteThreadCircleAccount = (options = {}) => {
12643
- return useConnectedMutation(DeleteThreadCircleAccount, options);
12644
- };
12645
-
12646
12343
  // src/mutations/integrations/useBlockIntegration.ts
12647
12344
  var BlockIntegration = async ({
12648
12345
  type,
@@ -12848,6 +12545,179 @@ var CreateInterest = async ({
12848
12545
  var useCreateInterest = (options = {}) => {
12849
12546
  return useConnectedMutation_default(CreateInterest, options);
12850
12547
  };
12548
+
12549
+ // src/socket/threads/ThreadMessageCreatedEffect.tsx
12550
+ import React6 from "react";
12551
+ import { useQueryClient as useQueryClient3 } from "@tanstack/react-query";
12552
+ import { produce as produce10 } from "immer";
12553
+ var ThreadMessageCreatedEffect = () => {
12554
+ const queryClient = useQueryClient3();
12555
+ const { locale } = useConnected();
12556
+ const handler = React6.useCallback(
12557
+ (payload) => {
12558
+ const messagesKey = [
12559
+ ...THREAD_MESSAGES_QUERY_KEY(payload.threadId),
12560
+ ...GetBaseInfiniteQueryKeys(locale || "en")
12561
+ ];
12562
+ const existing = queryClient.getQueryData(messagesKey);
12563
+ const alreadyCached = existing ? MergeInfinitePages(existing).some(
12564
+ (msg) => msg.id === payload.message.id
12565
+ ) : false;
12566
+ if (!alreadyCached) {
12567
+ prepend(queryClient, messagesKey, payload.message);
12568
+ }
12569
+ const threadsKey = [
12570
+ ...THREADS_QUERY_KEY(),
12571
+ ...GetBaseInfiniteQueryKeys(locale || "en")
12572
+ ];
12573
+ queryClient.setQueryData(
12574
+ threadsKey,
12575
+ (oldData) => {
12576
+ if (!oldData) return oldData;
12577
+ return produce10(oldData, (draft) => {
12578
+ let found = null;
12579
+ let foundPageIdx = -1;
12580
+ let foundIdx = -1;
12581
+ for (let p = 0; p < draft.pages.length; p++) {
12582
+ const page = draft.pages[p];
12583
+ if (!page?.data) continue;
12584
+ const idx = page.data.findIndex(
12585
+ (t) => t.id === payload.threadId
12586
+ );
12587
+ if (idx !== -1) {
12588
+ found = page.data[idx];
12589
+ foundPageIdx = p;
12590
+ foundIdx = idx;
12591
+ break;
12592
+ }
12593
+ }
12594
+ if (found && foundPageIdx !== -1) {
12595
+ const sourcePage = draft.pages[foundPageIdx];
12596
+ if (sourcePage?.data) {
12597
+ sourcePage.data.splice(foundIdx, 1);
12598
+ }
12599
+ found.lastMessageAt = payload.message.sentAt;
12600
+ found.lastMessage = payload.message.body;
12601
+ const firstPage = draft.pages[0];
12602
+ if (firstPage?.data) {
12603
+ firstPage.data.unshift(found);
12604
+ }
12605
+ }
12606
+ });
12607
+ }
12608
+ );
12609
+ },
12610
+ [queryClient, locale]
12611
+ );
12612
+ useWSEvent("thread.message.created", handler);
12613
+ return null;
12614
+ };
12615
+
12616
+ // src/socket/threads/ThreadMessageUpdatedEffect.tsx
12617
+ import React7 from "react";
12618
+ import { useQueryClient as useQueryClient4 } from "@tanstack/react-query";
12619
+ var ThreadMessageUpdatedEffect = () => {
12620
+ const queryClient = useQueryClient4();
12621
+ const { locale } = useConnected();
12622
+ const handler = React7.useCallback(
12623
+ (payload) => {
12624
+ const messagesKey = [
12625
+ ...THREAD_MESSAGES_QUERY_KEY(payload.threadId),
12626
+ ...GetBaseInfiniteQueryKeys(locale || "en")
12627
+ ];
12628
+ update(queryClient, messagesKey, payload.message);
12629
+ },
12630
+ [queryClient, locale]
12631
+ );
12632
+ useWSEvent("thread.message.updated", handler);
12633
+ return null;
12634
+ };
12635
+
12636
+ // src/socket/threads/ThreadMessageDeletedEffect.tsx
12637
+ import React8 from "react";
12638
+ import { useQueryClient as useQueryClient5 } from "@tanstack/react-query";
12639
+ var ThreadMessageDeletedEffect = () => {
12640
+ const queryClient = useQueryClient5();
12641
+ const { locale } = useConnected();
12642
+ const handler = React8.useCallback(
12643
+ (payload) => {
12644
+ const messagesKey = [
12645
+ ...THREAD_MESSAGES_QUERY_KEY(payload.threadId),
12646
+ ...GetBaseInfiniteQueryKeys(locale || "en")
12647
+ ];
12648
+ remove(queryClient, messagesKey, payload.messageId);
12649
+ },
12650
+ [queryClient, locale]
12651
+ );
12652
+ useWSEvent("thread.message.deleted", handler);
12653
+ return null;
12654
+ };
12655
+
12656
+ // src/socket/threads/ThreadReadEffect.tsx
12657
+ import React9 from "react";
12658
+ import { useQueryClient as useQueryClient6 } from "@tanstack/react-query";
12659
+ import { produce as produce11 } from "immer";
12660
+ var ThreadReadEffect = () => {
12661
+ const queryClient = useQueryClient6();
12662
+ const { locale } = useConnected();
12663
+ const { data: self } = useGetSelf();
12664
+ const selfId = self?.data?.id;
12665
+ const handler = React9.useCallback(
12666
+ (payload) => {
12667
+ const accountsKey = [
12668
+ ...THREAD_ACCOUNTS_QUERY_KEY(payload.threadId),
12669
+ ...GetBaseInfiniteQueryKeys(locale || "en")
12670
+ ];
12671
+ queryClient.setQueryData(
12672
+ accountsKey,
12673
+ (oldData) => {
12674
+ if (!oldData) return oldData;
12675
+ return produce11(oldData, (draft) => {
12676
+ for (const page of draft.pages) {
12677
+ if (!page?.data) continue;
12678
+ const idx = page.data.findIndex(
12679
+ (entry) => entry.accountId === payload.accountId
12680
+ );
12681
+ if (idx !== -1) {
12682
+ page.data[idx].lastReadAt = payload.readAt;
12683
+ return;
12684
+ }
12685
+ }
12686
+ });
12687
+ }
12688
+ );
12689
+ if (!selfId || payload.accountId !== selfId) return;
12690
+ const threadsKey = [
12691
+ ...THREADS_QUERY_KEY(),
12692
+ ...GetBaseInfiniteQueryKeys(locale || "en")
12693
+ ];
12694
+ queryClient.setQueryData(
12695
+ threadsKey,
12696
+ (oldData) => {
12697
+ if (!oldData) return oldData;
12698
+ return produce11(oldData, (draft) => {
12699
+ for (const page of draft.pages) {
12700
+ if (!page?.data) continue;
12701
+ const idx = page.data.findIndex(
12702
+ (t) => t.id === payload.threadId
12703
+ );
12704
+ if (idx !== -1) {
12705
+ const row = page.data[idx];
12706
+ if (row?._count) {
12707
+ row._count.messages = 0;
12708
+ return;
12709
+ }
12710
+ }
12711
+ }
12712
+ });
12713
+ }
12714
+ );
12715
+ },
12716
+ [queryClient, locale, selfId]
12717
+ );
12718
+ useWSEvent("thread.read", handler);
12719
+ return null;
12720
+ };
12851
12721
  export {
12852
12722
  ACCOUNTS_POPULAR_QUERY_KEY,
12853
12723
  ACCOUNTS_QUERY_KEY,
@@ -12876,13 +12746,10 @@ export {
12876
12746
  AddListingCoHost,
12877
12747
  AddListingSponsor,
12878
12748
  AddLogin,
12879
- AddSelfChatChannelMember,
12880
12749
  AddSelfEventSession,
12881
12750
  AddSelfInterests,
12882
- AddThreadCircleAccount,
12883
12751
  AddThreadMessageReaction,
12884
12752
  AdvertisementType,
12885
- AppendInfiniteQuery,
12886
12753
  ApplyEventRegistrationCoupon,
12887
12754
  BENEFITS_QUERY_KEY,
12888
12755
  BOOKINGS_QUERY_KEY,
@@ -12944,12 +12811,11 @@ export {
12944
12811
  CreateListingSpeaker,
12945
12812
  CreateLoginAccount,
12946
12813
  CreateSelfAddress,
12947
- CreateSelfChatChannel,
12948
- CreateSelfChatChannelMessage,
12949
12814
  CreateSelfLead,
12950
12815
  CreateStreamChatMessage,
12951
12816
  CreateSupportTicket,
12952
12817
  CreateSupportTicketMessage,
12818
+ CreateThread,
12953
12819
  CreateThreadMessage,
12954
12820
  DayOfWeek,
12955
12821
  DeactivateGroup,
@@ -12968,12 +12834,9 @@ export {
12968
12834
  DeleteListingSpeaker,
12969
12835
  DeleteSelf,
12970
12836
  DeleteSelfAddress,
12971
- DeleteSelfChatChannel,
12972
- DeleteSelfChatChannelMessage,
12973
12837
  DeleteSelfLead,
12974
12838
  DeleteSelfPushDevice,
12975
12839
  DeleteStreamChatMessage,
12976
- DeleteThreadCircleAccount,
12977
12840
  DeleteThreadMessage,
12978
12841
  DemoteGroupModerator,
12979
12842
  DisableIntegration,
@@ -13197,10 +13060,6 @@ export {
13197
13060
  GetSelfAddresses,
13198
13061
  GetSelfAnnouncement,
13199
13062
  GetSelfChannelSubscriber,
13200
- GetSelfChatChannel,
13201
- GetSelfChatChannelMembers,
13202
- GetSelfChatChannelMessages,
13203
- GetSelfChatChannels,
13204
13063
  GetSelfContacts,
13205
13064
  GetSelfEventListing,
13206
13065
  GetSelfEventListingAnnouncement,
@@ -13249,12 +13108,10 @@ export {
13249
13108
  GetSurveySubmissions,
13250
13109
  GetSurveys,
13251
13110
  GetThread,
13252
- GetThreadCircle,
13253
- GetThreadCircleAccount,
13254
- GetThreadCircleAccounts,
13255
- GetThreadCircles,
13111
+ GetThreadAccounts,
13256
13112
  GetThreadMessage,
13257
13113
  GetThreadMessages,
13114
+ GetThreads,
13258
13115
  GetUsernameAvailability,
13259
13116
  GetVideo,
13260
13117
  GroupAccess,
@@ -13272,6 +13129,7 @@ export {
13272
13129
  INVOICE_PAYMENTS_QUERY_KEY,
13273
13130
  INVOICE_QUERY_KEY,
13274
13131
  ImageType,
13132
+ InfiniteQueryHelpers_exports as InfiniteQueryHelpers,
13275
13133
  IntegrationType,
13276
13134
  InvoiceStatus,
13277
13135
  JoinGroup,
@@ -13299,11 +13157,12 @@ export {
13299
13157
  LOGIN_QUERY_KEY,
13300
13158
  LeadStatus,
13301
13159
  LeaveGroup,
13302
- LeaveSelfChatChannel,
13303
13160
  LikeActivity,
13304
13161
  LikeContent,
13305
13162
  LocationQuestionOption,
13306
13163
  MEETING_QUERY_KEY,
13164
+ MarkThreadMessageRead,
13165
+ MarkThreadRead,
13307
13166
  MeetingType,
13308
13167
  MergeInfinitePages,
13309
13168
  NotificationType,
@@ -13346,10 +13205,6 @@ export {
13346
13205
  SELF_ANNOUNCEMENT_QUERY_KEY,
13347
13206
  SELF_BOOKING_INTENT_QUERY_KEY,
13348
13207
  SELF_CHANNEL_SUBSCRIBER_QUERY_KEY,
13349
- SELF_CHAT_CHANNELS_QUERY_KEY,
13350
- SELF_CHAT_CHANNEL_MEMBERS_QUERY_KEY,
13351
- SELF_CHAT_CHANNEL_MESSAGES_QUERY_KEY,
13352
- SELF_CHAT_CHANNEL_QUERY_KEY,
13353
13208
  SELF_CONTACTS_QUERY_KEY,
13354
13209
  SELF_EVENTS_QUERY_KEY,
13355
13210
  SELF_EVENT_SESSIONS_QUERY_KEY,
@@ -13473,10 +13328,6 @@ export {
13473
13328
  SET_PAYMENT_QUERY_DATA,
13474
13329
  SET_PUSH_DEVICE_QUERY_DATA,
13475
13330
  SET_SELF_CHANNEL_SUBSCRIBER_QUERY_DATA,
13476
- SET_SELF_CHAT_CHANNELS_QUERY_DATA,
13477
- SET_SELF_CHAT_CHANNEL_MEMBERS_QUERY_DATA,
13478
- SET_SELF_CHAT_CHANNEL_MESSAGES_QUERY_DATA,
13479
- SET_SELF_CHAT_CHANNEL_QUERY_DATA,
13480
13331
  SET_SELF_GROUP_MEMBERSHIP_QUERY_DATA,
13481
13332
  SET_SELF_PROFILE_QUERY_DATA,
13482
13333
  SET_SELF_QUERY_DATA,
@@ -13494,10 +13345,8 @@ export {
13494
13345
  SET_SURVEYS_QUERY_DATA,
13495
13346
  SET_SURVEY_QUERY_DATA,
13496
13347
  SET_SURVEY_SUBMISSION_SECTIONS_QUERY_DATA,
13497
- SET_THREAD_CIRCLES_QUERY_DATA,
13498
- SET_THREAD_CIRCLE_ACCOUNTS_QUERY_DATA,
13499
- SET_THREAD_CIRCLE_ACCOUNT_QUERY_DATA,
13500
- SET_THREAD_CIRCLE_QUERY_DATA,
13348
+ SET_THREADS_QUERY_DATA,
13349
+ SET_THREAD_ACCOUNTS_QUERY_DATA,
13501
13350
  SET_THREAD_MESSAGES_QUERY_DATA,
13502
13351
  SET_THREAD_MESSAGE_QUERY_DATA,
13503
13352
  SET_THREAD_QUERY_DATA,
@@ -13515,10 +13364,12 @@ export {
13515
13364
  SURVEY_SUBMISSIONS_QUERY_KEY,
13516
13365
  SURVEY_SUBMISSION_QUERY_KEY,
13517
13366
  SURVEY_SUBMISSION_SECTIONS_QUERY_KEY,
13367
+ SendThreadTyping,
13518
13368
  SeriesQuestionType,
13519
13369
  SessionAccess,
13520
13370
  SessionVisibility,
13521
13371
  SetContentPublishSchedule,
13372
+ SingleQueryHelpers_exports as SingleQueryHelpers,
13522
13373
  StartSurvey,
13523
13374
  SubmitSurvey,
13524
13375
  SupportTicketActivityLogSource,
@@ -13529,15 +13380,18 @@ export {
13529
13380
  SurveyQuestionType,
13530
13381
  SurveyStatus,
13531
13382
  THREADS_QUERY_KEY,
13532
- THREAD_CIRCLES_QUERY_KEY,
13533
- THREAD_CIRCLE_ACCOUNTS_QUERY_KEY,
13534
- THREAD_CIRCLE_ACCOUNT_QUERY_KEY,
13535
- THREAD_CIRCLE_QUERY_KEY,
13383
+ THREAD_ACCOUNTS_QUERY_KEY,
13536
13384
  THREAD_MESSAGES_QUERY_KEY,
13537
13385
  THREAD_MESSAGE_QUERY_KEY,
13538
13386
  THREAD_QUERY_KEY,
13539
- ThreadCircleAccountRole,
13387
+ ThreadMessageCreatedEffect,
13388
+ ThreadMessageDeletedEffect,
13540
13389
  ThreadMessageType,
13390
+ ThreadMessageUpdatedEffect,
13391
+ ThreadReadEffect,
13392
+ ThreadTypingEffect,
13393
+ ThreadTypingStore,
13394
+ ThreadTypingStoreProvider,
13541
13395
  TicketEventAccessLevel,
13542
13396
  TicketVisibility,
13543
13397
  TransferEventAttendeePass,
@@ -13571,7 +13425,6 @@ export {
13571
13425
  UpdateSelf,
13572
13426
  UpdateSelfAddress,
13573
13427
  UpdateSelfBanner,
13574
- UpdateSelfChatChannelNotifications,
13575
13428
  UpdateSelfGroupMembership,
13576
13429
  UpdateSelfImage,
13577
13430
  UpdateSelfLead,
@@ -13582,14 +13435,14 @@ export {
13582
13435
  UpdateSurveyResponse,
13583
13436
  UpdateSurveySearchListResponse,
13584
13437
  UpdateThread,
13585
- UpdateThreadCircle,
13586
- UpdateThreadCircleAccount,
13587
13438
  UpdateThreadMessage,
13588
13439
  UploadFile,
13589
13440
  UploadImage,
13590
13441
  UpsertLinkPreview,
13591
13442
  VIDEO_QUERY_KEY,
13592
13443
  VerifyLoginAccount,
13444
+ WSMessageBus,
13445
+ WSMessageBusProvider,
13593
13446
  isListing,
13594
13447
  isManagedCoupon,
13595
13448
  isRegistrationQuestion,
@@ -13635,10 +13488,8 @@ export {
13635
13488
  useAddListingCoHost,
13636
13489
  useAddListingSponsor,
13637
13490
  useAddLogin,
13638
- useAddSelfChatChannelMember,
13639
13491
  useAddSelfEventSession,
13640
13492
  useAddSelfInterests,
13641
- useAddThreadCircleAccount,
13642
13493
  useAddThreadMessageReaction,
13643
13494
  useApplyEventRegistrationCoupon,
13644
13495
  useBlockAccount,
@@ -13678,12 +13529,11 @@ export {
13678
13529
  useCreateListingSpeaker,
13679
13530
  useCreateLoginAccount,
13680
13531
  useCreateSelfAddress,
13681
- useCreateSelfChatChannel,
13682
- useCreateSelfChatChannelMessage,
13683
13532
  useCreateSelfLead,
13684
13533
  useCreateStreamChatMessage,
13685
13534
  useCreateSupportTicket,
13686
13535
  useCreateSupportTicketMessage,
13536
+ useCreateThread,
13687
13537
  useCreateThreadMessage,
13688
13538
  useDeactivateGroup,
13689
13539
  useDeleteActivity,
@@ -13700,12 +13550,9 @@ export {
13700
13550
  useDeleteListingSpeaker,
13701
13551
  useDeleteSelf,
13702
13552
  useDeleteSelfAddress,
13703
- useDeleteSelfChatChannel,
13704
- useDeleteSelfChatChannelMessage,
13705
13553
  useDeleteSelfLead,
13706
13554
  useDeleteSelfPushDevice,
13707
13555
  useDeleteStreamChatMessage,
13708
- useDeleteThreadCircleAccount,
13709
13556
  useDeleteThreadMessage,
13710
13557
  useDemoteGroupModerator,
13711
13558
  useDisableIntegration,
@@ -13843,10 +13690,6 @@ export {
13843
13690
  useGetSelfAddresses,
13844
13691
  useGetSelfAnnouncement,
13845
13692
  useGetSelfChannelSubscriber,
13846
- useGetSelfChatChannel,
13847
- useGetSelfChatChannelMembers,
13848
- useGetSelfChatChannelMessages,
13849
- useGetSelfChatChannels,
13850
13693
  useGetSelfContacts,
13851
13694
  useGetSelfEventListing,
13852
13695
  useGetSelfEventListingAnnouncement,
@@ -13895,12 +13738,10 @@ export {
13895
13738
  useGetSurveySubmissions,
13896
13739
  useGetSurveys,
13897
13740
  useGetThread,
13898
- useGetThreadCircle,
13899
- useGetThreadCircleAccount,
13900
- useGetThreadCircleAccounts,
13901
- useGetThreadCircles,
13741
+ useGetThreadAccounts,
13902
13742
  useGetThreadMessage,
13903
13743
  useGetThreadMessages,
13744
+ useGetThreads,
13904
13745
  useGetUsernameAvailability,
13905
13746
  useGetVideo,
13906
13747
  useGroupStatus,
@@ -13914,9 +13755,10 @@ export {
13914
13755
  useJoinMeetingViaEvent,
13915
13756
  useJoinMeetingViaGroup,
13916
13757
  useLeaveGroup,
13917
- useLeaveSelfChatChannel,
13918
13758
  useLikeActivity,
13919
13759
  useLikeContent,
13760
+ useMarkThreadMessageRead,
13761
+ useMarkThreadRead,
13920
13762
  usePromoteGroupMember,
13921
13763
  useReinviteGroupInvitation,
13922
13764
  useRejectGroupInvitation,
@@ -13932,9 +13774,11 @@ export {
13932
13774
  useRemoveSelfEventSession,
13933
13775
  useRemoveThreadMessageReaction,
13934
13776
  useReportActivity,
13777
+ useSendThreadTyping,
13935
13778
  useSetContentPublishSchedule,
13936
13779
  useStartSurvey,
13937
13780
  useSubmitSurvey,
13781
+ useThreadTyping,
13938
13782
  useTransferEventAttendeePass,
13939
13783
  useUnblockAccount,
13940
13784
  useUnbookmarkEventAttendeePassSession,
@@ -13965,7 +13809,6 @@ export {
13965
13809
  useUpdateSelf,
13966
13810
  useUpdateSelfAddress,
13967
13811
  useUpdateSelfBanner,
13968
- useUpdateSelfChatChannelNotifications,
13969
13812
  useUpdateSelfGroupMembership,
13970
13813
  useUpdateSelfImage,
13971
13814
  useUpdateSelfLead,
@@ -13976,11 +13819,11 @@ export {
13976
13819
  useUpdateSurveyResponse,
13977
13820
  useUpdateSurveySearchListResponse,
13978
13821
  useUpdateThread,
13979
- useUpdateThreadCircle,
13980
- useUpdateThreadCircleAccount,
13981
13822
  useUpdateThreadMessage,
13982
13823
  useUploadFile,
13983
13824
  useUploadImage,
13984
13825
  useUpsertLinkPreview,
13985
- useVerifyLoginAccount
13826
+ useVerifyLoginAccount,
13827
+ useWSEvent,
13828
+ useWSMessageBus
13986
13829
  };