@messenger-box/platform-mobile 10.0.3-alpha.17 → 10.0.3-alpha.172

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 (89) hide show
  1. package/lib/compute.js +2 -3
  2. package/lib/compute.js.map +1 -1
  3. package/lib/index.js.map +1 -1
  4. package/lib/module.js.map +1 -1
  5. package/lib/queries/inboxQueries.js +65 -0
  6. package/lib/queries/inboxQueries.js.map +1 -0
  7. package/lib/routes.json +2 -3
  8. package/lib/screens/inbox/DialogMessages.js +8 -3
  9. package/lib/screens/inbox/DialogMessages.js.map +1 -1
  10. package/lib/screens/inbox/DialogThreadMessages.js +6 -11
  11. package/lib/screens/inbox/DialogThreadMessages.js.map +1 -1
  12. package/lib/screens/inbox/DialogThreads.js +58 -20
  13. package/lib/screens/inbox/DialogThreads.js.map +1 -1
  14. package/lib/screens/inbox/Inbox.js.map +1 -1
  15. package/lib/screens/inbox/components/CachedImage/consts.js +1 -1
  16. package/lib/screens/inbox/components/CachedImage/consts.js.map +1 -1
  17. package/lib/screens/inbox/components/CachedImage/index.js +166 -47
  18. package/lib/screens/inbox/components/CachedImage/index.js.map +1 -1
  19. package/lib/screens/inbox/components/DialogItem.js +160 -0
  20. package/lib/screens/inbox/components/DialogItem.js.map +1 -0
  21. package/lib/screens/inbox/components/GiftedChatInboxComponent.js +313 -0
  22. package/lib/screens/inbox/components/GiftedChatInboxComponent.js.map +1 -0
  23. package/lib/screens/inbox/components/SlackMessageContainer/ImageViewerModal.js +2 -0
  24. package/lib/screens/inbox/components/SlackMessageContainer/ImageViewerModal.js.map +1 -1
  25. package/lib/screens/inbox/components/SlackMessageContainer/PaymentMessage.js +194 -0
  26. package/lib/screens/inbox/components/SlackMessageContainer/PaymentMessage.js.map +1 -0
  27. package/lib/screens/inbox/components/SlackMessageContainer/SlackBubble.js +152 -29
  28. package/lib/screens/inbox/components/SlackMessageContainer/SlackBubble.js.map +1 -1
  29. package/lib/screens/inbox/components/SlackMessageContainer/SlackMessage.js +3 -4
  30. package/lib/screens/inbox/components/SlackMessageContainer/SlackMessage.js.map +1 -1
  31. package/lib/screens/inbox/components/SubscriptionHandler.js +22 -0
  32. package/lib/screens/inbox/components/SubscriptionHandler.js.map +1 -0
  33. package/lib/screens/inbox/components/ThreadsViewItem.js +67 -47
  34. package/lib/screens/inbox/components/ThreadsViewItem.js.map +1 -1
  35. package/lib/screens/inbox/config/config.js +4 -2
  36. package/lib/screens/inbox/config/config.js.map +1 -1
  37. package/lib/screens/inbox/containers/ConversationView.js +1234 -458
  38. package/lib/screens/inbox/containers/ConversationView.js.map +1 -1
  39. package/lib/screens/inbox/containers/Dialogs.js +195 -80
  40. package/lib/screens/inbox/containers/Dialogs.js.map +1 -1
  41. package/lib/screens/inbox/containers/ThreadConversationView.js +739 -225
  42. package/lib/screens/inbox/containers/ThreadConversationView.js.map +1 -1
  43. package/lib/screens/inbox/containers/ThreadsView.js +81 -54
  44. package/lib/screens/inbox/containers/ThreadsView.js.map +1 -1
  45. package/lib/screens/inbox/hooks/useInboxMessages.js +31 -0
  46. package/lib/screens/inbox/hooks/useInboxMessages.js.map +1 -0
  47. package/lib/screens/inbox/hooks/useSafeDialogThreadsMachine.js +108 -0
  48. package/lib/screens/inbox/hooks/useSafeDialogThreadsMachine.js.map +1 -0
  49. package/lib/screens/inbox/workflow/dialog-threads-xstate.js +151 -0
  50. package/lib/screens/inbox/workflow/dialog-threads-xstate.js.map +1 -0
  51. package/package.json +5 -5
  52. package/CHANGELOG.md +0 -152
  53. package/jest.config.js +0 -24
  54. package/lib/screens/inbox/components/DialogsListItem.js +0 -175
  55. package/lib/screens/inbox/components/DialogsListItem.js.map +0 -1
  56. package/lib/screens/inbox/components/ServiceDialogsListItem.js +0 -165
  57. package/lib/screens/inbox/components/ServiceDialogsListItem.js.map +0 -1
  58. package/rollup.config.mjs +0 -45
  59. package/src/components/index.ts +0 -0
  60. package/src/compute.ts +0 -63
  61. package/src/index.ts +0 -7
  62. package/src/module.ts +0 -10
  63. package/src/navigation/InboxNavigation.tsx +0 -102
  64. package/src/navigation/index.ts +0 -1
  65. package/src/screens/inbox/DialogMessages.tsx +0 -21
  66. package/src/screens/inbox/DialogThreadMessages.tsx +0 -97
  67. package/src/screens/inbox/DialogThreads.tsx +0 -129
  68. package/src/screens/inbox/Inbox.tsx +0 -17
  69. package/src/screens/inbox/components/CachedImage/consts.ts +0 -5
  70. package/src/screens/inbox/components/CachedImage/index.tsx +0 -103
  71. package/src/screens/inbox/components/DialogsHeader.tsx +0 -30
  72. package/src/screens/inbox/components/DialogsListItem.tsx +0 -302
  73. package/src/screens/inbox/components/ServiceDialogsListItem.tsx +0 -287
  74. package/src/screens/inbox/components/SlackMessageContainer/ImageViewerModal.tsx +0 -113
  75. package/src/screens/inbox/components/SlackMessageContainer/SlackBubble.tsx +0 -287
  76. package/src/screens/inbox/components/SlackMessageContainer/SlackMessage.tsx +0 -145
  77. package/src/screens/inbox/components/SlackMessageContainer/index.ts +0 -3
  78. package/src/screens/inbox/components/SupportServiceDialogsListItem.tsx +0 -283
  79. package/src/screens/inbox/components/ThreadsViewItem.tsx +0 -321
  80. package/src/screens/inbox/config/config.ts +0 -15
  81. package/src/screens/inbox/config/index.ts +0 -1
  82. package/src/screens/inbox/containers/ConversationView.tsx +0 -917
  83. package/src/screens/inbox/containers/Dialogs.tsx +0 -252
  84. package/src/screens/inbox/containers/SupportServiceDialogs.tsx +0 -119
  85. package/src/screens/inbox/containers/ThreadConversationView.tsx +0 -772
  86. package/src/screens/inbox/containers/ThreadsView.tsx +0 -305
  87. package/src/screens/index.ts +0 -4
  88. package/tsconfig.json +0 -13
  89. package/webpack.config.js +0 -58
