@messenger-box/platform-mobile 0.0.1-alpha.392 → 0.0.1-alpha.393

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.
@@ -77,6 +77,7 @@ export interface AlertMessageAttachmentsInterface {
77
77
 
78
78
  interface IThreadSubscriptionHandlerProps {
79
79
  subscribeToNewMessages: () => any;
80
+ channelId: string;
80
81
  }
81
82
 
82
83
  const ThreadConversationViewComponent = ({ channelId, postParentId, isPostParentIdThread, role }: any) => {
@@ -201,19 +202,19 @@ const ThreadConversationViewComponent = ({ channelId, postParentId, isPostParent
201
202
  }, [parentId]);
202
203
 
203
204
  useEffect(() => {
204
- if (threadMessagesData?.threadMessages?.data) {
205
- const { data: threads, totalCount: threadTotalCount }: any = threadMessagesData?.threadMessages;
206
- const threadMessage = threads?.map((t: any) => t?.post);
207
-
208
- if (threadPost?.length == 0) {
209
- setThreadPost(threadMessage);
210
- setChannelMessages((oldMessages: any) => uniqBy([...threadMessage, ...oldMessages], ({ id }) => id));
211
- }
212
- // if (!isPostParentIdThread) {
213
- // // setTotalCount((pc: any) => pc + threadTotalCount);
214
- // setChannelMessages((oldMessages: any) => uniqBy([...threadMessage, ...oldMessages], ({ id }) => id));
215
- // }
205
+ //if (threadMessagesData?.threadMessages?.data) {
206
+ // console.log('threadMessagesData?.threadMessages', JSON.stringify(threadMessagesData?.threadMessages));
207
+ const threads: any = threadMessagesData?.threadMessages;
208
+ if (threadPost?.length == 0 && threads?.data?.length > 0) {
209
+ const threadMessage = threads?.data?.map((t: any) => t?.post);
210
+ setThreadPost(threadMessage);
211
+ setChannelMessages((oldMessages: any) => uniqBy([...threadMessage, ...oldMessages], ({ id }) => id));
216
212
  }
213
+ // if (!isPostParentIdThread) {
214
+ // // setTotalCount((pc: any) => pc + threadTotalCount);
215
+ // setChannelMessages((oldMessages: any) => uniqBy([...threadMessage, ...oldMessages], ({ id }) => id));
216
+ // }
217
+ // }
217
218
  }, [threadMessagesData, threadPost, isPostParentIdThread]);
218
219
 
219
220
  // React.useEffect(() => {
@@ -225,17 +226,17 @@ const ThreadConversationViewComponent = ({ channelId, postParentId, isPostParent
225
226
  // }
226
227
  // }, [newThreadMsg]);
227
228
 
228
- React.useEffect(() => {
229
- if (newThreadMsg) {
230
- console.log('newThreadMsg');
231
- refetch({
232
- channelId: !parentId || parentId == 0 ? null : channelId?.toString(),
233
- parentId: !parentId || parentId == 0 ? null : parentId?.toString(),
234
- limit: MESSAGES_PER_PAGE,
235
- skip: 0,
236
- });
237
- }
238
- }, [newThreadMsg, skip, parentId]);
229
+ // React.useEffect(() => {
230
+ // if (newThreadMsg) {
231
+ // console.log('newThreadMsg');
232
+ // refetch({
233
+ // channelId: !parentId || parentId == 0 ? null : channelId?.toString(),
234
+ // parentId: !parentId || parentId == 0 ? null : parentId?.toString(),
235
+ // limit: MESSAGES_PER_PAGE,
236
+ // skip: 0,
237
+ // });
238
+ // }
239
+ // }, [newThreadMsg, skip, parentId]);
239
240
 
240
241
  // useEffect(() => {
241
242
  // if (data?.messages?.data && (loadingOldMessages || channelMessages.length === 0)) {
@@ -278,13 +279,13 @@ const ThreadConversationViewComponent = ({ channelId, postParentId, isPostParent
278
279
 
279
280
  if (loadingOldMessages && channelMessages) setLoadingOldMessages(false);
280
281
 
281
- if (
282
- channelMessages &&
283
- channelMessages?.length == MESSAGES_PER_PAGE &&
284
- totalCount > channelMessages?.length
285
- ) {
286
- onFetchOld();
287
- }
282
+ // if (
283
+ // channelMessages &&
284
+ // channelMessages?.length == MESSAGES_PER_PAGE &&
285
+ // totalCount > channelMessages?.length
286
+ // ) {
287
+ // onFetchOld();
288
+ // }
288
289
  }
289
290
 
290
291
  // if (threadPost?.length > 0 && channelMessages.length == (0 || MESSAGES_PER_PAGE)) {
@@ -910,6 +911,7 @@ const ThreadConversationViewComponent = ({ channelId, postParentId, isPostParent
910
911
  modalContent={modalContent}
911
912
  />
912
913
  <SubscriptionHandler
914
+ channelId={channelId}
913
915
  subscribeToNewMessages={() =>
914
916
  subscribeToMore({
915
917
  document: CHAT_MESSAGE_ADDED,
@@ -926,7 +928,7 @@ const ThreadConversationViewComponent = ({ channelId, postParentId, isPostParent
926
928
  : [];
927
929
  const totalMsgCount = prev?.messages?.totalCount + 1;
928
930
  const merged = {
929
- ...prev,
931
+ ...prev?.messages,
930
932
  messages: {
931
933
  ...prev?.messages,
932
934
  data: mergedData,
@@ -969,8 +971,8 @@ const ThreadConversationViewComponent = ({ channelId, postParentId, isPostParent
969
971
  );
970
972
  };
971
973
 
972
- const SubscriptionHandler = ({ subscribeToNewMessages }: IThreadSubscriptionHandlerProps) => {
973
- useEffect(() => subscribeToNewMessages(), []);
974
+ const SubscriptionHandler = ({ subscribeToNewMessages, channelId }: IThreadSubscriptionHandlerProps) => {
975
+ useEffect(() => subscribeToNewMessages(), [channelId]);
974
976
  return <></>;
975
977
  };
976
978