package/lib/compute.js CHANGED
@@ -42,8 +42,7 @@ const inboxPageStore = [{
42
42
  componentPath: "@messenger-box/platform-mobile/lib/screens/inbox/DialogThreads.js",
43
43
  hasComponent: true,
44
44
  queries: {
45
- ViewChannelDetailDocument: "{id: params.id}",
46
- ThreadMessagesDocument: "{channelId: params.channelId,role: params.role,limit: params.limit,repliesLimit2: 5}"
45
+ ChannelDetailDocument: "{}"
47
46
  }
48
47
  }, {
49
48
  key: "threadmessage",
@@ -68,7 +67,7 @@ const inboxPageStore = [{
68
67
  componentPath: "@messenger-box/platform-mobile/lib/screens/inbox/DialogThreadMessages.js",
69
68
  hasComponent: true,
70
69
  queries: {
71
- ViewChannelDetailDocument: "{id: params.id}"
70
+ ChannelDetailDocument: "{}"
72
71
  }
73
72
  }];
74
73
  const selectedRoutes = ["message", "thread", "threadmessage"];
@@ -1 +1 @@
1
- {"version":3,"file":"compute.js","sources":["../src/compute.ts"],"sourcesContent":["/* eslint-disable import/no-extraneous-dependencies */\nimport { getFilteredRoutes } from '@common-stack/client-react/lib/utils/filteredRoutes.js';\nimport type { IRouteModule } from '@common-stack/core';\n\nexport const inboxPageStore: IRouteModule[] = [\n {\n key: 'message',\n path: '/message',\n name: 'Message',\n exact: true,\n component: () => import('./screens/inbox/DialogMessages'),\n props: {\n initialParams: { channelId: null, role: null, isShowThreadMessage: true },\n options: {\n headerShown: true,\n title: 'Inbox',\n headerBackTitleVisible: false,\n gestureEnabled: false,\n swipeEnabled: false,\n },\n },\n },\n {\n key: 'thread',\n path: '/thread',\n name: 'Thread',\n exact: true,\n component: () => import('./screens/inbox/DialogThreads'),\n props: {\n initialParams: { channelId: null, postParentId: null, role: null },\n options: {\n headerShown: true,\n title: 'Thread',\n headerBackTitleVisible: false,\n gestureEnabled: false,\n swipeEnabled: false,\n },\n },\n },\n {\n key: 'threadmessage',\n path: '/threadmessage',\n name: 'ThreadMessage',\n exact: true,\n component: () => import('./screens/inbox/DialogThreadMessages'),\n props: {\n initialParams: { channelId: null, postParentId: null, isPostParentIdThread: null, role: null },\n options: {\n headerShown: true,\n title: 'Inbox',\n headerBackTitleVisible: false,\n gestureEnabled: false,\n swipeEnabled: false,\n },\n },\n },\n];\n\nconst selectedRoutes = ['message', 'thread', 'threadmessage'];\n\nconst filteredRoutes = getFiltered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AW,MAAM,OAAO,yCAAA,CAAA;AAAA,EACxB,KAAO,EAAA;AAAA,IACL,aAAe,EAAA;AAAA,MACb,SAAW,EAAA,IAAA;AAAA,MACX,YAAc,EAAA,IAAA;AAAA,MACd,oBAAsB,EAAA,IAAA;AAAA,MACtB,IAAM,EAAA;AAAA,KACR;AAAA,IACA,OAAS,EAAA;AAAA,MACP,WAAa,EAAA,IAAA;AAAA,MACb,KAAO,EAAA,OAAA;AAAA,MACP,sBAAwB,EAAA,KAAA;AAAA,MACxB,cAAgB,EAAA,KAAA;AAAA,MAChB,YAAc,EAAA;AAAA;AAChB;AAEJ,CAAC;AACD,MAAM,cAAiB,GAAA,CAAC,SAAW,EAAA,QAAA,EAAU,eAAe,CAAA;AACtD,MAAA,cAAA,GAAiB,iBAAkB,CAAA,cAAA,EAAgB,cAAc"}
1
+ {"version":3,"file":"compute.js","sources":["../src/compute.ts"],"sourcesContent":["/* eslint-disable import/no-extraneous-dependencies */\nimport { getFilteredRoutes } from '@common-stack/client-react/lib/utils/filteredRoutes.js';\nimport type { IRouteModule } from '@common-stack/core';\n\nexport const inboxPageStore: IRouteModule[] = [\n {\n key: 'message',\n path: '/message',\n name: 'Message',\n exact: true,\n component: () => import('./screens/inbox/DialogMessages'),\n props: {\n initialParams: { channelId: null, role: null, isShowThreadMessage: true },\n options: {\n headerShown: true,\n title: 'Inbox',\n headerBackTitleVisible: false,\n gestureEnabled: false,\n swipeEnabled: false,\n },\n },\n },\n {\n key: 'thread',\n path: '/thread',\n name: 'Thread',\n exact: true,\n component: () => import('./screens/inbox/DialogThreads'),\n props: {\n initialParams: { channelId: null, postParentId: null, role: null },\n options: {\n headerShown: true,\n title: 'Thread',\n headerBackTitleVisible: false,\n gestureEnabled: false,\n swipeEnabled: false,\n },\n },\n },\n {\n key: 'threadmessage',\n path: '/threadmessage',\n name: 'ThreadMessage',\n exact: true,\n component: () => import('./screens/inbox/DialogThreadMessages'),\n props: {\n initialParams: { channelId: null, postParentId: null, isPostParentIdThread: null, role: null },\n options: {\n headerShown: true,\n title: 'Inbox',\n headerBackTitleVisible: false,\n gestureEnabled: false,\n swipeEnabled: false,\n },\n },\n },\n];\n\nconst selectedRoutes = ['message', 'thread', 'threadmessage'];\n\nconst filteredRoutes = getFilteredRoutes(inboxPageStore, selectedRoutes);\n\nexport { filteredRoutes };\n"],"names":[],"mappings":"uFAGO,MAAM,iBAAiC,CAAC;AAAA,EAC7C,GAAA,EAAK,SAAA;AAAA,EACL,IAAA,EAAM,UAAA;AAAA,EACN,IAAA,EAAM,SAAA;AAAA,EACN,KAAA,EAAO,IAAA;AAAA,EACP,SAAA,EAAW,MAAM,OAAO,mCAAgC,CAAA;AAAA,EACxD,KAAA,EAAO;AAAA,IACL,aAAA,EAAe;AAAA,MACb,SAAA,EAAW,IAAA;AAAA,MACX,IAAA,EAAM,IAAA;AAAA,MACN,mBAAA,EAAqB;AAAA,KACvB;AAAA,IACA,OAAA,EAAS;AAAA,MACP,WAAA,EAAa,IAAA;AAAA,MACb,KAAA,EAAO,OAAA;AAAA,MACP,sBAAA,EAAwB,KAAA;AAAA,MACxB,cAAA,EAAgB,KAAA;AAAA,MAChB,YAAA,EAAc;AAAA;AAChB;AAEJ,CAAA,EAAG;AAAA,EACD,GAAA,EAAK,QAAA;AAAA,EACL,IAAA,EAAM,SAAA;AAAA,EACN,IAAA,EAAM,QAAA;AAAA,EACN,KAAA,EAAO,IAAA;AAAA,EACP,SAAA,EAAW,MAAM,OAAO,kCAA+B,CAAA;AAAA,EACvD,KAAA,EAAO;AAAA,IACL,aAAA,EAAe;AAAA,MACb,SAAA,EAAW,IAAA;AAAA,MACX,YAAA,EAAc,IAAA;AAAA,MACd,IAAA,EAAM;AAAA,KACR;AAAA,IACA,OAAA,EAAS;AAAA,MACP,WAAA,EAAa,IAAA;AAAA,MACb,KAAA,EAAO,QAAA;AAAA,MACP,sBAAA,EAAwB,KAAA;AAAA,MACxB,cAAA,EAAgB,KAAA;AAAA,MAChB,YAAA,EAAc;AAAA;AAChB;AAEJ,CAAA,EAAG;AAAA,EACD,GAAA,EAAK,eAAA;AAAA,EACL,IAAA,EAAM,gBAAA;AAAA,EACN,IAAA,EAAM,eAAA;AAAA,EACN,KAAA,EAAO,IAAA;AAAA,EACP,SAAA,EAAW,MAAM,OAAO,yCAAsC,CAAA;AAAA,EAC9D,KAAA,EAAO;AAAA,IACL,aAAA,EAAe;AAAA,MACb,SAAA,EAAW,IAAA;AAAA,MACX,YAAA,EAAc,IAAA;AAAA,MACd,oBAAA,EAAsB,IAAA;AAAA,MACtB,IAAA,EAAM;AAAA,KACR;AAAA,IACA,OAAA,EAAS;AAAA,MACP,WAAA,EAAa,IAAA;AAAA,MACb,KAAA,EAAO,OAAA;AAAA,MACP,sBAAA,EAAwB,KAAA;AAAA,MACxB,cAAA,EAAgB,KAAA;AAAA,MAChB,YAAA,EAAc;AAAA;AAChB;AAEJ,CAAC;AACD,MAAM,cAAA,GAAiB,CAAC,SAAA,EAAW,QAAA,EAAU,eAAe,CAAA;AAC5D,MAAM,cAAA,GAAiB,iBAAA,CAAkB,cAAA,EAAgB,cAAc"}
package/lib/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":["../src/index.ts"],"sourcesContent":["import PlatformModule from './module';\n\nimport { Feature } from '@common-stack/client-react';\n\nexport default new Feature(PlatformModule);\n// export * from './navigation';\nexport * from './screens';\n"],"names":[],"mappings":"yUAEA,YAAe,IAAI,QAAQ,cAAc,CAAA"}
1
+ {"version":3,"file":"index.js","sources":["../src/index.ts"],"sourcesContent":["import PlatformModule from './module';\n\nimport { Feature } from '@common-stack/client-react';\n// import * as inboxQueries from './queries/inboxQueries';\n\nexport default new Feature(PlatformModule);\n// export * from './navigation';\nexport * from './screens';\n// export { inboxQueries };\n"],"names":[],"mappings":"yUAIA,YAAe,IAAI,QAAQ,cAAc,CAAA"}
package/lib/module.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"module.js","sources":["../src/module.ts"],"sourcesContent":["/* eslint-disable import/no-extraneous-dependencies */\nimport { Feature } from '@common-stack/client-react';\nimport { schema, typePolicies, dataIdFromObject } from '@messenger-box/platform-client';\nimport {filteredRoutes} from './compute';\n\nexport default new Feature({\n dataIdFromObject,\n clientStateParams: { typeDefs: schema, typePolicies },\n routeConfig: filteredRoutes as any,\n});\n"],"names":[],"mappings":"6KAIA,qBAAe,IAAI,OAAQ,CAAA;AAAA,EACzB,gBAAA;AAAA,EACA,iBAAmB,EAAA;AAAA,IACjB,QAAU,EAAA,MAAA;AAAA,IACV;AAAA,GACF;AAAA,EACA,WAAa,EAAA;AACf,CAAC,CAAA"}
1
+ {"version":3,"file":"module.js","sources":["../src/module.ts"],"sourcesContent":["/* eslint-disable import/no-extraneous-dependencies */\nimport { Feature } from '@common-stack/client-react';\nimport { schema, typePolicies, dataIdFromObject } from '@messenger-box/platform-client';\nimport {filteredRoutes} from './compute';\n\nexport default new Feature({\n dataIdFromObject,\n clientStateParams: { typeDefs: schema, typePolicies },\n routeConfig: filteredRoutes as any,\n});\n"],"names":[],"mappings":"6KAIA,qBAAe,IAAI,OAAA,CAAQ;AAAA,EACzB,gBAAA;AAAA,EACA,iBAAA,EAAmB;AAAA,IACjB,QAAA,EAAU,MAAA;AAAA,IACV;AAAA,GACF;AAAA,EACA,WAAA,EAAa;AACf,CAAC,CAAA"}
@@ -0,0 +1,65 @@
1
+ import {useViewChannelDetailQuery,useThreadMessagesQuery,OnThreadCreatedUpdatedDocument,useSendThreadMessageMutation,OnChatMessageAddedDocument,MessagesDocument,useOnThreadCreatedUpdatedSubscription,useCreatePostThreadMutation,useSendExpoNotificationOnPostMutation,useGetPostThreadLazyQuery,useAddDirectChannelMutation,useSendMessagesMutation,useMessagesQuery}from'common/graphql';export{useMessagesQuery,useThreadMessagesQuery}from'common/graphql';import'react';var __defProp = Object.defineProperty;
2
+ var __getOwnPropSymbols = Object.getOwnPropertySymbols;
3
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
4
+ var __propIsEnum = Object.prototype.propertyIsEnumerable;
5
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
6
+ var __spreadValues = (a, b) => {
7
+ for (var prop in b || (b = {}))
8
+ if (__hasOwnProp.call(b, prop))
9
+ __defNormalProp(a, prop, b[prop]);
10
+ if (__getOwnPropSymbols)
11
+ for (var prop of __getOwnPropSymbols(b)) {
12
+ if (__propIsEnum.call(b, prop))
13
+ __defNormalProp(a, prop, b[prop]);
14
+ }
15
+ return a;
16
+ };
17
+ const useChannelDetailQuery = (channelId, options = {}) => {
18
+ return useViewChannelDetailQuery(__spreadValues({
19
+ variables: {
20
+ channelId
21
+ }
22
+ }, options));
23
+ };
24
+ const useThreadMessagesQueryWithOptions = (variables, options = {}) => {
25
+ return useThreadMessagesQuery(__spreadValues({
26
+ variables,
27
+ fetchPolicy: "cache-and-network",
28
+ refetchWritePolicy: "overwrite",
29
+ nextFetchPolicy: "network-only"
30
+ }, options));
31
+ };
32
+ const useChannelMessagesQuery = (variables = {}, options = {}) => {
33
+ return useMessagesQuery(__spreadValues({
34
+ variables,
35
+ fetchPolicy: "cache-and-network",
36
+ nextFetchPolicy: "cache-first",
37
+ refetchWritePolicy: "merge"
38
+ }, options));
39
+ };
40
+ const useSendChannelMessage = () => {
41
+ return useSendMessagesMutation();
42
+ };
43
+ const useAddDirectChannel = () => {
44
+ return useAddDirectChannelMutation();
45
+ };
46
+ const MESSAGES_DOCUMENT = MessagesDocument;
47
+ const useSendThreadMessage = () => {
48
+ return useSendThreadMessageMutation();
49
+ };
50
+ const useSendExpoNotification = () => {
51
+ return useSendExpoNotificationOnPostMutation();
52
+ };
53
+ const useCreatePostThread = (options = {}) => {
54
+ return useCreatePostThreadMutation(options);
55
+ };
56
+ const CHAT_MESSAGE_ADDED = OnChatMessageAddedDocument;
57
+ const THREAD_CREATED_UPDATED = OnThreadCreatedUpdatedDocument;
58
+ const useThreadCreatedUpdatedSubscription = (options = {}) => {
59
+ return useOnThreadCreatedUpdatedSubscription(__spreadValues({}, options));
60
+ };
61
+ const useGetPostThreadLazy = (options = {}) => {
62
+ return useGetPostThreadLazyQuery(__spreadValues({
63
+ fetchPolicy: "cache-and-network"
64
+ }, options));
65
+ };export{CHAT_MESSAGE_ADDED,MESSAGES_DOCUMENT,THREAD_CREATED_UPDATED,useAddDirectChannel,useChannelDetailQuery,useChannelMessagesQuery,useCreatePostThread,useGetPostThreadLazy,useSendChannelMessage,useSendExpoNotification,useSendThreadMessage,useThreadCreatedUpdatedSubscription,useThreadMessagesQueryWithOptions};//# sourceMappingURL=inboxQueries.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"inboxQueries.js","sources":["../../src/queries/inboxQueries.ts"],"sourcesContent":["// Imports from common/graphql\nimport {\n useGetChannelsByUserWithServiceChannelsQuery,\n useGetChannelsByUserQuery,\n OnChatMessageAddedDocument,\n OnThreadCreatedUpdatedDocument,\n useViewChannelDetailQuery,\n useThreadMessagesQuery,\n useSupportServiceChannelsQuery,\n useSendThreadMessageMutation,\n useMessagesQuery,\n useSendMessagesMutation,\n useAddDirectChannelMutation,\n MessagesDocument,\n useSendExpoNotificationOnPostMutation,\n useOnThreadCreatedUpdatedSubscription,\n useOnChatMessageAddedSubscription,\n useOnThreadChatMessageAddedSubscription,\n useCreatePostThreadMutation,\n useGetPostThreadLazyQuery,\n} from 'common/graphql';\nimport { useCallback } from 'react';\n\n// ====== CHANNEL QUERIES ======\n\n/**\n * Hook for fetching channels by user including service channels\n * @param options - Query options\n * @returns Query result with data, loading state, refetch and fetchMore functions\n */\nexport const useChannelsQuery = (options: any = {}) => {\n return useGetChannelsByUserQuery({\n ...options,\n fetchPolicy: 'cache-and-network',\n //nextFetchPolicy: 'network-only',\n });\n};\n\n/**\n * Hook for fetching service channels\n * @param options - Query options\n * @returns Query result with data, loading state and refetch function\n */\nexport const useServiceChannelsQuery = (options: any = {}) => {\n return useSupportServiceChannelsQuery({\n ...options,\n fetchPolicy: 'cache-and-network',\n });\n};\n\n/**\n * Hook for fetching channel details\n * @param channelId - ID of the channel to fetch\n * @param options - Additional query options\n * @returns Query result with channel details\n */\nexport const useChannelDetailQuery = (channelId: string, options: any = {}) => {\n return useViewChannelDetailQuery({\n variables: { channelId },\n ...options,\n });\n};\n\n// ====== THREAD QUERIES ======\n\n/**\n * Direct export of the thread messages query hook\n */\nexport { useThreadMessagesQuery };\n\n/**\n * Direct export of the messages query hook\n */\nexport { useMessagesQuery };\n\n/**\n * Hook for fetching thread messages with default options\n * @param variables - Query variables including channelId, role, and limit\n * @param options - Additional query options\n * @returns Query result with thread messages data\n */\nexport const useThreadMessagesQueryWithOptions = (variables: any, options: any = {}) => {\n return useThreadMessagesQuery({\n variables,\n fetchPolicy: 'cache-and-network',\n refetchWritePolicy: 'overwrite',\n nextFetchPolicy: 'network-only',\n ...options,\n });\n};\n\n// ====== MESSAGE QUERIES ======\n\n/**\n * Hook for fetching channel messages\n * @param variables - Query variables including channelId, parentId, and pagination params\n * @param options - Additional query options\n * @returns Query result for messages\n */\nexport const useChannelMessagesQuery = (variables: any = {}, options: any = {}) => {\n return useMessagesQuery({\n variables,\n fetchPolicy: 'cache-and-network',\n nextFetchPolicy: 'cache-first',\n refetchWritePolicy: 'merge',\n ...options,\n });\n};\n\n/**\n * Hook for sending messages in a channel\n * @returns Mutation function and result\n */\nexport const useSendChannelMessage = () => {\n return useSendMessagesMutation();\n};\n\n/**\n * Hook for adding a direct channel\n * @returns Mutation function and result\n */\nexport const useAddDirectChannel = () => {\n return useAddDirectChannelMutation();\n};\n\n/**\n * Messages document for queries\n */\nexport const MESSAGES_DOCUMENT = MessagesDocument;\n\n// ====== MUTATIONS ======\n\n/**\n * Hook for sending thread messages\n * @returns Mutation function and result\n */\nexport const useSendThreadMessage = () => {\n return useSendThreadMessageMutation();\n};\n\n/**\n * Hook for sending expo notifications\n * @returns Mutation function and result\n */\nexport const useSendExpoNotification = () => {\n return useSendExpoNotificationOnPostMutation();\n};\n\n/**\n * Hook for creating a post thread\n * @param options - Mutation options\n * @returns Mutation function and result\n */\nexport const useCreatePostThread = (options: any = {}) => {\n return useCreatePostThreadMutation(options);\n};\n\n// ====== SUBSCRIPTION DOCUMENTS ======\n\n/**\n * Document for chat message added subscription\n */\nexport const CHAT_MESSAGE_ADDED = OnChatMessageAddedDocument;\n\n/**\n * Document for thread created/updated subscription\n */\nexport const THREAD_CREATED_UPDATED = OnThreadCreatedUpdatedDocument;\n\n/**\n * Hook for subscribing to thread creation and updates\n * @returns Subscription result for thread creation/update events\n */\nexport const useThreadCreatedUpdatedSubscription = (options: any = {}) => {\n return useOnThreadCreatedUpdatedSubscription({\n ...options,\n });\n};\n\n/**\n * Hook for subscribing to chat message additions\n * @param options - Subscription options including variables like channelId\n * @returns Subscription result for new chat messages\n */\nexport const useChatMessageAddedSubscription = (options: any = {}) => {\n return useOnChatMessageAddedSubscription({\n ...options,\n });\n};\n\n/**\n * Hook for subscribing to thread chat message additions\n * @param options - Subscription options including variables like channelId and threadId\n * @returns Subscription result for new thread chat messages\n */\nexport const useThreadChatMessageAddedSubscription = (options: any = {}) => {\n return useOnThreadChatMessageAddedSubscription({\n ...options,\n });\n};\n\n// ====== LAZY QUERIES ======\n\n/**\n * Hook for lazily fetching a post thread\n * @param options - Lazy query options\n * @returns Lazy query function and result\n */\nexport const useGetPostThreadLazy = (options: any = {}) => {\n return useGetPostThreadLazyQuery({\n fetchPolicy: 'cache-and-network',\n ...options,\n });\n};\n\n// ====== CUSTOM QUERY HOOKS ======\n\n/**\n * Custom hook that combines channels and provides refresh functionality\n */\nexport const useInboxChannels = () => {\n const queryResult = useChannelsQuery();\n\n const refresh = useCallback(() => {\n return queryResult.refetch();\n }, [queryResult.refetch]);\n\n const loadMore = useCallback(\n (page: number) => {\n if (queryResult.loading || !queryResult.data) return;\n\n return queryResult.fetchMore({\n variables: { page },\n updateQuery: (prev, { fetchMoreResult }) => {\n if (!fetchMoreResult) return prev;\n\n return {\n ...fetchMoreResult,\n channelsByUser: [...(prev.channelsByUser || []), ...(fetchMoreResult.channelsByUser || [])],\n // supportServiceChannels: [\n // ...(prev.supportServiceChannels || []),\n // ...(fetchMoreResult.supportServiceChannels || []),\n // ],\n };\n },\n });\n },\n [queryResult.fetchMore, queryResult.loading, queryResult.data],\n );\n\n return {\n ...queryResult,\n refresh,\n loadMore,\n };\n};\n\n/**\n * Custom hook for thread message operations\n */\nexport const useThreadOperations = (channelId: string, options: any = {}) => {\n const queryResult = useThreadMessagesQueryWithOptions({ channelId, ...options.variables }, options.queryOptions);\n\n const [sendMessage, sendMessageResult] = useSendThreadMessage();\n\n const refresh = useCallback(() => {\n return queryResult.refetch();\n }, [queryResult.refetch]);\n\n const fetchMoreMessages = useCallback(\n (variables: any) => {\n return queryResult.fetchMore({\n variables,\n updateQuery: (prev, { fetchMoreResult }) => {\n if (!fetchMoreResult?.threadMessages?.data) return prev;\n\n return {\n ...prev,\n threadMessages: {\n ...prev.threadMessages,\n data: [...fetchMoreResult.threadMessages.data, ...(prev.threadMessages?.data || [])],\n },\n };\n },\n });\n },\n [queryResult.fetchMore],\n );\n\n return {\n data: queryResult.data,\n loading: queryResult.loading,\n error: queryResult.error,\n refresh,\n fetchMoreMessages,\n sendMessage,\n sendMessageResult,\n };\n};\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAqCO,MAAM,qBAAA,GAAwB,CAAC,SAAA,EAAmB,OAAA,GAAe,EAAC,KAAM;AAC7E,EAAA,OAAO,yBAAA,CAA0B,cAAA,CAAA;AAAA,IAC/B,SAAA,EAAW;AAAA,MACT;AAAA;AACF,GAAA,EACG,OAAA,CACJ,CAAA;AACH;AAoBO,MAAM,iCAAA,GAAoC,CAAC,SAAA,EAAgB,OAAA,GAAe,EAAC,KAAM;AACtF,EAAA,OAAO,sBAAA,CAAuB,cAAA,CAAA;AAAA,IAC5B,SAAA;AAAA,IACA,WAAA,EAAa,mBAAA;AAAA,IACb,kBAAA,EAAoB,WAAA;AAAA,IACpB,eAAA,EAAiB;AAAA,GAAA,EACd,OAAA,CACJ,CAAA;AACH;AAUO,MAAM,0BAA0B,CAAC,SAAA,GAAiB,EAAC,EAAG,OAAA,GAAe,EAAC,KAAM;AACjF,EAAA,OAAO,gBAAA,CAAiB,cAAA,CAAA;AAAA,IACtB,SAAA;AAAA,IACA,WAAA,EAAa,mBAAA;AAAA,IACb,eAAA,EAAiB,aAAA;AAAA,IACjB,kBAAA,EAAoB;AAAA,GAAA,EACjB,OAAA,CACJ,CAAA;AACH;AAMO,MAAM,wBAAwB,MAAM;AACzC,EAAA,OAAO,uBAAA,EAAwB;AACjC;AAMO,MAAM,sBAAsB,MAAM;AACvC,EAAA,OAAO,2BAAA,EAA4B;AACrC;AAKO,MAAM,iBAAA,GAAoB;AAQ1B,MAAM,uBAAuB,MAAM;AACxC,EAAA,OAAO,4BAAA,EAA6B;AACtC;AAMO,MAAM,0BAA0B,MAAM;AAC3C,EAAA,OAAO,qCAAA,EAAsC;AAC/C;AAOO,MAAM,mBAAA,GAAsB,CAAC,OAAA,GAAe,EAAC,KAAM;AACxD,EAAA,OAAO,4BAA4B,OAAO,CAAA;AAC5C;AAOO,MAAM,kBAAA,GAAqB;AAK3B,MAAM,sBAAA,GAAyB;AAM/B,MAAM,mCAAA,GAAsC,CAAC,OAAA,GAAe,EAAC,KAAM;AACxE,EAAA,OAAO,qCAAA,CAAsC,mBACxC,OAAA,CACJ,CAAA;AACH;AA+BO,MAAM,oBAAA,GAAuB,CAAC,OAAA,GAAe,EAAC,KAAM;AACzD,EAAA,OAAO,yBAAA,CAA0B,cAAA,CAAA;AAAA,IAC/B,WAAA,EAAa;AAAA,GAAA,EACV,OAAA,CACJ,CAAA;AACH"}
package/lib/routes.json CHANGED
@@ -46,8 +46,7 @@
46
46
  "componentPath": "@messenger-box/platform-mobile/lib/screens/inbox/DialogThreads.js",
47
47
  "hasComponent": true,
48
48
  "queries": {
49
- "ViewChannelDetailDocument": "{id: params.id}",
50
- "ThreadMessagesDocument": "{channelId: params.channelId,role: params.role,limit: params.limit,repliesLimit2: 5}"
49
+ "ChannelDetailDocument": "{}"
51
50
  }
52
51
  }
53
52
  },
@@ -75,7 +74,7 @@
75
74
  "componentPath": "@messenger-box/platform-mobile/lib/screens/inbox/DialogThreadMessages.js",
76
75
  "hasComponent": true,
77
76
  "queries": {
78
- "ViewChannelDetailDocument": "{id: params.id}"
77
+ "ChannelDetailDocument": "{}"
79
78
  }
80
79
  }
81
80
  }
@@ -33,13 +33,18 @@ function DialogMessages(_a) {
33
33
  var _b = _a, {
34
34
  channelId,
35
35
  role,
36
- isShowThreadMessage = true
36
+ isShowThreadMessage = true,
37
+ isPaymentChatUI = false
37
38
  } = _b, rest = __objRest(_b, [
38
39
  "channelId",
39
40
  "role",
40
- "isShowThreadMessage"
41
+ "isShowThreadMessage",
42
+ "isPaymentChatUI"
41
43
  ]);
42
44
  var _a2, _b2, _c;
43
45
  const currentRoute = navigationRef.isReady() ? (_a2 = navigationRef) == null ? void 0 : _a2.getCurrentRoute() : null;
44
- return /* @__PURE__ */ React.createElement(Box, { className: "bg-white flex-1" }, /* @__PURE__ */ React.createElement(ConversationView, __spreadProps(__spreadValues({}, rest), { channelId: (_c = (_b2 = currentRoute == null ? void 0 : currentRoute.params) == null ? void 0 : _b2.channelId) != null ? _c : channelId, role, isShowThreadMessage })));
46
+ return (
47
+ // <Box bg={'white'} flex={1} pt={5}>
48
+ /* @__PURE__ */ React.createElement(Box, { className: "bg-white flex-1" }, /* @__PURE__ */ React.createElement(ConversationView, __spreadProps(__spreadValues({}, rest), { channelId: (_c = (_b2 = currentRoute == null ? void 0 : currentRoute.params) == null ? void 0 : _b2.channelId) != null ? _c : channelId, role, isShowThreadMessage, isPaymentChatUI })))
49
+ );
45
50
  }export{DialogMessages,DialogMessages as default};//# sourceMappingURL=DialogMessages.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"DialogMessages.js","sources":["../../../src/screens/inbox/DialogMessages.tsx"],"sourcesContent":["import * as React from 'react';\nimport { Box } from '@admin-layout/gluestack-ui-mobile';\nimport { ConversationView } from './containers/ConversationView';\nimport { navigationRef } from '@common-stack/client-react';\n\nexport function DialogMessages({ channelId, role, isShowThreadMessage = true, ...rest }) {\n const currentRoute = navigationRef.isReady() ? navigationRef?.getCurrentRoute() : null;\n return (\n // <Box bg={'white'} flex={1} pt={5}>\n <Box className=\"bg-white flex-1\">\n <ConversationView\n {...rest}\n channelId={currentRoute?.params?.channelId ?? channelId}\n role={role}\n isShowThreadMessage={isShowThreadMessage}\n />\n </Box>\n );\n}\n\nexport default DialogMessages;\n"],"names":["_a","_b"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAIO,SAAS,eAAe,EAK5B,EAAA;AAL4B,EAC7B,IAAA,EAAA,GAAA,EAAA,EAAA;AAAA,IAAA,SAAA;AAAA,IACA,IAAA;AAAA,IACA,mBAAsB,GAAA;AAAA,GAPxB,GAI+B,EAI1B,EAAA,IAAA,GAAA,SAAA,CAJ0B,EAI1B,EAAA;AAAA,IAHH,WAAA;AAAA,IACA,MAAA;AAAA,IACA;AAAA,GAAA,CAAA;AAPF,EAAA,IAAAA,KAAAC,GAAA,EAAA,EAAA;AAUE,EAAA,MAAM,eAAe,aAAc,CAAA,OAAA,MAAYD,GAAA,GAAA,aAAA,KAAA,IAAA,GAAA,MAAA,GAAAA,IAAe,eAAoB,EAAA,GAAA,IAAA;AAClF,EAEE,uBAAA,KAAA,CAAA,aAAA,CAAC,OAAI,SAAU,EAAA,iBAAA,EAAA,sCACN,gBAAqB,EAAA,aAAA,CAAA,cAAA,CAAA,EAAA,EAAA,IAAA,CAAA,EAArB,EAA2B,SAAW,EAAA,CAAA,EAAA,GAAA,CAAAC,MAAA,YAAc,IAAA,IAAA,GAAA,MAAA,GAAA,YAAA,CAAA,MAAA,KAAd,gBAAAA,GAAsB,CAAA,SAAA,KAAtB,YAAmC,SAAW,EAAA,IAAA,EAAY,sBAA0C,CAC/I,CAAA;AAER"}
1
+ {"version":3,"file":"DialogMessages.js","sources":["../../../src/screens/inbox/DialogMessages.tsx"],"sourcesContent":["import * as React from 'react';\nimport { Box } from '@admin-layout/gluestack-ui-mobile';\nimport { ConversationView } from './containers/ConversationView';\nimport { navigationRef } from '@common-stack/client-react';\n\nexport function DialogMessages({ channelId, role, isShowThreadMessage = true, isPaymentChatUI = false, ...rest }) {\n const currentRoute = navigationRef.isReady() ? navigationRef?.getCurrentRoute() : null;\n return (\n // <Box bg={'white'} flex={1} pt={5}>\n <Box className=\"bg-white flex-1\">\n <ConversationView\n {...rest}\n channelId={currentRoute?.params?.channelId ?? channelId}\n role={role}\n isShowThreadMessage={isShowThreadMessage}\n isPaymentChatUI={isPaymentChatUI}\n />\n </Box>\n );\n}\n\nexport default DialogMessages;\n"],"names":["_a","_b"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAIO,SAAS,eAAe,EAAA,EAM5B;AAN4B,EAAA,IAAA,EAAA,GAAA,EAAA,EAC7B;AAAA,IAAA,SAAA;AAAA,IACA,IAAA;AAAA,IACA,mBAAA,GAAsB,IAAA;AAAA,IACtB,eAAA,GAAkB;AAAA,GARpB,GAI+B,EAAA,EAK1B,IAAA,GAAA,SAAA,CAL0B,EAAA,EAK1B;AAAA,IAJH,WAAA;AAAA,IACA,MAAA;AAAA,IACA,qBAAA;AAAA,IACA;AAAA,GAAA,CAAA;AARF,EAAA,IAAAA,KAAAC,GAAAA,EAAA,EAAA;AAWE,EAAA,MAAM,eAAe,aAAA,CAAc,OAAA,MAAYD,GAAAA,GAAA,aAAA,KAAA,IAAA,GAAA,MAAA,GAAAA,IAAe,eAAA,EAAA,GAAoB,IAAA;AAClF,EAAA;AAAA;AAAA,oBAEE,KAAA,CAAA,aAAA,CAAC,OAAI,SAAA,EAAU,iBAAA,EAAA,sCACN,gBAAA,EAAA,aAAA,CAAA,cAAA,CAAA,EAAA,EAAqB,IAAA,CAAA,EAArB,EAA2B,SAAA,EAAA,CAAW,EAAA,GAAA,CAAAC,MAAA,YAAA,IAAA,IAAA,GAAA,MAAA,GAAA,YAAA,CAAc,MAAA,KAAd,gBAAAA,GAAAA,CAAsB,SAAA,KAAtB,YAAmC,SAAA,EAAW,IAAA,EAAY,mBAAA,EAA0C,eAAA,EAAA,CAAkC,CACjL;AAAA;AAER"}
@@ -1,4 +1,4 @@
1
- import*as React from'react';import {Box,Spinner}from'@admin-layout/gluestack-ui-mobile';import {ThreadConversationView}from'./containers/ThreadConversationView.js';import {useViewChannelDetailQuery,useSendThreadMessageMutation}from'common/graphql';import {useFocusEffect}from'@react-navigation/native';import colors from'tailwindcss/colors';function DialogThreadMessages({
1
+ import*as React from'react';import {Box,Spinner}from'@admin-layout/gluestack-ui-mobile';import {ThreadConversationView}from'./containers/ThreadConversationView.js';import {useChannelDetailQuery,useSendThreadMessage}from'../../queries/inboxQueries.js';import {useFocusEffect}from'@react-navigation/native';import colors from'tailwindcss/colors';function DialogThreadMessages({
2
2
  channelId,
3
3
  postParentId,
4
4
  isPostParentIdThread,
@@ -8,12 +8,8 @@ import*as React from'react';import {Box,Spinner}from'@admin-layout/gluestack-ui-
8
8
  data,
9
9
  loading: channelLoading,
10
10
  refetch
11
- } = useViewChannelDetailQuery({
12
- variables: {
13
- id: channelId == null ? void 0 : channelId.toString()
14
- }
15
- });
16
- const [sendThreadMessage] = useSendThreadMessageMutation();
11
+ } = useChannelDetailQuery(channelId == null ? void 0 : channelId.toString(), {});
12
+ const [sendThreadMessage] = useSendThreadMessage();
17
13
  const [loading, setLoading] = React.useState(true);
18
14
  const [channel, setChannel] = React.useState(null);
19
15
  const [parentId, setParentId] = React.useState(postParentId);
@@ -23,10 +19,9 @@ import*as React from'react';import {Box,Spinner}from'@admin-layout/gluestack-ui-
23
19
  });
24
20
  }, [channelId]);
25
21
  useFocusEffect(React.useCallback(() => {
26
- if (channelId)
27
- refetch({
28
- id: channelId == null ? void 0 : channelId.toString()
29
- });
22
+ if (channelId) refetch({
23
+ id: channelId == null ? void 0 : channelId.toString()
24
+ });
30
25
  return () => {
31
26
  };
32
27
  }, [channelId]));
@@ -1 +1 @@
1
- {"version":3,"file":"DialogThreadMessages.js","sources":["../../../src/screens/inbox/DialogThreadMessages.tsx"],"sourcesContent":["import * as React from 'react';\nimport { Box, Spinner, Text } from '@admin-layout/gluestack-ui-mobile';\nimport { ThreadConversationView } from './containers/ThreadConversationView';\nimport { ThreadsView } from './containers/ThreadsView';\nimport { useViewChannelDetailQuery, useSendThreadMessageMutation } from 'common/graphql';\nimport { useFocusEffect } from '@react-navigation/native';\n// import { useSelector } from 'react-redux';\nimport colors from 'tailwindcss/colors';\n\nexport function DialogThreadMessages({ channelId, postParentId, isPostParentIdThread, role }) {\n const {\n data,\n loading: channelLoading,\n refetch,\n } = useViewChannelDetailQuery({\n variables: {\n id: channelId?.toString(),\n },\n });\n\n const [sendThreadMessage] = useSendThreadMessageMutation();\n const [loading, setLoading] = React.useState<boolean>(true);\n const [channel, setChannel] = React.useState<any>(null);\n const [parentId, setParentId] = React.useState<any>(postParentId);\n\n const refetchChannelDetail = React.useCallback(\n (id: string) => {\n return refetch({ id: id?.toString() });\n },\n [channelId],\n );\n\n useFocusEffect(\n React.useCallback(() => {\n // Do something when the screen is focused\n if (channelId) refetch({ id: channelId?.toString() });\n return () => {};\n }, [channelId]),\n );\n\n React.useEffect(() => {\n setParentId(postParentId);\n }, [postParentId]);\n\n React.useEffect(() => {\n if (data?.viewChannelDetail) {\n setChannel(data?.viewChannelDetail);\n setLoading(false);\n }\n }, [data]);\n\n // React.useEffect(() => {\n // async function sendInitialMessage(channel: any) {\n // const content = `Welcome to ${channel?.title}`;\n // const createdBy = channel?.creator?.id;\n // await sendThreadMessage({\n // variables: {\n // channelId,\n // threadMessageInput: {\n // content,\n // role,\n // },\n // responderId: createdBy,\n // },\n // update: (cache, { data, errors }: any) => {\n // if (!data) {\n // return;\n // }\n // setParentId(data?.sendThreadMessage?.lastMessage?.id);\n // },\n // });\n // }\n // if ((!parentId || parentId == 0) && channel) {\n // sendInitialMessage(channel);\n // }\n\n // if (parentId) setLoading(false);\n // }, [parentId, channel]);\n\n return (\n <Box className=\"bg-white flex-1\">\n {/* {loading && !parentId ? ( */}\n {loading ? (\n <Spinner color={colors.blue[500]} />\n ) : (\n <ThreadConversationView\n channelId={channelId}\n postParentId={parentId}\n isPostParentIdThread={isPostParentIdThread}\n role={role}\n />\n )}\n </Box>\n );\n}\n\nexport default DialogThreadMessages;\n"],"names":[],"mappings":"qVAQO,SAAS,oBAAqB,CAAA;AAAA,EACnC,SAAA;AAAA,EACA,YAAA;AAAA,EACA,oBAAA;AAAA,EACA;AACF,CAAG,EAAA;AACD,EAAM,MAAA;AAAA,IACJ,IAAA;AAAA,IACA,OAAS,EAAA,cAAA;AAAA,IACT;AAAA,MACE,yBAA0B,CAAA;AAAA,IAC5B,SAAW,EAAA;AAAA,MACT,IAAI,SAAW,IAAA,IAAA,GAAA,MAAA,GAAA,SAAA,CAAA,QAAA;AAAA;AACjB,GACD,CAAA;AACD,EAAM,MAAA,CAAC,iBAAiB,CAAA,GAAI,4BAA6B,EAAA;AACzD,EAAA,MAAM,CAAC,OAAS,EAAA,UAAU,CAAI,GAAA,KAAA,CAAM,SAAkB,IAAI,CAAA;AAC1D,EAAA,MAAM,CAAC,OAAS,EAAA,UAAU,CAAI,GAAA,KAAA,CAAM,SAAc,IAAI,CAAA;AACtD,EAAA,MAAM,CAAC,QAAU,EAAA,WAAW,CAAI,GAAA,KAAA,CAAM,SAAc,YAAY,CAAA;AAChE,EAA6B,KAAA,CAAM,WAAY,CAAA,CAAC,EAAe,KAAA;AAC7D,IAAA,OAAO,OAAQ,CAAA;AAAA,MACb,IAAI,EAAI,IAAA,IAAA,GAAA,MAAA,GAAA,EAAA,CAAA,QAAA;AAAA,KACT,CAAA;AAAA,GACH,EAAG,CAAC,SAAS,CAAC;AACd,EAAe,cAAA,CAAA,KAAA,CAAM,YAAY,MAAM;AAErC,IAAI,IAAA,SAAA;AAAW,MAAQ,OAAA,CAAA;AAAA,QACrB,IAAI,SAAW,IAAA,IAAA,GAAA,MAAA,GAAA,SAAA,CAAA,QAAA;AAAA,OAChB,CAAA;AACD,IAAA,OAAO,MAAM;AAAA,KAAC;AAAA,GACb,EAAA,CAAC,SAAS,CAAC,CAAC,CAAA;AACf,EAAA,KAAA,CAAM,UAAU,MAAM;AACpB,IAAA,WAAA,CAAY,YAAY,CAAA;AAAA,GAC1B,EAAG,CAAC,YAAY,CAAC,CAAA;AACjB,EAAA,KAAA,CAAM,UAAU,MAAM;AACpB,IAAA,IAAI,6BAAM,iBAAmB,EAAA;AAC3B,MAAA,UAAA,CAAW,6BAAM,iBAAiB,CAAA;AAClC,MAAA,UAAA,CAAW,KAAK,CAAA;AAAA;AAClB,GACF,EAAG,CAAC,IAAI,CAAC,CAAA;AA8BT,EAAA,2CAAQ,GAAI,EAAA,EAAA,SAAA,EAAU,qBAEX,OAAU,mBAAA,KAAA,CAAA,aAAA,CAAC,WAAQ,KAAO,EAAA,MAAA,CAAO,KAAK,GAAM,CAAA,EAAA,CAAA,uCAAM,sBAAuB,EAAA,EAAA,SAAA,EAAsB,cAAc,QAAU,EAAA,oBAAA,EAA4C,MAAY,CACpL,CAAA;AACR"}
1
+ {"version":3,"file":"DialogThreadMessages.js","sources":["../../../src/screens/inbox/DialogThreadMessages.tsx"],"sourcesContent":["import * as React from 'react';\nimport { Box, Spinner, Text } from '@admin-layout/gluestack-ui-mobile';\nimport { ThreadConversationView } from './containers/ThreadConversationView';\nimport { ThreadsView } from './containers/ThreadsView';\nimport { useChannelDetailQuery, useSendThreadMessage } from '../../queries/inboxQueries';\nimport { useFocusEffect } from '@react-navigation/native';\n// import { useSelector } from 'react-redux';\nimport colors from 'tailwindcss/colors';\n\nexport function DialogThreadMessages({ channelId, postParentId, isPostParentIdThread, role }) {\n const { data, loading: channelLoading, refetch } = useChannelDetailQuery(channelId?.toString(), {});\n\n const [sendThreadMessage] = useSendThreadMessage();\n const [loading, setLoading] = React.useState<boolean>(true);\n const [channel, setChannel] = React.useState<any>(null);\n const [parentId, setParentId] = React.useState<any>(postParentId);\n\n const refetchChannelDetail = React.useCallback(\n (id: string) => {\n return refetch({ id: id?.toString() });\n },\n [channelId],\n );\n\n useFocusEffect(\n React.useCallback(() => {\n // Do something when the screen is focused\n if (channelId) refetch({ id: channelId?.toString() });\n return () => {};\n }, [channelId]),\n );\n\n React.useEffect(() => {\n setParentId(postParentId);\n }, [postParentId]);\n\n React.useEffect(() => {\n if (data?.viewChannelDetail) {\n setChannel(data?.viewChannelDetail);\n setLoading(false);\n }\n }, [data]);\n\n // React.useEffect(() => {\n // async function sendInitialMessage(channel: any) {\n // const content = `Welcome to ${channel?.title}`;\n // const createdBy = channel?.creator?.id;\n // await sendThreadMessage({\n // variables: {\n // channelId,\n // threadMessageInput: {\n // content,\n // role,\n // },\n // responderId: createdBy,\n // },\n // update: (cache, { data, errors }: any) => {\n // if (!data) {\n // return;\n // }\n // setParentId(data?.sendThreadMessage?.lastMessage?.id);\n // },\n // });\n // }\n // if ((!parentId || parentId == 0) && channel) {\n // sendInitialMessage(channel);\n // }\n\n // if (parentId) setLoading(false);\n // }, [parentId, channel]);\n\n return (\n <Box className=\"bg-white flex-1\">\n {/* {loading && !parentId ? ( */}\n {loading ? (\n <Spinner color={colors.blue[500]} />\n ) : (\n <ThreadConversationView\n channelId={channelId}\n postParentId={parentId}\n isPostParentIdThread={isPostParentIdThread}\n role={role}\n />\n )}\n </Box>\n );\n}\n\nexport default DialogThreadMessages;\n"],"names":[],"mappings":"wVAQO,SAAS,oBAAA,CAAqB;AAAA,EACnC,SAAA;AAAA,EACA,YAAA;AAAA,EACA,oBAAA;AAAA,EACA;AACF,CAAA,EAAG;AACD,EAAA,MAAM;AAAA,IACJ,IAAA;AAAA,IACA,OAAA,EAAS,cAAA;AAAA,IACT;AAAA,GACF,GAAI,qBAAA,CAAsB,SAAA,IAAA,IAAA,GAAA,MAAA,GAAA,SAAA,CAAW,QAAA,EAAA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,EAEX,0BAAU,KAAA,CAAA,aAAA,CAAC,OAAA,EAAA,EAAQ,OAAO,MAAA,CAAO,IAAA,CAAK,GAAG,CAAA,EAAG,CAAA,uCAAM,sBAAA,EAAA,EAAuB,SAAA,EAAsB,cAAc,QAAA,EAAU,oBAAA,EAA4C,MAAY,CACpL,CAAA;AACR"}
@@ -1,4 +1,4 @@
1
- import*as React from'react';import {Spinner,Box}from'@admin-layout/gluestack-ui-mobile';import {ThreadsView}from'./containers/ThreadsView.js';import {useViewChannelDetailQuery,useThreadMessagesQuery}from'common/graphql';import {useFocusEffect}from'@react-navigation/native';import {config}from'./config/config.js';import colors from'tailwindcss/colors';const {
1
+ import*as React from'react';import {Spinner,Box}from'@admin-layout/gluestack-ui-mobile';import {ThreadsView}from'./containers/ThreadsView.js';import {useChannelDetailQuery,useThreadMessagesQueryWithOptions}from'../../queries/inboxQueries.js';import {useFocusEffect}from'@react-navigation/native';import {config}from'./config/config.js';import colors from'tailwindcss/colors';import {useSafeDialogThreadsMachine}from'./hooks/useSafeDialogThreadsMachine.js';import {Actions,BaseState}from'./workflow/dialog-threads-xstate.js';const {
2
2
  MESSAGES_PER_PAGE
3
3
  } = config;
4
4
  function DialogThreads({
@@ -6,22 +6,29 @@ function DialogThreads({
6
6
  postParentId,
7
7
  role
8
8
  }) {
9
+ var _a;
10
+ const [state, send] = useSafeDialogThreadsMachine();
11
+ const {
12
+ context,
13
+ value
14
+ } = state;
15
+ const {
16
+ channelsDetail,
17
+ loading,
18
+ error
19
+ } = context;
9
20
  const {
10
21
  data: channelData,
11
22
  loading: channelLoading,
12
23
  refetch: channelRefetch
13
- } = useViewChannelDetailQuery({
14
- variables: {
15
- id: channelId == null ? void 0 : channelId.toString()
16
- }
17
- });
24
+ } = useChannelDetailQuery(channelId == null ? void 0 : channelId.toString(), {});
18
25
  const {
19
26
  data: threadsData,
20
27
  loading: threadLoading,
21
28
  error: threadsError,
22
29
  refetch: threadsRefetch,
23
30
  subscribeToMore: threadsSubscribeToMore
24
- } = useThreadMessagesQuery({
31
+ } = useThreadMessagesQueryWithOptions({
25
32
  variables: {
26
33
  channelId: channelId == null ? void 0 : channelId.toString(),
27
34
  role: role == null ? void 0 : role.toString(),
@@ -29,27 +36,58 @@ function DialogThreads({
29
36
  repliesLimit2: 5
30
37
  }
31
38
  });
32
- const channelsDetail = React.useMemo(() => {
33
- if (!(channelData == null ? void 0 : channelData.viewChannelDetail))
34
- return null;
35
- return channelData == null ? void 0 : channelData.viewChannelDetail;
39
+ console.log("threadsData", (_a = threadsData == null ? void 0 : threadsData.threadMessages) == null ? void 0 : _a.totalCount);
40
+ console.log("channelid", channelId);
41
+ React.useEffect(() => {
42
+ send({
43
+ type: Actions.INITIALIZE,
44
+ data: {
45
+ channelId,
46
+ postParentId,
47
+ role
48
+ }
49
+ });
50
+ }, [channelId, postParentId, role]);
51
+ React.useEffect(() => {
52
+ if (channelData == null ? void 0 : channelData.viewChannelDetail) {
53
+ send({
54
+ type: Actions.SET_CHANNEL_DETAIL,
55
+ data: {
56
+ channelsDetail: channelData.viewChannelDetail
57
+ }
58
+ });
59
+ }
36
60
  }, [channelData]);
61
+ React.useEffect(() => {
62
+ var _a2;
63
+ if (threadsData) {
64
+ send({
65
+ type: Actions.SET_THREADS,
66
+ data: {
67
+ threadData: ((_a2 = threadsData == null ? void 0 : threadsData.threadMessages) == null ? void 0 : _a2.data) || []
68
+ }
69
+ });
70
+ }
71
+ }, [threadsData]);
72
+ React.useEffect(() => {
73
+ if (threadsError) {
74
+ send({
75
+ type: Actions.ERROR,
76
+ data: {
77
+ error: threadsError
78
+ }
79
+ });
80
+ }
81
+ }, [threadsError]);
37
82
  const refetchChannelDetail = React.useCallback((id) => {
38
83
  return channelRefetch({
39
84
  id: id == null ? void 0 : id.toString()
40
85
  });
41
86
  }, [channelId]);
42
87
  useFocusEffect(React.useCallback(() => {
43
- if (channelId)
44
- refetchChannelDetail(channelId);
88
+ if (channelId) refetchChannelDetail(channelId);
45
89
  return () => {
46
90
  };
47
91
  }, []));
48
- return /* @__PURE__ */ React.createElement(React.Fragment, null, channelLoading ? /* @__PURE__ */ React.createElement(Spinner, { color: colors.blue[500] }) : /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement(
49
- Box,
50
- {
51
- className: "flex-1 bg-gray-200 dark:border-gray-500 dark:bg-gray-500 "
52
- },
53
- /* @__PURE__ */ React.createElement(ThreadsView, { data: threadsData, loading: threadLoading, refetch: threadsRefetch, subscribeToMore: threadsSubscribeToMore, error: threadsError, channelId, role, channelsDetail, refetchChannelDetail })
54
- )));
92
+ return /* @__PURE__ */ React.createElement(React.Fragment, null, state.matches(BaseState.LoadingChannel) || channelLoading ? /* @__PURE__ */ React.createElement(Spinner, { color: colors.blue[500] }) : /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement(Box, { className: "flex-1 bg-gray-200 dark:border-gray-500 dark:bg-gray-500" }, /* @__PURE__ */ React.createElement(ThreadsView, { data: threadsData, loading: threadLoading || state.matches(BaseState.LoadingThreads), refetch: threadsRefetch, subscribeToMore: threadsSubscribeToMore, error: error || threadsError, channelId, role, channelsDetail, refetchChannelDetail }))));
55
93
  }export{DialogThreads,DialogThreads as default};//# sourceMappingURL=DialogThreads.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"DialogThreads.js","sources":["../../../src/screens/inbox/DialogThreads.tsx"],"sourcesContent":["import * as React from 'react';\nimport { Box, Spinner, Text } from '@admin-layout/gluestack-ui-mobile';\nimport { ThreadConversationView } from './containers/ThreadConversationView';\nimport { ThreadsView } from './containers/ThreadsView';\nimport { useViewChannelDetailQuery, useThreadMessagesQuery } from 'common/graphql';\nimport { useFocusEffect } from '@react-navigation/native';\nimport { useSelector } from 'react-redux';\nimport { config } from './config';\nimport colors from 'tailwindcss/colors';\nconst { MESSAGES_PER_PAGE } = config;\n\nexport function DialogThreads({ channelId, postParentId, role }) {\n const {\n data: channelData,\n loading: channelLoading,\n refetch: channelRefetch,\n } = useViewChannelDetailQuery({\n variables: {\n id: channelId?.toString(),\n },\n });\n\n const {\n data: threadsData,\n loading: threadLoading,\n error: threadsError,\n refetch: threadsRefetch,\n subscribeToMore: threadsSubscribeToMore,\n } = useThreadMessagesQuery({\n variables: {\n channelId: channelId?.toString(),\n role: role?.toString(),\n limit: MESSAGES_PER_PAGE,\n repliesLimit2: 5,\n },\n // fetchPolicy: 'cache-and-network',\n });\n\n const channelsDetail = React.useMemo(() => {\n if (!channelData?.viewChannelDetail) return null;\n return channelData?.viewChannelDetail;\n }, [channelData]);\n\n const refetchChannelDetail = React.useCallback(\n (id: string) => {\n return channelRefetch({ id: id?.toString() });\n },\n [channelId],\n );\n\n useFocusEffect(\n React.useCallback(() => {\n // Do something when the screen is focused\n if (channelId) refetchChannelDetail(channelId);\n return () => {};\n }, []),\n );\n\n return (\n // <Box bg={'white'} flex={1} pt={5}>\n <>\n {channelLoading ? (\n <Spinner color={colors.blue[500]} />\n ) : (\n <>\n <Box\n // $dark-borderColor=\"$coolGray600\"\n // $dark-backgroundColor=\"$trueGray700\"\n // $light-backgroundColor=\"$trueGray50\"\n className=\"flex-1 bg-gray-200 dark:border-gray-500 dark:bg-gray-500 \"\n >\n <ThreadsView\n data={threadsData}\n loading={threadLoading}\n refetch={threadsRefetch}\n subscribeToMore={threadsSubscribeToMore}\n error={threadsError}\n channelId={channelId}\n role={role}\n channelsDetail={channelsDetail}\n refetchChannelDetail={refetchChannelDetail}\n />\n </Box>\n </>\n )}\n </>\n );\n\n // return (\n // // <Box bg={'white'} flex={1} pt={5}>\n // <>\n // {channelLoading ? (\n // <Spinner />\n // ) : (\n // <>\n // {postParentId || postParentId == 0 ? (\n // <Box bg={'white'} flex={1}>\n // <ThreadConversationView\n // channelId={channelId}\n // postParentId={postParentId}\n // channelsDetail={channelsDetail}\n // refetchChannelDetail={refetchChannelDetail}\n // />\n // </Box>\n // ) : (\n // <Box\n // flex={1}\n // _dark={{\n // borderColor: 'coolGray.600',\n // backgroundColor: 'gray.700',\n // }}\n // _light={{\n // backgroundColor: 'gray.50',\n // }}\n // >\n // <ThreadsView\n // channelId={channelId}\n // channelsDetail={channelsDetail}\n // refetchChannelDetail={refetchChannelDetail}\n // />\n // </Box>\n // )}\n // </>\n // )}\n // </>\n // );\n}\n\nexport default DialogThreads;\n"],"names":[],"mappings":"iWASA,MAAM;AAAA,EACJ;AACF,CAAI,GAAA,MAAA;AACG,SAAS,aAAc,CAAA;AAAA,EAC5B,SAAA;AAAA,EACA,YAAA;AAAA,EACA;AACF,CAAG,EAAA;AACD,EAAM,MAAA;AAAA,IACJ,IAAM,EAAA,WAAA;AAAA,IACN,OAAS,EAAA,cAAA;AAAA,IACT,OAAS,EAAA;AAAA,MACP,yBAA0B,CAAA;AAAA,IAC5B,SAAW,EAAA;AAAA,MACT,IAAI,SAAW,IAAA,IAAA,GAAA,MAAA,GAAA,SAAA,CAAA,QAAA;AAAA;AACjB,GACD,CAAA;AACD,EAAM,MAAA;AAAA,IACJ,IAAM,EAAA,WAAA;AAAA,IACN,OAAS,EAAA,aAAA;AAAA,IACT,KAAO,EAAA,YAAA;AAAA,IACP,OAAS,EAAA,cAAA;AAAA,IACT,eAAiB,EAAA;AAAA,MACf,sBAAuB,CAAA;AAAA,IACzB,SAAW,EAAA;AAAA,MACT,WAAW,SAAW,IAAA,IAAA,GAAA,MAAA,GAAA,SAAA,CAAA,QAAA,EAAA;AAAA,MACtB,MAAM,IAAM,IAAA,IAAA,GAAA,MAAA,GAAA,IAAA,CAAA,QAAA,EAAA;AAAA,MACZ,KAAO,EAAA,iBAAA;AAAA,MACP,aAAe,EAAA;AAAA;AACjB,GAED,CAAA;AACD,EAAM,MAAA,cAAA,GAAiB,KAAM,CAAA,OAAA,CAAQ,MAAM;AACzC,IAAA,IAAI,EAAC,WAAa,IAAA,IAAA,GAAA,MAAA,GAAA,WAAA,CAAA,iBAAA,CAAA;AAAmB,MAAO,OAAA,IAAA;AAC5C,IAAA,OAAO,WAAa,IAAA,IAAA,GAAA,MAAA,GAAA,WAAA,CAAA,iBAAA;AAAA,GACtB,EAAG,CAAC,WAAW,CAAC,CAAA;AAChB,EAAA,MAAM,oBAAuB,GAAA,KAAA,CAAM,WAAY,CAAA,CAAC,EAAe,KAAA;AAC7D,IAAA,OAAO,cAAe,CAAA;AAAA,MACpB,IAAI,EAAI,IAAA,IAAA,GAAA,MAAA,GAAA,EAAA,CAAA,QAAA;AAAA,KACT,CAAA;AAAA,GACH,EAAG,CAAC,SAAS,CAAC,CAAA;AACd,EAAe,cAAA,CAAA,KAAA,CAAM,YAAY,MAAM;AAErC,IAAI,IAAA,SAAA;AAAW,MAAA,oBAAA,CAAqB,SAAS,CAAA;AAC7C,IAAA,OAAO,MAAM;AAAA,KAAC;AAAA,GAChB,EAAG,EAAE,CAAC,CAAA;AACN,EAEE,uBAAA,KAAA,CAAA,aAAA,CAAA,KAAA,CAAA,QAAA,EAAA,IAAA,EACS,iCAAkB,KAAA,CAAA,aAAA,CAAA,OAAA,EAAA,EAAQ,OAAO,MAAO,CAAA,IAAA,CAAK,GAAM,CAAA,EAAA,CAAA,mBAC5C,KAAA,CAAA,aAAA,CAAA,KAAA,CAAA,QAAA,EAAA,IAAA,kBAAA,KAAA,CAAA,aAAA;AAAA,IAAC,GAAA;AAAA,IAAA;AAAA,MAIb,SAAU,EAAA;AAAA,KAAA;AAAA,oBACO,KAAA,CAAA,aAAA,CAAA,WAAA,EAAA,EAAY,IAAM,EAAA,WAAA,EAAa,SAAS,aAAe,EAAA,OAAA,EAAS,cAAgB,EAAA,eAAA,EAAiB,wBAAwB,KAAO,EAAA,YAAA,EAAc,SAAsB,EAAA,IAAA,EAAY,gBAAgC,oBAA4C,EAAA;AAAA,GAErQ,CACR,CAAA;AAyCR"}
1
+ {"version":3,"file":"DialogThreads.js","sources":["../../../src/screens/inbox/DialogThreads.tsx"],"sourcesContent":["import * as React from 'react';\nimport { Box, Spinner, Text } from '@admin-layout/gluestack-ui-mobile';\nimport { ThreadConversationView } from './containers/ThreadConversationView';\nimport { ThreadsView } from './containers/ThreadsView';\nimport { useChannelDetailQuery, useThreadMessagesQueryWithOptions } from '../../queries/inboxQueries';\nimport { useFocusEffect } from '@react-navigation/native';\nimport { useSelector } from 'react-redux';\nimport { config } from './config';\nimport colors from 'tailwindcss/colors';\nimport { useSafeDialogThreadsMachine } from './hooks/useSafeDialogThreadsMachine';\nimport { Actions, BaseState } from './workflow/dialog-threads-xstate';\nconst { MESSAGES_PER_PAGE } = config;\n\nexport function DialogThreads({ channelId, postParentId, role }) {\n // Use the XState machine for state management\n const [state, send] = useSafeDialogThreadsMachine();\n const { context, value } = state;\n const { channelsDetail, loading, error } = context;\n\n // Fetch channel details\n const {\n data: channelData,\n loading: channelLoading,\n refetch: channelRefetch,\n } = useChannelDetailQuery(channelId?.toString(), {});\n\n // Fetch thread messages\n const {\n data: threadsData,\n loading: threadLoading,\n error: threadsError,\n refetch: threadsRefetch,\n subscribeToMore: threadsSubscribeToMore,\n } = useThreadMessagesQueryWithOptions({\n variables: {\n channelId: channelId?.toString(),\n role: role?.toString(),\n limit: MESSAGES_PER_PAGE,\n repliesLimit2: 5,\n },\n });\n console.log('threadsData', threadsData?.threadMessages?.totalCount);\n console.log('channelid', channelId);\n // Initialize the machine with props\n React.useEffect(() => {\n send({\n type: Actions.INITIALIZE,\n data: { channelId, postParentId, role },\n });\n }, [channelId, postParentId, role]);\n\n // Update channel detail in state when data changes\n React.useEffect(() => {\n if (channelData?.viewChannelDetail) {\n send({\n type: Actions.SET_CHANNEL_DETAIL,\n data: { channelsDetail: channelData.viewChannelDetail },\n });\n }\n }, [channelData]);\n\n // Update thread data in state when data changes\n React.useEffect(() => {\n if (threadsData) {\n send({\n type: Actions.SET_THREADS,\n data: { threadData: threadsData?.threadMessages?.data || [] },\n });\n }\n }, [threadsData]);\n\n // Handle errors\n React.useEffect(() => {\n if (threadsError) {\n send({\n type: Actions.ERROR,\n data: { error: threadsError },\n });\n }\n }, [threadsError]);\n\n const refetchChannelDetail = React.useCallback(\n (id: string) => {\n return channelRefetch({ id: id?.toString() });\n },\n [channelId],\n );\n\n useFocusEffect(\n React.useCallback(() => {\n // Do something when the screen is focused\n if (channelId) refetchChannelDetail(channelId);\n return () => {};\n }, []),\n );\n\n return (\n <>\n {state.matches(BaseState.LoadingChannel) || channelLoading ? (\n <Spinner color={colors.blue[500]} />\n ) : (\n <>\n <Box className=\"flex-1 bg-gray-200 dark:border-gray-500 dark:bg-gray-500\">\n <ThreadsView\n data={threadsData}\n loading={threadLoading || state.matches(BaseState.LoadingThreads)}\n refetch={threadsRefetch}\n subscribeToMore={threadsSubscribeToMore}\n error={error || threadsError}\n channelId={channelId}\n role={role}\n channelsDetail={channelsDetail}\n refetchChannelDetail={refetchChannelDetail}\n />\n </Box>\n </>\n )}\n </>\n );\n}\n\nexport default DialogThreads;\n"],"names":["_a"],"mappings":"4gBAWA,MAAM;AAAA,EACJ;AACF,CAAA,GAAI,MAAA;AACG,SAAS,aAAA,CAAc;AAAA,EAC5B,SAAA;AAAA,EACA,YAAA;AAAA,EACA;AACF,CAAA,EAAG;AAlBH,EAAA,IAAA,EAAA;AAoBE,EAAA,MAAM,CAAC,KAAA,EAAO,IAAI,CAAA,GAAI,2BAAA,EAA4B;AAClD,EAAA,MAAM;AAAA,IACJ,OAAA;AAAA,IACA;AAAA,GACF,GAAI,KAAA;AACJ,EAAA,MAAM;AAAA,IACJ,cAAA;AAAA,IACA,OAAA;AAAA,IACA;AAAA,GACF,GAAI,OAAA;AAGJ,EAAA,MAAM;AAAA,IACJ,IAAA,EAAM,WAAA;AAAA,IACN,OAAA,EAAS,cAAA;AAAA,IACT,OAAA,EAAS;AAAA,GACX,GAAI,qBAAA,CAAsB,SAAA,IAAA,IAAA,GAAA,MAAA,GAAA,SAAA,CAAW,QAAA,EAAA,EAAY,EAAE,CAAA;AAGnD,EAAA,MAAM;AAAA,IACJ,IAAA,EAAM,WAAA;AAAA,IACN,OAAA,EAAS,aAAA;AAAA,IACT,KAA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,KAAA,CAAA,aAAA,CAAC,WAAA,EAAA,EAAY,MAAM,WAAA,EAAa,OAAA,EAAS,iBAAiB,KAAA,CAAM,OAAA,CAAQ,UAAU,cAAc,CAAA,EAAG,SAAS,cAAA,EAAgB,eAAA,EAAiB,wBAAwB,KAAA,EAAO,KAAA,IAAS,cAAc,SAAA,EAAsB,IAAA,EAAY,gBAAgC,oBAAA,EAA4C,CACrT,CACJ,CACR,CAAA;AACR"}
@@ -1 +1 @@
1
- {"version":3,"file":"Inbox.js","sources":["../../../src/screens/inbox/Inbox.tsx"],"sourcesContent":["import * as React from 'react';\nimport { Box, Text } from '@admin-layout/gluestack-ui-mobile';\n\nimport { Dialogs } from './containers/Dialogs';\n// import { SupportServiceDialogs } from './containers/SupportServiceDialogs';\n\nexport const Inbox = (props: any) => {\n const { channelFilters, channelRole, supportServices } = props;\n return (\n <Box className=\"flex-1 bg-white\">\n {/* {supportServices && (\n <SupportServiceDialogs channelFilters={channelFilters} channelRole={channelRole} {...props} />\n )} */}\n <Dialogs channelFilters={channelFilters} channelRole={channelRole} {...props} />\n </Box>\n );\n};\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAKa,MAAA,KAAA,GAAQ,CAAC,KAAe,KAAA;AACnC,EAAM,MAAA;AAAA,IACJ,cAAA;AAAA,IACA,WAAA;AAAA,IACA;AAAA,GACE,GAAA,KAAA;AACJ,EAAO,uBAAA,KAAA,CAAA,aAAA,CAAC,OAAI,SAAU,EAAA,iBAAA,EAAA,sCAIX,OAAQ,EAAA,cAAA,CAAA,EAAA,cAAA,EAAgC,WAA8B,EAAA,EAAA,KAAA,CAAO,CAClF,CAAA;AACR"}
1
+ {"version":3,"file":"Inbox.js","sources":["../../../src/screens/inbox/Inbox.tsx"],"sourcesContent":["import * as React from 'react';\nimport { Box, Text } from '@admin-layout/gluestack-ui-mobile';\n\nimport { Dialogs } from './containers/Dialogs';\n// import { SupportServiceDialogs } from './containers/SupportServiceDialogs';\n\nexport const Inbox = (props: any) => {\n const { channelFilters, channelRole, supportServices } = props;\n return (\n <Box className=\"flex-1 bg-white\">\n {/* {supportServices && (\n <SupportServiceDialogs channelFilters={channelFilters} channelRole={channelRole} {...props} />\n )} */}\n <Dialogs channelFilters={channelFilters} channelRole={channelRole} {...props} />\n </Box>\n );\n};\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAKO,MAAM,KAAA,GAAQ,CAAC,KAAA,KAAe;AACnC,EAAA,MAAM;AAAA,IACJ,cAAA;AAAA,IACA,WAAA;AAAA,IACA;AAAA,GACF,GAAI,KAAA;AACJ,EAAA,uBAAO,KAAA,CAAA,aAAA,CAAC,OAAI,SAAA,EAAU,iBAAA,EAAA,sCAIX,OAAA,EAAA,cAAA,CAAA,EAAQ,cAAA,EAAgC,WAAA,EAAA,EAA8B,KAAA,CAAO,CAClF,CAAA;AACR"}
@@ -1 +1 @@
1
- import*as FileSystem from'expo-file-system';const IMAGE_CACHE_FOLDER = `${FileSystem.cacheDirectory}`;export{IMAGE_CACHE_FOLDER,IMAGE_CACHE_FOLDER as default};//# sourceMappingURL=consts.js.map
1
+ import*as FileSystem from'expo-file-system';const IMAGE_CACHE_FOLDER = `${FileSystem.cacheDirectory}/image-cache/`;export{IMAGE_CACHE_FOLDER,IMAGE_CACHE_FOLDER as default};//# sourceMappingURL=consts.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"consts.js","sources":["../../../../../src/screens/inbox/components/CachedImage/consts.ts"],"sourcesContent":["import * as FileSystem from \"expo-file-system\"\n\nexport const IMAGE_CACHE_FOLDER = `${FileSystem.cacheDirectory}`\n// export const IMAGE_CACHE_FOLDER = `${FileSystem.documentDirectory}images/`\nexport default IMAGE_CACHE_FOLDER\n"],"names":[],"mappings":"4CACa,MAAA,kBAAA,GAAqB,GAAG,UAAW,CAAA,cAAA,CAAA"}
1
+ {"version":3,"file":"consts.js","sources":["../../../../../src/screens/inbox/components/CachedImage/consts.ts"],"sourcesContent":["import * as FileSystem from 'expo-file-system';\n\n// Make sure cache directory path ends with a slash\nexport const IMAGE_CACHE_FOLDER = `${FileSystem.cacheDirectory}/image-cache/`;\n// export const IMAGE_CACHE_FOLDER = `${FileSystem.documentDirectory}images/`\nexport default IMAGE_CACHE_FOLDER;\n"],"names":[],"mappings":"4CAGO,MAAM,kBAAA,GAAqB,CAAA,EAAG,UAAA,CAAW,cAAc,CAAA,aAAA"}