@messenger-box/platform-mobile 0.0.1-alpha.360 → 0.0.1-alpha.363
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +8 -0
- package/lib/index.js +2085 -527
- package/lib/index.js.map +1 -1
- package/lib/screens/inbox/DialogThreadMessages.d.ts +7 -0
- package/lib/screens/inbox/DialogThreads.d.ts +6 -0
- package/lib/screens/inbox/components/SupportServiceDialogsListItem.d.ts +21 -0
- package/lib/screens/inbox/components/ThreadsViewItem.d.ts +18 -0
- package/lib/screens/inbox/config/config.d.ts +2 -0
- package/lib/screens/inbox/containers/Dialogs.d.ts +1 -0
- package/lib/screens/inbox/containers/SupportServiceDialogs.d.ts +6 -0
- package/lib/screens/inbox/containers/ThreadConversationView.d.ts +11 -0
- package/lib/screens/inbox/containers/ThreadsView.d.ts +8 -0
- package/lib/screens/index.d.ts +2 -0
- package/package.json +4 -4
- package/src/navigation/InboxNavigation.tsx +63 -0
- package/src/screens/inbox/DialogThreadMessages.tsx +28 -0
- package/src/screens/inbox/DialogThreads.tsx +107 -0
- package/src/screens/inbox/Inbox.tsx +5 -3
- package/src/screens/inbox/components/DialogsListItem.tsx +7 -3
- package/src/screens/inbox/components/SupportServiceDialogsListItem.tsx +295 -0
- package/src/screens/inbox/components/ThreadsViewItem.tsx +229 -0
- package/src/screens/inbox/config/config.ts +4 -0
- package/src/screens/inbox/containers/ConversationView.tsx +288 -95
- package/src/screens/inbox/containers/Dialogs.tsx +2 -1
- package/src/screens/inbox/containers/SupportServiceDialogs.tsx +119 -0
- package/src/screens/inbox/containers/ThreadConversationView.tsx +700 -0
- package/src/screens/inbox/containers/ThreadsView.tsx +186 -0
- package/src/screens/index.ts +3 -1
package/lib/index.js
CHANGED
|
@@ -90,6 +90,8 @@ exports.inboxFeature = void 0;
|
|
|
90
90
|
const React = __importStar(__webpack_require__(/*! react */ "react"));
|
|
91
91
|
const client_react_1 = __webpack_require__(/*! @common-stack/client-react */ "@common-stack/client-react");
|
|
92
92
|
const DialogMessages_1 = __webpack_require__(/*! ../screens/inbox/DialogMessages */ "./src/screens/inbox/DialogMessages.tsx");
|
|
93
|
+
const DialogThreads_1 = __webpack_require__(/*! ../screens/inbox/DialogThreads */ "./src/screens/inbox/DialogThreads.tsx");
|
|
94
|
+
const DialogThreadMessages_1 = __webpack_require__(/*! ../screens/inbox/DialogThreadMessages */ "./src/screens/inbox/DialogThreadMessages.tsx");
|
|
93
95
|
const native_base_1 = __webpack_require__(/*! native-base */ "native-base");
|
|
94
96
|
const vector_icons_1 = __webpack_require__(/*! @expo/vector-icons */ "@expo/vector-icons");
|
|
95
97
|
const inboxConfig = {
|
|
@@ -111,6 +113,48 @@ const inboxConfig = {
|
|
|
111
113
|
},
|
|
112
114
|
},
|
|
113
115
|
},
|
|
116
|
+
['//thread']: {
|
|
117
|
+
exact: true,
|
|
118
|
+
name: 'Thread',
|
|
119
|
+
props: {
|
|
120
|
+
initialParams: { channelId: null, postParentId: null, role: null },
|
|
121
|
+
component: (props) => {
|
|
122
|
+
var _a, _b, _c, _d, _e, _f;
|
|
123
|
+
return (React.createElement(DialogThreads_1.DialogThreads, Object.assign({}, props, { channelId: (_b = (_a = props === null || props === void 0 ? void 0 : props.route) === null || _a === void 0 ? void 0 : _a.params) === null || _b === void 0 ? void 0 : _b.channelId, postParentId: (_d = (_c = props === null || props === void 0 ? void 0 : props.route) === null || _c === void 0 ? void 0 : _c.params) === null || _d === void 0 ? void 0 : _d.postParentId, role: (_f = (_e = props === null || props === void 0 ? void 0 : props.route) === null || _e === void 0 ? void 0 : _e.params) === null || _f === void 0 ? void 0 : _f.role })));
|
|
124
|
+
},
|
|
125
|
+
options: ({ navigation }) => {
|
|
126
|
+
return {
|
|
127
|
+
headerShown: true,
|
|
128
|
+
title: 'Thread',
|
|
129
|
+
headerBackTitleVisible: false,
|
|
130
|
+
gestureEnabled: false,
|
|
131
|
+
swipeEnabled: false,
|
|
132
|
+
headerLeft: (props) => (React.createElement(native_base_1.IconButton, { onPress: () => navigation.goBack(), icon: React.createElement(native_base_1.Icon, { size: 'lg', as: vector_icons_1.MaterialIcons, name: "arrow-back-ios", color: 'black' }) })),
|
|
133
|
+
};
|
|
134
|
+
},
|
|
135
|
+
},
|
|
136
|
+
},
|
|
137
|
+
['//threadmessage']: {
|
|
138
|
+
exact: true,
|
|
139
|
+
name: 'ThreadMessage',
|
|
140
|
+
props: {
|
|
141
|
+
initialParams: { channelId: null, postParentId: null, isPostParentIdThread: null, role: null },
|
|
142
|
+
component: (props) => {
|
|
143
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
144
|
+
return (React.createElement(DialogThreadMessages_1.DialogThreadMessages, Object.assign({}, props, { channelId: (_b = (_a = props === null || props === void 0 ? void 0 : props.route) === null || _a === void 0 ? void 0 : _a.params) === null || _b === void 0 ? void 0 : _b.channelId, postParentId: (_d = (_c = props === null || props === void 0 ? void 0 : props.route) === null || _c === void 0 ? void 0 : _c.params) === null || _d === void 0 ? void 0 : _d.postParentId, isPostParentIdThread: (_f = (_e = props === null || props === void 0 ? void 0 : props.route) === null || _e === void 0 ? void 0 : _e.params) === null || _f === void 0 ? void 0 : _f.isPostParentIdThread, role: (_h = (_g = props === null || props === void 0 ? void 0 : props.route) === null || _g === void 0 ? void 0 : _g.params) === null || _h === void 0 ? void 0 : _h.role })));
|
|
145
|
+
},
|
|
146
|
+
options: ({ navigation }) => {
|
|
147
|
+
return {
|
|
148
|
+
headerShown: true,
|
|
149
|
+
title: 'Inbox',
|
|
150
|
+
headerBackTitleVisible: false,
|
|
151
|
+
gestureEnabled: false,
|
|
152
|
+
swipeEnabled: false,
|
|
153
|
+
headerLeft: (props) => (React.createElement(native_base_1.IconButton, { onPress: () => navigation.goBack(), icon: React.createElement(native_base_1.Icon, { size: 'lg', as: vector_icons_1.MaterialIcons, name: "arrow-back-ios", color: 'black' }) })),
|
|
154
|
+
};
|
|
155
|
+
},
|
|
156
|
+
},
|
|
157
|
+
},
|
|
114
158
|
};
|
|
115
159
|
exports.inboxFeature = new client_react_1.Feature({
|
|
116
160
|
routeConfig: inboxConfig,
|
|
@@ -190,6 +234,165 @@ function DialogMessages({ channelId }) {
|
|
|
190
234
|
exports.DialogMessages = DialogMessages;
|
|
191
235
|
|
|
192
236
|
|
|
237
|
+
/***/ }),
|
|
238
|
+
|
|
239
|
+
/***/ "./src/screens/inbox/DialogThreadMessages.tsx":
|
|
240
|
+
/*!****************************************************!*\
|
|
241
|
+
!*** ./src/screens/inbox/DialogThreadMessages.tsx ***!
|
|
242
|
+
\****************************************************/
|
|
243
|
+
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {
|
|
244
|
+
|
|
245
|
+
|
|
246
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
247
|
+
if (k2 === undefined) k2 = k;
|
|
248
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
249
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
250
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
251
|
+
}
|
|
252
|
+
Object.defineProperty(o, k2, desc);
|
|
253
|
+
}) : (function(o, m, k, k2) {
|
|
254
|
+
if (k2 === undefined) k2 = k;
|
|
255
|
+
o[k2] = m[k];
|
|
256
|
+
}));
|
|
257
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
258
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
259
|
+
}) : function(o, v) {
|
|
260
|
+
o["default"] = v;
|
|
261
|
+
});
|
|
262
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
263
|
+
if (mod && mod.__esModule) return mod;
|
|
264
|
+
var result = {};
|
|
265
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
266
|
+
__setModuleDefault(result, mod);
|
|
267
|
+
return result;
|
|
268
|
+
};
|
|
269
|
+
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
270
|
+
exports.DialogThreadMessages = void 0;
|
|
271
|
+
const React = __importStar(__webpack_require__(/*! react */ "react"));
|
|
272
|
+
const native_base_1 = __webpack_require__(/*! native-base */ "native-base");
|
|
273
|
+
const ThreadConversationView_1 = __webpack_require__(/*! ./containers/ThreadConversationView */ "./src/screens/inbox/containers/ThreadConversationView.tsx");
|
|
274
|
+
const native_1 = __webpack_require__(/*! @react-navigation/native */ "@react-navigation/native");
|
|
275
|
+
function DialogThreadMessages({ channelId, postParentId, isPostParentIdThread, role }) {
|
|
276
|
+
(0, native_1.useFocusEffect)(React.useCallback(() => {
|
|
277
|
+
// Do something when the screen is focused
|
|
278
|
+
return () => { };
|
|
279
|
+
}, []));
|
|
280
|
+
return (React.createElement(native_base_1.Box, { bg: 'white', flex: 1 },
|
|
281
|
+
React.createElement(ThreadConversationView_1.ThreadConversationView, { channelId: channelId, postParentId: postParentId, isPostParentIdThread: isPostParentIdThread, role: role })));
|
|
282
|
+
}
|
|
283
|
+
exports.DialogThreadMessages = DialogThreadMessages;
|
|
284
|
+
|
|
285
|
+
|
|
286
|
+
/***/ }),
|
|
287
|
+
|
|
288
|
+
/***/ "./src/screens/inbox/DialogThreads.tsx":
|
|
289
|
+
/*!*********************************************!*\
|
|
290
|
+
!*** ./src/screens/inbox/DialogThreads.tsx ***!
|
|
291
|
+
\*********************************************/
|
|
292
|
+
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {
|
|
293
|
+
|
|
294
|
+
|
|
295
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
296
|
+
if (k2 === undefined) k2 = k;
|
|
297
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
298
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
299
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
300
|
+
}
|
|
301
|
+
Object.defineProperty(o, k2, desc);
|
|
302
|
+
}) : (function(o, m, k, k2) {
|
|
303
|
+
if (k2 === undefined) k2 = k;
|
|
304
|
+
o[k2] = m[k];
|
|
305
|
+
}));
|
|
306
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
307
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
308
|
+
}) : function(o, v) {
|
|
309
|
+
o["default"] = v;
|
|
310
|
+
});
|
|
311
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
312
|
+
if (mod && mod.__esModule) return mod;
|
|
313
|
+
var result = {};
|
|
314
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
315
|
+
__setModuleDefault(result, mod);
|
|
316
|
+
return result;
|
|
317
|
+
};
|
|
318
|
+
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
319
|
+
exports.DialogThreads = void 0;
|
|
320
|
+
const React = __importStar(__webpack_require__(/*! react */ "react"));
|
|
321
|
+
const native_base_1 = __webpack_require__(/*! native-base */ "native-base");
|
|
322
|
+
const ThreadsView_1 = __webpack_require__(/*! ./containers/ThreadsView */ "./src/screens/inbox/containers/ThreadsView.tsx");
|
|
323
|
+
const platform_client_1 = __webpack_require__(/*! @messenger-box/platform-client */ "@messenger-box/platform-client");
|
|
324
|
+
const native_1 = __webpack_require__(/*! @react-navigation/native */ "@react-navigation/native");
|
|
325
|
+
function DialogThreads({ channelId, postParentId, role }) {
|
|
326
|
+
const { data, loading: channelLoading, refetch, } = (0, platform_client_1.useViewChannelDetailQuery)({
|
|
327
|
+
variables: {
|
|
328
|
+
id: channelId === null || channelId === void 0 ? void 0 : channelId.toString(),
|
|
329
|
+
},
|
|
330
|
+
});
|
|
331
|
+
const channelsDetail = React.useMemo(() => {
|
|
332
|
+
if (!(data === null || data === void 0 ? void 0 : data.viewChannelDetail))
|
|
333
|
+
return null;
|
|
334
|
+
return data === null || data === void 0 ? void 0 : data.viewChannelDetail;
|
|
335
|
+
}, [data]);
|
|
336
|
+
const refetchChannelDetail = React.useCallback((id) => {
|
|
337
|
+
return refetch({ id: id === null || id === void 0 ? void 0 : id.toString() });
|
|
338
|
+
}, [channelId]);
|
|
339
|
+
(0, native_1.useFocusEffect)(React.useCallback(() => {
|
|
340
|
+
// Do something when the screen is focused
|
|
341
|
+
refetchChannelDetail(channelId);
|
|
342
|
+
return () => { };
|
|
343
|
+
}, []));
|
|
344
|
+
return (
|
|
345
|
+
// <Box bg={'white'} flex={1} pt={5}>
|
|
346
|
+
React.createElement(React.Fragment, null, channelLoading ? (React.createElement(native_base_1.Spinner, null)) : (React.createElement(React.Fragment, null,
|
|
347
|
+
React.createElement(native_base_1.Box, { flex: 1, _dark: {
|
|
348
|
+
borderColor: 'coolGray.600',
|
|
349
|
+
backgroundColor: 'gray.700',
|
|
350
|
+
}, _light: {
|
|
351
|
+
backgroundColor: 'gray.50',
|
|
352
|
+
} },
|
|
353
|
+
React.createElement(ThreadsView_1.ThreadsView, { channelId: channelId, role: role, channelsDetail: channelsDetail, refetchChannelDetail: refetchChannelDetail }))))));
|
|
354
|
+
// return (
|
|
355
|
+
// // <Box bg={'white'} flex={1} pt={5}>
|
|
356
|
+
// <>
|
|
357
|
+
// {channelLoading ? (
|
|
358
|
+
// <Spinner />
|
|
359
|
+
// ) : (
|
|
360
|
+
// <>
|
|
361
|
+
// {postParentId || postParentId == 0 ? (
|
|
362
|
+
// <Box bg={'white'} flex={1}>
|
|
363
|
+
// <ThreadConversationView
|
|
364
|
+
// channelId={channelId}
|
|
365
|
+
// postParentId={postParentId}
|
|
366
|
+
// channelsDetail={channelsDetail}
|
|
367
|
+
// refetchChannelDetail={refetchChannelDetail}
|
|
368
|
+
// />
|
|
369
|
+
// </Box>
|
|
370
|
+
// ) : (
|
|
371
|
+
// <Box
|
|
372
|
+
// flex={1}
|
|
373
|
+
// _dark={{
|
|
374
|
+
// borderColor: 'coolGray.600',
|
|
375
|
+
// backgroundColor: 'gray.700',
|
|
376
|
+
// }}
|
|
377
|
+
// _light={{
|
|
378
|
+
// backgroundColor: 'gray.50',
|
|
379
|
+
// }}
|
|
380
|
+
// >
|
|
381
|
+
// <ThreadsView
|
|
382
|
+
// channelId={channelId}
|
|
383
|
+
// channelsDetail={channelsDetail}
|
|
384
|
+
// refetchChannelDetail={refetchChannelDetail}
|
|
385
|
+
// />
|
|
386
|
+
// </Box>
|
|
387
|
+
// )}
|
|
388
|
+
// </>
|
|
389
|
+
// )}
|
|
390
|
+
// </>
|
|
391
|
+
// );
|
|
392
|
+
}
|
|
393
|
+
exports.DialogThreads = DialogThreads;
|
|
394
|
+
|
|
395
|
+
|
|
193
396
|
/***/ }),
|
|
194
397
|
|
|
195
398
|
/***/ "./src/screens/inbox/Inbox.tsx":
|
|
@@ -227,9 +430,11 @@ exports.Inbox = void 0;
|
|
|
227
430
|
const React = __importStar(__webpack_require__(/*! react */ "react"));
|
|
228
431
|
const native_base_1 = __webpack_require__(/*! native-base */ "native-base");
|
|
229
432
|
const Dialogs_1 = __webpack_require__(/*! ./containers/Dialogs */ "./src/screens/inbox/containers/Dialogs.tsx");
|
|
433
|
+
const SupportServiceDialogs_1 = __webpack_require__(/*! ./containers/SupportServiceDialogs */ "./src/screens/inbox/containers/SupportServiceDialogs.tsx");
|
|
230
434
|
const Inbox = (props) => {
|
|
231
|
-
const { channelFilters, channelRole } = props;
|
|
435
|
+
const { channelFilters, channelRole, supportServices } = props;
|
|
232
436
|
return (React.createElement(native_base_1.Box, { bg: 'white', flex: 1 },
|
|
437
|
+
supportServices && React.createElement(SupportServiceDialogs_1.SupportServiceDialogs, Object.assign({ channelFilters: channelFilters, channelRole: channelRole }, props)),
|
|
233
438
|
React.createElement(Dialogs_1.Dialogs, Object.assign({ channelFilters: channelFilters, channelRole: channelRole }, props))));
|
|
234
439
|
};
|
|
235
440
|
exports.Inbox = Inbox;
|
|
@@ -452,17 +657,19 @@ const DialogsListItemComponent = function DialogsListItem({ currentUser,
|
|
|
452
657
|
// users,
|
|
453
658
|
selectedChannelId, channel, onOpen, }) {
|
|
454
659
|
var _a, _b, _c;
|
|
660
|
+
const parentId = null;
|
|
455
661
|
const { data: messagesQuery, loading: messageLoading, refetch: refetchMessages, } = (0, platform_client_1.useMessagesQuery)({
|
|
456
662
|
variables: {
|
|
457
663
|
channelId: (_a = channel === null || channel === void 0 ? void 0 : channel.id) === null || _a === void 0 ? void 0 : _a.toString(),
|
|
458
|
-
|
|
664
|
+
parentId: parentId,
|
|
665
|
+
limit: 25,
|
|
459
666
|
},
|
|
460
667
|
fetchPolicy: 'cache-and-network',
|
|
461
668
|
});
|
|
462
669
|
(0, native_1.useFocusEffect)(react_1.default.useCallback(() => {
|
|
463
670
|
var _a;
|
|
464
671
|
// Do something when the screen is focused
|
|
465
|
-
refetchMessages({ channelId: (_a = channel === null || channel === void 0 ? void 0 : channel.id) === null || _a === void 0 ? void 0 : _a.toString(), limit:
|
|
672
|
+
refetchMessages({ channelId: (_a = channel === null || channel === void 0 ? void 0 : channel.id) === null || _a === void 0 ? void 0 : _a.toString(), parentId: parentId, limit: 25 });
|
|
466
673
|
return () => {
|
|
467
674
|
// Do something when the screen is unfocused
|
|
468
675
|
// Useful for cleanup functions
|
|
@@ -474,7 +681,9 @@ selectedChannelId, channel, onOpen, }) {
|
|
|
474
681
|
return null;
|
|
475
682
|
}
|
|
476
683
|
const { data } = messagesQuery.messages;
|
|
477
|
-
|
|
684
|
+
const filteredData = data === null || data === void 0 ? void 0 : data.filter((p) => (p === null || p === void 0 ? void 0 : p.message) !== '');
|
|
685
|
+
return filteredData[0];
|
|
686
|
+
//return data[data.length - 1];
|
|
478
687
|
}, [messagesQuery]);
|
|
479
688
|
const channelMembers = (0, react_1.useMemo)(() => {
|
|
480
689
|
var _a, _b, _c;
|
|
@@ -978,48 +1187,10 @@ exports.ImageViewerModal = ImageViewerModal_1.default;
|
|
|
978
1187
|
|
|
979
1188
|
/***/ }),
|
|
980
1189
|
|
|
981
|
-
/***/ "./src/screens/inbox/
|
|
982
|
-
|
|
983
|
-
!*** ./src/screens/inbox/
|
|
984
|
-
|
|
985
|
-
/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
|
|
986
|
-
|
|
987
|
-
|
|
988
|
-
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
989
|
-
exports.config = void 0;
|
|
990
|
-
const envalid_1 = __webpack_require__(/*! envalid */ "envalid");
|
|
991
|
-
exports.config = (0, envalid_1.cleanEnv)(process['APP_ENV'] || process.env, {
|
|
992
|
-
MESSAGES_PER_PAGE: (0, envalid_1.num)({ devDefault: 10, default: 20 }),
|
|
993
|
-
FILES_PER_MESSAGE: (0, envalid_1.num)({ default: 10 }),
|
|
994
|
-
INBOX_MESSEGE_PATH: (0, envalid_1.str)({ default: 'MainStack.Message' }),
|
|
995
|
-
CALL_TO_ACTION_PATH: (0, envalid_1.str)({ default: 'MainStack.MyReservationDetails' }),
|
|
996
|
-
CALL_TO_ACTION_BOX_BGCOLOR: (0, envalid_1.str)({ default: '#0084ff' }),
|
|
997
|
-
CALL_TO_ACTION_BUTTON_BORDERCOLOR: (0, envalid_1.str)({ default: '#fff' }),
|
|
998
|
-
CALL_TO_ACTION_TEXT_COLOR: (0, envalid_1.str)({ default: '#fff' }),
|
|
999
|
-
});
|
|
1000
|
-
|
|
1001
|
-
|
|
1002
|
-
/***/ }),
|
|
1003
|
-
|
|
1004
|
-
/***/ "./src/screens/inbox/config/index.ts":
|
|
1005
|
-
/*!*******************************************!*\
|
|
1006
|
-
!*** ./src/screens/inbox/config/index.ts ***!
|
|
1007
|
-
\*******************************************/
|
|
1008
|
-
/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
|
|
1009
|
-
|
|
1010
|
-
|
|
1011
|
-
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
1012
|
-
exports.config = void 0;
|
|
1013
|
-
var config_1 = __webpack_require__(/*! ./config */ "./src/screens/inbox/config/config.ts");
|
|
1014
|
-
Object.defineProperty(exports, "config", ({ enumerable: true, get: function () { return config_1.config; } }));
|
|
1015
|
-
|
|
1016
|
-
|
|
1017
|
-
/***/ }),
|
|
1018
|
-
|
|
1019
|
-
/***/ "./src/screens/inbox/containers/ConversationView.tsx":
|
|
1020
|
-
/*!***********************************************************!*\
|
|
1021
|
-
!*** ./src/screens/inbox/containers/ConversationView.tsx ***!
|
|
1022
|
-
\***********************************************************/
|
|
1190
|
+
/***/ "./src/screens/inbox/components/SupportServiceDialogsListItem.tsx":
|
|
1191
|
+
/*!************************************************************************!*\
|
|
1192
|
+
!*** ./src/screens/inbox/components/SupportServiceDialogsListItem.tsx ***!
|
|
1193
|
+
\************************************************************************/
|
|
1023
1194
|
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {
|
|
1024
1195
|
|
|
1025
1196
|
|
|
@@ -1046,124 +1217,1611 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
1046
1217
|
__setModuleDefault(result, mod);
|
|
1047
1218
|
return result;
|
|
1048
1219
|
};
|
|
1049
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
1050
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
1051
|
-
};
|
|
1052
1220
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
1053
|
-
exports.
|
|
1221
|
+
exports.SupportServiceDialogsListItem = exports.SupportServiceDialogsListItemComponent = void 0;
|
|
1054
1222
|
const react_1 = __importStar(__webpack_require__(/*! react */ "react"));
|
|
1055
1223
|
const native_base_1 = __webpack_require__(/*! native-base */ "native-base");
|
|
1056
|
-
const
|
|
1224
|
+
const date_fns_1 = __webpack_require__(/*! date-fns */ "date-fns");
|
|
1057
1225
|
const native_1 = __webpack_require__(/*! @react-navigation/native */ "@react-navigation/native");
|
|
1058
|
-
const react_redux_1 = __webpack_require__(/*! react-redux */ "react-redux");
|
|
1059
|
-
const lodash_1 = __webpack_require__(/*! lodash */ "lodash");
|
|
1060
|
-
const ImagePicker = __importStar(__webpack_require__(/*! expo-image-picker */ "expo-image-picker"));
|
|
1061
|
-
const base_64_1 = __webpack_require__(/*! base-64 */ "base-64");
|
|
1062
|
-
const vector_icons_1 = __webpack_require__(/*! @expo/vector-icons */ "@expo/vector-icons");
|
|
1063
|
-
const react_native_gifted_chat_1 = __webpack_require__(/*! react-native-gifted-chat */ "react-native-gifted-chat");
|
|
1064
1226
|
const platform_client_1 = __webpack_require__(/*! @messenger-box/platform-client */ "@messenger-box/platform-client");
|
|
1065
|
-
const
|
|
1066
|
-
const
|
|
1067
|
-
|
|
1068
|
-
|
|
1069
|
-
|
|
1070
|
-
|
|
1071
|
-
|
|
1072
|
-
|
|
1073
|
-
|
|
1074
|
-
|
|
1075
|
-
|
|
1076
|
-
|
|
1077
|
-
|
|
1078
|
-
|
|
1079
|
-
|
|
1080
|
-
|
|
1081
|
-
|
|
1082
|
-
|
|
1083
|
-
|
|
1084
|
-
|
|
1085
|
-
const
|
|
1086
|
-
const [expoTokens, setExpoTokens] = (0, react_1.useState)([]);
|
|
1087
|
-
const [isShowImageViewer, setImageViewer] = (0, react_1.useState)(false);
|
|
1088
|
-
const [imageObject, setImageObject] = (0, react_1.useState)({});
|
|
1089
|
-
const { startUpload } = (0, platform_client_1.useUploadFilesNative)();
|
|
1090
|
-
const [sendMsg] = (0, platform_client_1.useSendMessagesMutation)();
|
|
1091
|
-
const { data, loading: messageLoading, refetch, } = (0, platform_client_1.useMessagesQuery)({
|
|
1227
|
+
const lodash_1 = __webpack_require__(/*! lodash */ "lodash");
|
|
1228
|
+
const createdAtText = (value) => {
|
|
1229
|
+
if (!value)
|
|
1230
|
+
return '';
|
|
1231
|
+
let date = new Date(value);
|
|
1232
|
+
if ((0, date_fns_1.isToday)(date))
|
|
1233
|
+
return 'Today';
|
|
1234
|
+
if ((0, date_fns_1.isYesterday)(date))
|
|
1235
|
+
return 'Yesterday';
|
|
1236
|
+
return (0, date_fns_1.format)(new Date(value), 'MMM dd, yyyy');
|
|
1237
|
+
};
|
|
1238
|
+
/**
|
|
1239
|
+
* TODO:
|
|
1240
|
+
* - Get Reservation info: reservation date, status
|
|
1241
|
+
* - Add ability to get property information: name, logo
|
|
1242
|
+
*/
|
|
1243
|
+
const SupportServiceDialogsListItemComponent = function DialogsListItem({ currentUser,
|
|
1244
|
+
// users,
|
|
1245
|
+
selectedChannelId, channel, onOpen, refreshing, role, }) {
|
|
1246
|
+
var _a, _b, _c, _d, _e;
|
|
1247
|
+
const { data: threadMessages, loading: threadMessageLoading, error, refetch: refetchThreadMessages, } = (0, platform_client_1.useThreadMessagesQuery)({
|
|
1092
1248
|
variables: {
|
|
1093
|
-
channelId:
|
|
1094
|
-
|
|
1249
|
+
channelId: (_a = channel === null || channel === void 0 ? void 0 : channel.id) === null || _a === void 0 ? void 0 : _a.toString(),
|
|
1250
|
+
role,
|
|
1251
|
+
limit: 25,
|
|
1095
1252
|
},
|
|
1096
|
-
skip: !channelId,
|
|
1097
1253
|
fetchPolicy: 'cache-and-network',
|
|
1098
1254
|
});
|
|
1099
|
-
const {
|
|
1100
|
-
|
|
1101
|
-
|
|
1102
|
-
|
|
1103
|
-
}
|
|
1104
|
-
//
|
|
1105
|
-
|
|
1106
|
-
|
|
1107
|
-
|
|
1108
|
-
|
|
1109
|
-
|
|
1110
|
-
fetchPolicy: 'network-only',
|
|
1111
|
-
pollInterval: 5000,
|
|
1112
|
-
});
|
|
1255
|
+
// const {
|
|
1256
|
+
// data: messagesQuery,
|
|
1257
|
+
// loading: messageLoading,
|
|
1258
|
+
// refetch: refetchMessages,
|
|
1259
|
+
// } = useMessagesQuery({
|
|
1260
|
+
// variables: {
|
|
1261
|
+
// channelId: channel?.id?.toString(),
|
|
1262
|
+
// limit: 25,
|
|
1263
|
+
// },
|
|
1264
|
+
// fetchPolicy: 'cache-and-network',
|
|
1265
|
+
// });
|
|
1113
1266
|
(0, native_1.useFocusEffect)(react_1.default.useCallback(() => {
|
|
1267
|
+
var _a;
|
|
1114
1268
|
// Do something when the screen is focused
|
|
1115
|
-
|
|
1116
|
-
|
|
1117
|
-
channelId: channelId === null || channelId === void 0 ? void 0 : channelId.toString(),
|
|
1118
|
-
limit: MESSAGES_PER_PAGE,
|
|
1119
|
-
}).then(({ data }) => {
|
|
1120
|
-
if (!(data === null || data === void 0 ? void 0 : data.messages)) {
|
|
1121
|
-
return;
|
|
1122
|
-
}
|
|
1123
|
-
const { data: messages, totalCount } = data.messages;
|
|
1124
|
-
setTotalCount(totalCount);
|
|
1125
|
-
setChannelMessages((oldMessages) => (0, lodash_1.uniqBy)([...oldMessages, ...messages], ({ id }) => id));
|
|
1126
|
-
});
|
|
1269
|
+
// refetchMessages({ channelId: channel?.id?.toString(), limit: 25 });
|
|
1270
|
+
refetchThreadMessages({ channelId: (_a = channel === null || channel === void 0 ? void 0 : channel.id) === null || _a === void 0 ? void 0 : _a.toString(), limit: 25 });
|
|
1127
1271
|
return () => {
|
|
1128
1272
|
// Do something when the screen is unfocused
|
|
1129
1273
|
// Useful for cleanup functions
|
|
1130
|
-
setTotalCount(0);
|
|
1131
|
-
setChannelMessages([]);
|
|
1132
1274
|
};
|
|
1133
|
-
}, []));
|
|
1275
|
+
}, [refreshing]));
|
|
1134
1276
|
react_1.default.useEffect(() => {
|
|
1135
|
-
|
|
1136
|
-
|
|
1137
|
-
|
|
1138
|
-
|
|
1139
|
-
|
|
1277
|
+
var _a;
|
|
1278
|
+
if (refreshing) {
|
|
1279
|
+
// refetchMessages({ channelId: channel?.id?.toString(), limit: 25 });
|
|
1280
|
+
refetchThreadMessages({ channelId: (_a = channel === null || channel === void 0 ? void 0 : channel.id) === null || _a === void 0 ? void 0 : _a.toString(), limit: 25 });
|
|
1281
|
+
}
|
|
1282
|
+
}, [refreshing]);
|
|
1283
|
+
// const lastMessageCreatorAndMembers = useMemo(() => {
|
|
1284
|
+
// const replyCount = threadMessages?.threadMessages?.data?.reduce((rc: any, t: any) => rc + t?.replyCount, 0);
|
|
1285
|
+
// if (!messagesQuery?.messages?.data?.length || threadMessages?.threadMessages?.totalCount == 0) {
|
|
1286
|
+
// return null;
|
|
1287
|
+
// }
|
|
1288
|
+
// const { data } = messagesQuery.messages;
|
|
1289
|
+
// const filteredData = data?.filter((p: any) => p?.message !== '');
|
|
1290
|
+
// if (replyCount == 0) {
|
|
1291
|
+
// const post: any =
|
|
1292
|
+
// threadMessages?.threadMessages?.data?.find((t: any) => {
|
|
1293
|
+
// return t?.post?.message !== '';
|
|
1294
|
+
// }) ??
|
|
1295
|
+
// threadMessages?.threadMessages?.data?.find((t: any) => {
|
|
1296
|
+
// return t?.post;
|
|
1297
|
+
// }) ??
|
|
1298
|
+
// null;
|
|
1299
|
+
// return post ? post?.post : null;
|
|
1300
|
+
// } else {
|
|
1301
|
+
// return filteredData[0];
|
|
1302
|
+
// }
|
|
1303
|
+
// // return data[data.length - 1];
|
|
1304
|
+
// }, [threadMessages, messagesQuery]);
|
|
1305
|
+
// const lastMessage = useMemo(() => {
|
|
1306
|
+
// if (!threadMessages?.threadMessages?.data?.length) {
|
|
1307
|
+
// return null;
|
|
1308
|
+
// }
|
|
1309
|
+
// const { data }: any = threadMessages.threadMessages;
|
|
1310
|
+
// const replies =
|
|
1311
|
+
// data
|
|
1312
|
+
// ?.map((t: any) => t?.replies)
|
|
1313
|
+
// ?.flat(1)
|
|
1314
|
+
// ?.filter((p: any) => p?.message !== '') ?? [];
|
|
1315
|
+
// if (replies?.length) {
|
|
1316
|
+
// return replies[0];
|
|
1317
|
+
// // return replies[replies.length - 1];
|
|
1318
|
+
// } else {
|
|
1319
|
+
// const post =
|
|
1320
|
+
// data?.find((t: any) => {
|
|
1321
|
+
// return t?.post?.message !== '';
|
|
1322
|
+
// }) ??
|
|
1323
|
+
// data?.find((t: any) => {
|
|
1324
|
+
// return t?.post;
|
|
1325
|
+
// }) ??
|
|
1326
|
+
// null;
|
|
1327
|
+
// return post ? post?.post : null;
|
|
1328
|
+
// }
|
|
1329
|
+
// }, [threadMessages]);
|
|
1330
|
+
const lastMessage = (0, react_1.useMemo)(() => {
|
|
1331
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
1332
|
+
if (!((_b = (_a = threadMessages === null || threadMessages === void 0 ? void 0 : threadMessages.threadMessages) === null || _a === void 0 ? void 0 : _a.data) === null || _b === void 0 ? void 0 : _b.length)) {
|
|
1333
|
+
return null;
|
|
1334
|
+
}
|
|
1335
|
+
const { data } = threadMessages.threadMessages;
|
|
1336
|
+
const replies = (_e = (_d = (_c = data === null || data === void 0 ? void 0 : data.map((t) => t === null || t === void 0 ? void 0 : t.replies)) === null || _c === void 0 ? void 0 : _c.flat(1)) === null || _d === void 0 ? void 0 : _d.filter((p) => (p === null || p === void 0 ? void 0 : p.message) !== '')) !== null && _e !== void 0 ? _e : [];
|
|
1337
|
+
if (replies === null || replies === void 0 ? void 0 : replies.length) {
|
|
1338
|
+
return replies[0];
|
|
1339
|
+
// return replies[replies.length - 1];
|
|
1340
|
+
}
|
|
1341
|
+
else {
|
|
1342
|
+
const post = (_g = (_f = data === null || data === void 0 ? void 0 : data.find((t) => {
|
|
1343
|
+
var _a;
|
|
1344
|
+
return ((_a = t === null || t === void 0 ? void 0 : t.post) === null || _a === void 0 ? void 0 : _a.message) !== '';
|
|
1345
|
+
})) !== null && _f !== void 0 ? _f : data === null || data === void 0 ? void 0 : data.find((t) => {
|
|
1346
|
+
return t === null || t === void 0 ? void 0 : t.post;
|
|
1347
|
+
})) !== null && _g !== void 0 ? _g : null;
|
|
1348
|
+
return post ? post === null || post === void 0 ? void 0 : post.post : null;
|
|
1349
|
+
}
|
|
1350
|
+
}, [threadMessages]);
|
|
1351
|
+
const creatorAndMembersId = react_1.default.useMemo(() => {
|
|
1352
|
+
var _a, _b, _c, _d, _e, _f;
|
|
1353
|
+
if (!(channel === null || channel === void 0 ? void 0 : channel.members))
|
|
1354
|
+
return null;
|
|
1355
|
+
const membersIds = (_c = (_b = (_a = channel === null || channel === void 0 ? void 0 : channel.members) === null || _a === void 0 ? void 0 : _a.filter((m) => { var _a; return ((_a = m === null || m === void 0 ? void 0 : m.user) === null || _a === void 0 ? void 0 : _a.id) !== (currentUser === null || currentUser === void 0 ? void 0 : currentUser.id); })) === null || _b === void 0 ? void 0 : _b.map((mu) => { var _a; return (_a = mu === null || mu === void 0 ? void 0 : mu.user) === null || _a === void 0 ? void 0 : _a.id; })) !== null && _c !== void 0 ? _c : [];
|
|
1356
|
+
const creatorId = (_d = channel === null || channel === void 0 ? void 0 : channel.creator) === null || _d === void 0 ? void 0 : _d.id;
|
|
1357
|
+
const mergedIds = (_e = [].concat(membersIds, creatorId)) !== null && _e !== void 0 ? _e : [];
|
|
1358
|
+
return (_f = mergedIds === null || mergedIds === void 0 ? void 0 : mergedIds.filter((m, pos) => (mergedIds === null || mergedIds === void 0 ? void 0 : mergedIds.indexOf(m)) === pos)) !== null && _f !== void 0 ? _f : [];
|
|
1359
|
+
}, [channel]);
|
|
1360
|
+
const postParentId = react_1.default.useMemo(() => {
|
|
1361
|
+
var _a;
|
|
1362
|
+
if (!(creatorAndMembersId === null || creatorAndMembersId === void 0 ? void 0 : creatorAndMembersId.length))
|
|
1363
|
+
return null;
|
|
1364
|
+
return (creatorAndMembersId === null || creatorAndMembersId === void 0 ? void 0 : creatorAndMembersId.length) && (creatorAndMembersId === null || creatorAndMembersId === void 0 ? void 0 : creatorAndMembersId.includes(currentUser === null || currentUser === void 0 ? void 0 : currentUser.id))
|
|
1365
|
+
? null
|
|
1366
|
+
: (lastMessage === null || lastMessage === void 0 ? void 0 : lastMessage.parentId)
|
|
1367
|
+
? lastMessage === null || lastMessage === void 0 ? void 0 : lastMessage.parentId
|
|
1368
|
+
: (_a = lastMessage === null || lastMessage === void 0 ? void 0 : lastMessage.id) !== null && _a !== void 0 ? _a : 0;
|
|
1369
|
+
}, [creatorAndMembersId, lastMessage]);
|
|
1370
|
+
return (react_1.default.createElement(native_base_1.Pressable, { onPress: () => (channel === null || channel === void 0 ? void 0 : channel.id) !== selectedChannelId && onOpen(channel === null || channel === void 0 ? void 0 : channel.id, channel === null || channel === void 0 ? void 0 : channel.title, postParentId), borderWidth: '1', borderRadius: 10, borderColor: 'gray.200', flex: 1, _dark: {
|
|
1371
|
+
borderColor: 'coolGray.600',
|
|
1372
|
+
backgroundColor: 'gray.700',
|
|
1373
|
+
}, _web: {
|
|
1374
|
+
shadow: 2,
|
|
1375
|
+
borderWidth: 0,
|
|
1376
|
+
}, _light: {
|
|
1377
|
+
backgroundColor: 'gray.50',
|
|
1378
|
+
} },
|
|
1379
|
+
react_1.default.createElement(native_base_1.HStack
|
|
1380
|
+
// px={2}
|
|
1381
|
+
// pl={3}
|
|
1382
|
+
, {
|
|
1383
|
+
// px={2}
|
|
1384
|
+
// pl={3}
|
|
1385
|
+
py: 3, space: 2, w: '100%', flex: 1, direction: 'row', justifyContent: 'space-between', alignItems: 'center' },
|
|
1386
|
+
react_1.default.createElement(native_base_1.Box, { flex: 0.1, alignItems: 'flex-start', pl: 3 },
|
|
1387
|
+
react_1.default.createElement(native_base_1.Avatar.Group, { _avatar: {
|
|
1388
|
+
size: 'sm',
|
|
1389
|
+
bg: 'transparent',
|
|
1390
|
+
} },
|
|
1391
|
+
react_1.default.createElement(native_base_1.Avatar, { key: 'service-channels-key', bg: 'transparent', size: 9, top: 0, right: 0, zIndex: 1, _image: { borderRadius: 6, borderWidth: 2, borderColor: '#fff' }, source: {
|
|
1392
|
+
uri: (_b = channel === null || channel === void 0 ? void 0 : channel.creator) === null || _b === void 0 ? void 0 : _b.picture,
|
|
1393
|
+
} }, (0, lodash_1.startCase)((_d = (_c = channel === null || channel === void 0 ? void 0 : channel.creator) === null || _c === void 0 ? void 0 : _c.username) === null || _d === void 0 ? void 0 : _d.charAt(0))))),
|
|
1394
|
+
react_1.default.createElement(native_base_1.Box, { flex: 0.9 },
|
|
1395
|
+
react_1.default.createElement(native_base_1.HStack, { space: 1, flex: 1, direction: 'row', justifyContent: 'center', alignItems: 'center' },
|
|
1396
|
+
react_1.default.createElement(native_base_1.Box, { flex: 0.8 },
|
|
1397
|
+
react_1.default.createElement(native_base_1.Text, { color: "gray.600", fontSize: "lg", flexWrap: 'wrap', fontWeight: "semibold" }, channel === null || channel === void 0 ? void 0 : channel.title),
|
|
1398
|
+
react_1.default.createElement(native_base_1.Text, { color: "gray.600", noOfLines: 1 }, (_e = lastMessage === null || lastMessage === void 0 ? void 0 : lastMessage.message) !== null && _e !== void 0 ? _e : '')),
|
|
1399
|
+
react_1.default.createElement(native_base_1.Box, { flex: 0.2 },
|
|
1400
|
+
react_1.default.createElement(native_base_1.Text, { color: "gray.500" }, lastMessage ? createdAtText(lastMessage === null || lastMessage === void 0 ? void 0 : lastMessage.createdAt) : '')))))));
|
|
1401
|
+
};
|
|
1402
|
+
exports.SupportServiceDialogsListItemComponent = SupportServiceDialogsListItemComponent;
|
|
1403
|
+
exports.SupportServiceDialogsListItem = react_1.default.memo(exports.SupportServiceDialogsListItemComponent);
|
|
1404
|
+
|
|
1405
|
+
|
|
1406
|
+
/***/ }),
|
|
1407
|
+
|
|
1408
|
+
/***/ "./src/screens/inbox/components/ThreadsViewItem.tsx":
|
|
1409
|
+
/*!**********************************************************!*\
|
|
1410
|
+
!*** ./src/screens/inbox/components/ThreadsViewItem.tsx ***!
|
|
1411
|
+
\**********************************************************/
|
|
1412
|
+
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {
|
|
1413
|
+
|
|
1414
|
+
|
|
1415
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
1416
|
+
if (k2 === undefined) k2 = k;
|
|
1417
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
1418
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
1419
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
1420
|
+
}
|
|
1421
|
+
Object.defineProperty(o, k2, desc);
|
|
1422
|
+
}) : (function(o, m, k, k2) {
|
|
1423
|
+
if (k2 === undefined) k2 = k;
|
|
1424
|
+
o[k2] = m[k];
|
|
1425
|
+
}));
|
|
1426
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
1427
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
1428
|
+
}) : function(o, v) {
|
|
1429
|
+
o["default"] = v;
|
|
1430
|
+
});
|
|
1431
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
1432
|
+
if (mod && mod.__esModule) return mod;
|
|
1433
|
+
var result = {};
|
|
1434
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
1435
|
+
__setModuleDefault(result, mod);
|
|
1436
|
+
return result;
|
|
1437
|
+
};
|
|
1438
|
+
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
1439
|
+
exports.ThreadViewItem = exports.ThreadViewItemComponent = void 0;
|
|
1440
|
+
const react_1 = __importStar(__webpack_require__(/*! react */ "react"));
|
|
1441
|
+
const native_base_1 = __webpack_require__(/*! native-base */ "native-base");
|
|
1442
|
+
const date_fns_1 = __webpack_require__(/*! date-fns */ "date-fns");
|
|
1443
|
+
const native_1 = __webpack_require__(/*! @react-navigation/native */ "@react-navigation/native");
|
|
1444
|
+
const lodash_1 = __webpack_require__(/*! lodash */ "lodash");
|
|
1445
|
+
const createdAtText = (value) => {
|
|
1446
|
+
if (!value)
|
|
1447
|
+
return '';
|
|
1448
|
+
let date = new Date(value);
|
|
1449
|
+
if ((0, date_fns_1.isToday)(date))
|
|
1450
|
+
return 'Today';
|
|
1451
|
+
if ((0, date_fns_1.isYesterday)(date))
|
|
1452
|
+
return 'Yesterday';
|
|
1453
|
+
return (0, date_fns_1.format)(new Date(value), 'MMM dd, yyyy');
|
|
1454
|
+
};
|
|
1455
|
+
/**
|
|
1456
|
+
* TODO:
|
|
1457
|
+
* - Get Reservation info: reservation date, status
|
|
1458
|
+
* - Add ability to get property information: name, logo
|
|
1459
|
+
*/
|
|
1460
|
+
const ThreadViewItemComponent = function DialogsListItem({ currentUser,
|
|
1461
|
+
// users,
|
|
1462
|
+
thread, onOpen, }) {
|
|
1463
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x;
|
|
1464
|
+
(0, native_1.useFocusEffect)(react_1.default.useCallback(() => {
|
|
1465
|
+
// Do something when the screen is focused
|
|
1466
|
+
return () => {
|
|
1467
|
+
// Do something when the screen is unfocused
|
|
1468
|
+
// Useful for cleanup functions
|
|
1469
|
+
};
|
|
1470
|
+
}, []));
|
|
1471
|
+
const lastMessage = (0, react_1.useMemo)(() => {
|
|
1472
|
+
var _a, _b, _c;
|
|
1473
|
+
if (!thread) {
|
|
1474
|
+
return null;
|
|
1475
|
+
}
|
|
1476
|
+
const replies = (_b = (_a = thread === null || thread === void 0 ? void 0 : thread.replies) === null || _a === void 0 ? void 0 : _a.filter((p) => (p === null || p === void 0 ? void 0 : p.message) !== '')) !== null && _b !== void 0 ? _b : [];
|
|
1477
|
+
if (replies === null || replies === void 0 ? void 0 : replies.length) {
|
|
1478
|
+
return replies[0];
|
|
1479
|
+
// return replies[replies.length - 1];
|
|
1480
|
+
}
|
|
1481
|
+
else {
|
|
1482
|
+
const post = (_c = thread === null || thread === void 0 ? void 0 : thread.post) !== null && _c !== void 0 ? _c : null;
|
|
1483
|
+
return post ? post === null || post === void 0 ? void 0 : post.post : null;
|
|
1484
|
+
}
|
|
1485
|
+
}, [thread]);
|
|
1486
|
+
const participants = react_1.default.useMemo(() => {
|
|
1487
|
+
var _a, _b, _c;
|
|
1488
|
+
if (!((_a = thread === null || thread === void 0 ? void 0 : thread.participants) === null || _a === void 0 ? void 0 : _a.length))
|
|
1489
|
+
return null;
|
|
1490
|
+
return (_c = (_b = thread === null || thread === void 0 ? void 0 : thread.participants) === null || _b === void 0 ? void 0 : _b.filter((u) => { var _a; return ((_a = u === null || u === void 0 ? void 0 : u.user) === null || _a === void 0 ? void 0 : _a.id) !== (currentUser === null || currentUser === void 0 ? void 0 : currentUser.id); })) !== null && _c !== void 0 ? _c : [];
|
|
1491
|
+
}, [thread]);
|
|
1492
|
+
const allParticipantsNames = react_1.default.useMemo(() => {
|
|
1493
|
+
var _a, _b;
|
|
1494
|
+
if (!(participants === null || participants === void 0 ? void 0 : participants.length))
|
|
1495
|
+
return null;
|
|
1496
|
+
return ((_b = (_a = participants === null || participants === void 0 ? void 0 : participants.map((p) => {
|
|
1497
|
+
var _a, _b, _c;
|
|
1498
|
+
return (_c = ((_a = p === null || p === void 0 ? void 0 : p.user) === null || _a === void 0 ? void 0 : _a.givenName) + ' ' + ((_b = p === null || p === void 0 ? void 0 : p.user) === null || _b === void 0 ? void 0 : _b.familyName)) !== null && _c !== void 0 ? _c : '';
|
|
1499
|
+
})) === null || _a === void 0 ? void 0 : _a.join(', ')) !== null && _b !== void 0 ? _b : '');
|
|
1500
|
+
}, [participants]);
|
|
1501
|
+
return (react_1.default.createElement(native_base_1.VStack, { space: 1, py: 2, px: 2, borderWidth: '1', borderRadius: 10, borderColor: 'gray.200', flex: 1, _dark: {
|
|
1502
|
+
borderColor: 'white',
|
|
1503
|
+
backgroundColor: 'white',
|
|
1504
|
+
}, _web: {
|
|
1505
|
+
shadow: 2,
|
|
1506
|
+
borderWidth: 0,
|
|
1507
|
+
}, _light: {
|
|
1508
|
+
backgroundColor: 'white',
|
|
1509
|
+
} },
|
|
1510
|
+
react_1.default.createElement(native_base_1.HStack
|
|
1511
|
+
// px={2}
|
|
1512
|
+
// pl={3}
|
|
1513
|
+
, {
|
|
1514
|
+
// px={2}
|
|
1515
|
+
// pl={3}
|
|
1516
|
+
py: 2, space: 2, w: '100%', flex: 1, direction: 'row', justifyContent: 'space-between', alignItems: 'center' },
|
|
1517
|
+
react_1.default.createElement(native_base_1.Box, { flex: 1 },
|
|
1518
|
+
react_1.default.createElement(native_base_1.HStack, { flex: 1, space: 5, py: 2, alignItems: 'baseline' },
|
|
1519
|
+
react_1.default.createElement(native_base_1.Box, null,
|
|
1520
|
+
react_1.default.createElement(native_base_1.Avatar.Badge, { size: 4, left: 0, zIndex: 1, bg: "green.800" })),
|
|
1521
|
+
react_1.default.createElement(native_base_1.Box, null,
|
|
1522
|
+
react_1.default.createElement(native_base_1.Text, { color: "gray.600", fontSize: "lg", flexWrap: 'wrap', fontWeight: "semibold" }, allParticipantsNames || ''))),
|
|
1523
|
+
react_1.default.createElement(native_base_1.HStack, { space: 1, flex: 1, direction: 'row', justifyContent: 'center', alignItems: 'center' },
|
|
1524
|
+
react_1.default.createElement(native_base_1.Box, { flex: 1 },
|
|
1525
|
+
react_1.default.createElement(native_base_1.HStack, { space: 2, py: 2 },
|
|
1526
|
+
react_1.default.createElement(native_base_1.Box, null,
|
|
1527
|
+
react_1.default.createElement(native_base_1.Avatar, { bg: 'transparent', size: 8, _image: { borderRadius: 6, borderWidth: 2, borderColor: '#fff' }, source: {
|
|
1528
|
+
uri: (_b = (_a = thread === null || thread === void 0 ? void 0 : thread.post) === null || _a === void 0 ? void 0 : _a.author) === null || _b === void 0 ? void 0 : _b.picture,
|
|
1529
|
+
} }, (0, lodash_1.startCase)((_e = (_d = (_c = thread === null || thread === void 0 ? void 0 : thread.post) === null || _c === void 0 ? void 0 : _c.author) === null || _d === void 0 ? void 0 : _d.username) === null || _e === void 0 ? void 0 : _e.charAt(0)))),
|
|
1530
|
+
react_1.default.createElement(native_base_1.Box, null,
|
|
1531
|
+
react_1.default.createElement(native_base_1.HStack, { space: 4 },
|
|
1532
|
+
react_1.default.createElement(native_base_1.Text, null, (_k = ((_g = (_f = thread === null || thread === void 0 ? void 0 : thread.post) === null || _f === void 0 ? void 0 : _f.author) === null || _g === void 0 ? void 0 : _g.givenName) + ' ' + ((_j = (_h = thread === null || thread === void 0 ? void 0 : thread.post) === null || _h === void 0 ? void 0 : _h.author) === null || _j === void 0 ? void 0 : _j.familyName)) !== null && _k !== void 0 ? _k : ''),
|
|
1533
|
+
react_1.default.createElement(native_base_1.Text, { color: "gray.500" }, (thread === null || thread === void 0 ? void 0 : thread.post) ? createdAtText((_l = thread === null || thread === void 0 ? void 0 : thread.post) === null || _l === void 0 ? void 0 : _l.createdAt) : '')),
|
|
1534
|
+
react_1.default.createElement(native_base_1.Text, { color: "gray.600", noOfLines: 1 }, (_o = (_m = thread === null || thread === void 0 ? void 0 : thread.post) === null || _m === void 0 ? void 0 : _m.message) !== null && _o !== void 0 ? _o : ''),
|
|
1535
|
+
!((_p = thread === null || thread === void 0 ? void 0 : thread.replies) === null || _p === void 0 ? void 0 : _p.length) && (react_1.default.createElement(native_base_1.Button, { size: 'xs', variant: 'outline', _text: { fontSize: 12, color: '#000' }, onPress: () => { var _a, _b, _c; return onOpen((_a = thread === null || thread === void 0 ? void 0 : thread.channel) === null || _a === void 0 ? void 0 : _a.id, (_b = thread === null || thread === void 0 ? void 0 : thread.channel) === null || _b === void 0 ? void 0 : _b.title, (_c = thread === null || thread === void 0 ? void 0 : thread.post) === null || _c === void 0 ? void 0 : _c.id); } }, "Reply")))),
|
|
1536
|
+
((_q = thread === null || thread === void 0 ? void 0 : thread.replies) === null || _q === void 0 ? void 0 : _q.length) > 0 && (react_1.default.createElement(native_base_1.HStack, { space: 2, pb: 2, pt: 1 },
|
|
1537
|
+
react_1.default.createElement(native_base_1.Box, null,
|
|
1538
|
+
react_1.default.createElement(native_base_1.Avatar, { bg: 'transparent', size: 8, _image: { borderRadius: 6, borderWidth: 2, borderColor: '#fff' }, source: {
|
|
1539
|
+
uri: (_r = lastMessage === null || lastMessage === void 0 ? void 0 : lastMessage.author) === null || _r === void 0 ? void 0 : _r.picture,
|
|
1540
|
+
} }, (0, lodash_1.startCase)((_t = (_s = lastMessage === null || lastMessage === void 0 ? void 0 : lastMessage.author) === null || _s === void 0 ? void 0 : _s.username) === null || _t === void 0 ? void 0 : _t.charAt(0)))),
|
|
1541
|
+
react_1.default.createElement(native_base_1.Box, null,
|
|
1542
|
+
react_1.default.createElement(native_base_1.HStack, { space: 4 },
|
|
1543
|
+
react_1.default.createElement(native_base_1.Text, null, (_w = ((_u = lastMessage === null || lastMessage === void 0 ? void 0 : lastMessage.author) === null || _u === void 0 ? void 0 : _u.givenName) +
|
|
1544
|
+
' ' +
|
|
1545
|
+
((_v = lastMessage === null || lastMessage === void 0 ? void 0 : lastMessage.author) === null || _v === void 0 ? void 0 : _v.familyName)) !== null && _w !== void 0 ? _w : ''),
|
|
1546
|
+
react_1.default.createElement(native_base_1.Text, { color: "gray.500" }, lastMessage ? createdAtText(lastMessage === null || lastMessage === void 0 ? void 0 : lastMessage.createdAt) : '')),
|
|
1547
|
+
react_1.default.createElement(native_base_1.Text, { color: "gray.600", noOfLines: 1 }, (_x = lastMessage === null || lastMessage === void 0 ? void 0 : lastMessage.message) !== null && _x !== void 0 ? _x : ''),
|
|
1548
|
+
react_1.default.createElement(native_base_1.Button, { size: 'xs', variant: 'outline', _text: { fontSize: 12, color: '#000' }, onPress: () => { var _a, _b, _c; return onOpen((_a = thread === null || thread === void 0 ? void 0 : thread.channel) === null || _a === void 0 ? void 0 : _a.id, (_b = thread === null || thread === void 0 ? void 0 : thread.channel) === null || _b === void 0 ? void 0 : _b.title, (_c = thread === null || thread === void 0 ? void 0 : thread.post) === null || _c === void 0 ? void 0 : _c.id); } }, "Reply"))))))))));
|
|
1549
|
+
};
|
|
1550
|
+
exports.ThreadViewItemComponent = ThreadViewItemComponent;
|
|
1551
|
+
exports.ThreadViewItem = react_1.default.memo(exports.ThreadViewItemComponent);
|
|
1552
|
+
|
|
1553
|
+
|
|
1554
|
+
/***/ }),
|
|
1555
|
+
|
|
1556
|
+
/***/ "./src/screens/inbox/config/config.ts":
|
|
1557
|
+
/*!********************************************!*\
|
|
1558
|
+
!*** ./src/screens/inbox/config/config.ts ***!
|
|
1559
|
+
\********************************************/
|
|
1560
|
+
/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
|
|
1561
|
+
|
|
1562
|
+
|
|
1563
|
+
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
1564
|
+
exports.config = void 0;
|
|
1565
|
+
const envalid_1 = __webpack_require__(/*! envalid */ "envalid");
|
|
1566
|
+
exports.config = (0, envalid_1.cleanEnv)(process['APP_ENV'] || process.env, {
|
|
1567
|
+
MESSAGES_PER_PAGE: (0, envalid_1.num)({ devDefault: 10, default: 20 }),
|
|
1568
|
+
FILES_PER_MESSAGE: (0, envalid_1.num)({ default: 10 }),
|
|
1569
|
+
INBOX_MESSEGE_PATH: (0, envalid_1.str)({ default: 'MainStack.Message' }),
|
|
1570
|
+
// THREAD_MESSEGE_PATH: str({ default: 'MainStack.Thread' }),
|
|
1571
|
+
// THREADS_PATH: str({ default: 'MainStack.ThreadMessage' }),
|
|
1572
|
+
THREAD_MESSEGE_PATH: (0, envalid_1.str)({ default: 'MainStack.ThreadMessage' }),
|
|
1573
|
+
THREADS_PATH: (0, envalid_1.str)({ default: 'MainStack.Thread' }),
|
|
1574
|
+
CALL_TO_ACTION_PATH: (0, envalid_1.str)({ default: 'MainStack.MyReservationDetails' }),
|
|
1575
|
+
CALL_TO_ACTION_BOX_BGCOLOR: (0, envalid_1.str)({ default: '#0084ff' }),
|
|
1576
|
+
CALL_TO_ACTION_BUTTON_BORDERCOLOR: (0, envalid_1.str)({ default: '#fff' }),
|
|
1577
|
+
CALL_TO_ACTION_TEXT_COLOR: (0, envalid_1.str)({ default: '#fff' }),
|
|
1578
|
+
});
|
|
1579
|
+
|
|
1580
|
+
|
|
1581
|
+
/***/ }),
|
|
1582
|
+
|
|
1583
|
+
/***/ "./src/screens/inbox/config/index.ts":
|
|
1584
|
+
/*!*******************************************!*\
|
|
1585
|
+
!*** ./src/screens/inbox/config/index.ts ***!
|
|
1586
|
+
\*******************************************/
|
|
1587
|
+
/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
|
|
1588
|
+
|
|
1589
|
+
|
|
1590
|
+
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
1591
|
+
exports.config = void 0;
|
|
1592
|
+
var config_1 = __webpack_require__(/*! ./config */ "./src/screens/inbox/config/config.ts");
|
|
1593
|
+
Object.defineProperty(exports, "config", ({ enumerable: true, get: function () { return config_1.config; } }));
|
|
1594
|
+
|
|
1595
|
+
|
|
1596
|
+
/***/ }),
|
|
1597
|
+
|
|
1598
|
+
/***/ "./src/screens/inbox/containers/ConversationView.tsx":
|
|
1599
|
+
/*!***********************************************************!*\
|
|
1600
|
+
!*** ./src/screens/inbox/containers/ConversationView.tsx ***!
|
|
1601
|
+
\***********************************************************/
|
|
1602
|
+
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {
|
|
1603
|
+
|
|
1604
|
+
|
|
1605
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
1606
|
+
if (k2 === undefined) k2 = k;
|
|
1607
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
1608
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
1609
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
1610
|
+
}
|
|
1611
|
+
Object.defineProperty(o, k2, desc);
|
|
1612
|
+
}) : (function(o, m, k, k2) {
|
|
1613
|
+
if (k2 === undefined) k2 = k;
|
|
1614
|
+
o[k2] = m[k];
|
|
1615
|
+
}));
|
|
1616
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
1617
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
1618
|
+
}) : function(o, v) {
|
|
1619
|
+
o["default"] = v;
|
|
1620
|
+
});
|
|
1621
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
1622
|
+
if (mod && mod.__esModule) return mod;
|
|
1623
|
+
var result = {};
|
|
1624
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
1625
|
+
__setModuleDefault(result, mod);
|
|
1626
|
+
return result;
|
|
1627
|
+
};
|
|
1628
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
1629
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
1630
|
+
};
|
|
1631
|
+
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
1632
|
+
exports.ConversationView = void 0;
|
|
1633
|
+
const react_1 = __importStar(__webpack_require__(/*! react */ "react"));
|
|
1634
|
+
const native_base_1 = __webpack_require__(/*! native-base */ "native-base");
|
|
1635
|
+
const react_native_1 = __webpack_require__(/*! react-native */ "react-native");
|
|
1636
|
+
const native_1 = __webpack_require__(/*! @react-navigation/native */ "@react-navigation/native");
|
|
1637
|
+
const react_redux_1 = __webpack_require__(/*! react-redux */ "react-redux");
|
|
1638
|
+
const lodash_1 = __webpack_require__(/*! lodash */ "lodash");
|
|
1639
|
+
const ImagePicker = __importStar(__webpack_require__(/*! expo-image-picker */ "expo-image-picker"));
|
|
1640
|
+
const base_64_1 = __webpack_require__(/*! base-64 */ "base-64");
|
|
1641
|
+
const vector_icons_1 = __webpack_require__(/*! @expo/vector-icons */ "@expo/vector-icons");
|
|
1642
|
+
const react_native_gifted_chat_1 = __webpack_require__(/*! react-native-gifted-chat */ "react-native-gifted-chat");
|
|
1643
|
+
const platform_client_1 = __webpack_require__(/*! @messenger-box/platform-client */ "@messenger-box/platform-client");
|
|
1644
|
+
const config_1 = __webpack_require__(/*! ../config */ "./src/screens/inbox/config/index.ts");
|
|
1645
|
+
const user_auth0_client_1 = __webpack_require__(/*! @adminide-stack/user-auth0-client */ "@adminide-stack/user-auth0-client");
|
|
1646
|
+
const SlackMessageContainer_1 = __webpack_require__(/*! ../components/SlackMessageContainer */ "./src/screens/inbox/components/SlackMessageContainer/index.ts");
|
|
1647
|
+
const CachedImage_1 = __importDefault(__webpack_require__(/*! ../components/CachedImage */ "./src/screens/inbox/components/CachedImage/index.tsx"));
|
|
1648
|
+
const date_fns_1 = __webpack_require__(/*! date-fns */ "date-fns");
|
|
1649
|
+
const { MESSAGES_PER_PAGE, CALL_TO_ACTION_BOX_BGCOLOR, CALL_TO_ACTION_PATH, CALL_TO_ACTION_BUTTON_BORDERCOLOR, CALL_TO_ACTION_TEXT_COLOR, } = config_1.config;
|
|
1650
|
+
const createdAtText = (value) => {
|
|
1651
|
+
if (!value)
|
|
1652
|
+
return '';
|
|
1653
|
+
let date = new Date(value);
|
|
1654
|
+
if ((0, date_fns_1.isToday)(date))
|
|
1655
|
+
return 'Today';
|
|
1656
|
+
if ((0, date_fns_1.isYesterday)(date))
|
|
1657
|
+
return 'Yesterday';
|
|
1658
|
+
return (0, date_fns_1.format)(new Date(value), 'MMM dd, yyyy');
|
|
1659
|
+
};
|
|
1660
|
+
const ConversationViewComponent = ({ channelId }) => {
|
|
1661
|
+
var _a;
|
|
1662
|
+
const [channelToTop, setChannelToTop] = (0, react_1.useState)(0);
|
|
1663
|
+
const [channelMessages, setChannelMessages] = (0, react_1.useState)([]);
|
|
1664
|
+
const auth = (0, react_redux_1.useSelector)(user_auth0_client_1.userSelector);
|
|
1665
|
+
const [totalCount, setTotalCount] = (0, react_1.useState)(0);
|
|
1666
|
+
const [selectedImage, setImage] = (0, react_1.useState)('');
|
|
1667
|
+
const [loadingOldMessages, setLoadingOldMessages] = (0, react_1.useState)(false);
|
|
1668
|
+
const color = (0, native_base_1.useColorModeValue)('white', 'black');
|
|
1669
|
+
// const color = useColorModeValue('black', 'white');
|
|
1670
|
+
const navigation = (0, native_1.useNavigation)();
|
|
1671
|
+
const [files, setFiles] = (0, react_1.useState)([]);
|
|
1672
|
+
const [images, setImages] = (0, react_1.useState)([]);
|
|
1673
|
+
const [msg, setMsg] = (0, react_1.useState)('');
|
|
1674
|
+
const [loading, setLoading] = (0, react_1.useState)(false);
|
|
1675
|
+
const [imageLoading, setImageLoading] = (0, react_1.useState)(false);
|
|
1676
|
+
const [expoTokens, setExpoTokens] = (0, react_1.useState)([]);
|
|
1677
|
+
const [isShowImageViewer, setImageViewer] = (0, react_1.useState)(false);
|
|
1678
|
+
const [imageObject, setImageObject] = (0, react_1.useState)({});
|
|
1679
|
+
const isFocused = (0, native_1.useIsFocused)();
|
|
1680
|
+
const { data: mongooseObjectId } = (0, platform_client_1.useGetNewMongooseObjectIdQuery)({
|
|
1681
|
+
fetchPolicy: 'network-only',
|
|
1682
|
+
pollInterval: 5000,
|
|
1683
|
+
});
|
|
1684
|
+
const { startUpload } = (0, platform_client_1.useUploadFilesNative)();
|
|
1685
|
+
const [sendMsg] = (0, platform_client_1.useSendMessagesMutation)();
|
|
1686
|
+
const { data, loading: messageLoading, refetch, } = (0, platform_client_1.useMessagesQuery)({
|
|
1687
|
+
variables: {
|
|
1688
|
+
channelId: channelId === null || channelId === void 0 ? void 0 : channelId.toString(),
|
|
1689
|
+
parentId: null,
|
|
1690
|
+
limit: MESSAGES_PER_PAGE,
|
|
1691
|
+
},
|
|
1692
|
+
skip: !channelId,
|
|
1693
|
+
fetchPolicy: 'cache-and-network',
|
|
1694
|
+
});
|
|
1695
|
+
const { data: channelsDetail, loading: channelLoading, refetch: refetchChannelDetail, } = (0, platform_client_1.useViewChannelDetailQuery)({
|
|
1696
|
+
variables: {
|
|
1697
|
+
id: channelId === null || channelId === void 0 ? void 0 : channelId.toString(),
|
|
1698
|
+
},
|
|
1699
|
+
});
|
|
1700
|
+
// const { data: users } = useGetAllUsersQuery();
|
|
1701
|
+
const { data: checkForMessages } = (0, platform_client_1.useCheckForNewMessagesQuery)({
|
|
1702
|
+
variables: {
|
|
1703
|
+
channelId: channelId === null || channelId === void 0 ? void 0 : channelId.toString(),
|
|
1704
|
+
},
|
|
1705
|
+
skip: !channelId,
|
|
1706
|
+
fetchPolicy: 'network-only',
|
|
1707
|
+
pollInterval: 5000,
|
|
1708
|
+
});
|
|
1709
|
+
(0, native_1.useFocusEffect)(react_1.default.useCallback(() => {
|
|
1710
|
+
// Do something when the screen is focused
|
|
1711
|
+
refetchChannelDetail({ id: channelId === null || channelId === void 0 ? void 0 : channelId.toString() });
|
|
1712
|
+
refetch({
|
|
1713
|
+
channelId: channelId === null || channelId === void 0 ? void 0 : channelId.toString(),
|
|
1714
|
+
parentId: null,
|
|
1715
|
+
limit: MESSAGES_PER_PAGE,
|
|
1716
|
+
}).then(({ data }) => {
|
|
1717
|
+
if (!(data === null || data === void 0 ? void 0 : data.messages)) {
|
|
1718
|
+
return;
|
|
1719
|
+
}
|
|
1720
|
+
const { data: messages, totalCount } = data.messages;
|
|
1721
|
+
setTotalCount(totalCount);
|
|
1722
|
+
setChannelMessages((oldMessages) => (0, lodash_1.uniqBy)([...oldMessages, ...messages], ({ id }) => id));
|
|
1723
|
+
});
|
|
1724
|
+
return () => {
|
|
1725
|
+
// Do something when the screen is unfocused
|
|
1726
|
+
// Useful for cleanup functions
|
|
1727
|
+
setTotalCount(0);
|
|
1728
|
+
setChannelMessages([]);
|
|
1729
|
+
};
|
|
1730
|
+
}, [isFocused]));
|
|
1731
|
+
react_1.default.useEffect(() => {
|
|
1732
|
+
if (selectedImage)
|
|
1733
|
+
setImageLoading(false);
|
|
1734
|
+
}, [selectedImage]);
|
|
1735
|
+
// const currentUser = useMemo(
|
|
1736
|
+
// () => users?.getUsers?.find(({ alias }: any) => alias?.includes(auth?.auth0UserId)),
|
|
1140
1737
|
// [users, auth],
|
|
1141
1738
|
// );
|
|
1142
1739
|
// useEffect(() => {
|
|
1143
|
-
// if (data?.messages?.data && (loadingOldMessages || channelMessages.length === 0)) {
|
|
1144
|
-
// const { data: messages, totalCount: messeageTotalCount } = data.messages;
|
|
1145
|
-
// if (messages && messages.length > 0) {
|
|
1146
|
-
// setChannelMessages((oldMessages: any) => uniqBy([...messages, ...oldMessages], ({ id }) => id));
|
|
1147
|
-
// }
|
|
1148
|
-
// if (totalCount !== messeageTotalCount) setTotalCount(messeageTotalCount);
|
|
1149
|
-
// }
|
|
1150
|
-
// }, [data, loadingOldMessages, channelMessages]);
|
|
1740
|
+
// if (data?.messages?.data && (loadingOldMessages || channelMessages.length === 0)) {
|
|
1741
|
+
// const { data: messages, totalCount: messeageTotalCount } = data.messages;
|
|
1742
|
+
// if (messages && messages.length > 0) {
|
|
1743
|
+
// setChannelMessages((oldMessages: any) => uniqBy([...messages, ...oldMessages], ({ id }) => id));
|
|
1744
|
+
// }
|
|
1745
|
+
// if (totalCount !== messeageTotalCount) setTotalCount(messeageTotalCount);
|
|
1746
|
+
// }
|
|
1747
|
+
// }, [data, loadingOldMessages, channelMessages]);
|
|
1748
|
+
// useEffect(() => {
|
|
1749
|
+
// if (data?.messages?.data) {
|
|
1750
|
+
// const { data: messages, totalCount: messeageTotalCount } = data.messages;
|
|
1751
|
+
// if (
|
|
1752
|
+
// messages &&
|
|
1753
|
+
// messages.length > 0 &&
|
|
1754
|
+
// totalCount !== messeageTotalCount &&
|
|
1755
|
+
// (loadingOldMessages || channelMessages.length === 0)
|
|
1756
|
+
// ) {
|
|
1757
|
+
// setChannelMessages((oldMessages: any) => uniqBy([...messages, ...oldMessages], ({ id }) => id));
|
|
1758
|
+
// setLoadingOldMessages(false);
|
|
1759
|
+
// setTotalCount(messeageTotalCount);
|
|
1760
|
+
// }
|
|
1761
|
+
// // if (totalCount !== messeageTotalCount) setTotalCount(messeageTotalCount);
|
|
1762
|
+
// }
|
|
1763
|
+
// }, [data, loadingOldMessages, channelMessages]);///
|
|
1764
|
+
(0, react_1.useEffect)(() => {
|
|
1765
|
+
var _a;
|
|
1766
|
+
if (((_a = data === null || data === void 0 ? void 0 : data.messages) === null || _a === void 0 ? void 0 : _a.data) && (loadingOldMessages || channelMessages.length === 0)) {
|
|
1767
|
+
const { data: messages, totalCount: messeageTotalCount } = data.messages;
|
|
1768
|
+
if (messages && messages.length > 0) {
|
|
1769
|
+
setChannelMessages((oldMessages) => (0, lodash_1.uniqBy)([...messages, ...oldMessages], ({ id }) => id));
|
|
1770
|
+
setLoadingOldMessages(false);
|
|
1771
|
+
}
|
|
1772
|
+
if (totalCount !== messeageTotalCount)
|
|
1773
|
+
setTotalCount(messeageTotalCount);
|
|
1774
|
+
}
|
|
1775
|
+
}, [data, loadingOldMessages, channelMessages, totalCount]);
|
|
1776
|
+
// useEffect(() => {
|
|
1777
|
+
// if (data?.messages?.data) {
|
|
1778
|
+
// const { data: messages, totalCount: messeageTotalCount } = data.messages;
|
|
1779
|
+
// console.log('messeageTotalCount',messeageTotalCount)
|
|
1780
|
+
// console.log('totalCount',totalCount)
|
|
1781
|
+
// if (messages && messages.length > 0) {
|
|
1782
|
+
// setChannelMessages((oldMessages: any) => uniqBy([...messages, ...oldMessages], ({ id }) => id));
|
|
1783
|
+
// }
|
|
1784
|
+
// if (totalCount !== messeageTotalCount) setTotalCount(messeageTotalCount);
|
|
1785
|
+
// }
|
|
1786
|
+
// }, [data]);
|
|
1787
|
+
// useEffect(() => {
|
|
1788
|
+
// if (checkForMessages?.messages?.totalCount > totalCount) {
|
|
1789
|
+
// const numberOfNewMessages = checkForMessages?.messages?.totalCount - totalCount;
|
|
1790
|
+
// refetch({
|
|
1791
|
+
// limit: numberOfNewMessages,
|
|
1792
|
+
// }).then(({ data }) => {
|
|
1793
|
+
// if (!data?.messages) {
|
|
1794
|
+
// return;
|
|
1795
|
+
// }
|
|
1796
|
+
// const { data: messages, totalCount }:any = data.messages;
|
|
1797
|
+
// setTotalCount(totalCount);
|
|
1798
|
+
// setChannelMessages((oldMessages:any) => uniqBy([...oldMessages, ...messages], ({ id }) => id));
|
|
1799
|
+
// });
|
|
1800
|
+
// }
|
|
1801
|
+
// }, [checkForMessages, totalCount]);
|
|
1802
|
+
(0, react_1.useEffect)(() => {
|
|
1803
|
+
var _a, _b, _c;
|
|
1804
|
+
if (!messageLoading &&
|
|
1805
|
+
((_a = checkForMessages === null || checkForMessages === void 0 ? void 0 : checkForMessages.messages) === null || _a === void 0 ? void 0 : _a.totalCount) &&
|
|
1806
|
+
((_b = checkForMessages === null || checkForMessages === void 0 ? void 0 : checkForMessages.messages) === null || _b === void 0 ? void 0 : _b.totalCount) > totalCount) {
|
|
1807
|
+
const numberOfNewMessages = ((_c = checkForMessages === null || checkForMessages === void 0 ? void 0 : checkForMessages.messages) === null || _c === void 0 ? void 0 : _c.totalCount) - totalCount;
|
|
1808
|
+
console.log('new msg check');
|
|
1809
|
+
refetch({
|
|
1810
|
+
channelId: channelId === null || channelId === void 0 ? void 0 : channelId.toString(),
|
|
1811
|
+
parentId: null,
|
|
1812
|
+
limit: numberOfNewMessages,
|
|
1813
|
+
}).then(({ data }) => {
|
|
1814
|
+
if (!(data === null || data === void 0 ? void 0 : data.messages)) {
|
|
1815
|
+
return;
|
|
1816
|
+
}
|
|
1817
|
+
const { data: messages, totalCount } = data.messages;
|
|
1818
|
+
setTotalCount(totalCount);
|
|
1819
|
+
setChannelMessages((oldMessages) => (0, lodash_1.uniqBy)([...oldMessages, ...messages], ({ id }) => id));
|
|
1820
|
+
});
|
|
1821
|
+
}
|
|
1822
|
+
}, [checkForMessages, totalCount]);
|
|
1823
|
+
// const onFetchOld = useCallback(() => {
|
|
1824
|
+
// // if (data?.messages?.totalCount > channelMessages.length) {
|
|
1825
|
+
// //if(channelMessages.length !== data?.messages?.totalCount){
|
|
1826
|
+
// if(totalCount > channelMessages.length){
|
|
1827
|
+
// setLoadingOldMessages(true);
|
|
1828
|
+
// refetch({ skip: channelMessages.length });
|
|
1829
|
+
// }
|
|
1830
|
+
// }, [data, channelMessages]);
|
|
1831
|
+
// const onFetchOld = () => {
|
|
1832
|
+
// // if (data?.messages?.totalCount > channelMessages.length) {
|
|
1833
|
+
// //if(channelMessages.length !== data?.messages?.totalCount){
|
|
1834
|
+
// if(totalCount > channelMessages.length){
|
|
1835
|
+
// setLoadingOldMessages(true);
|
|
1836
|
+
// refetch({ skip: channelMessages.length });
|
|
1837
|
+
// }
|
|
1838
|
+
// };
|
|
1839
|
+
const onFetchOld = (0, react_1.useCallback)(() => {
|
|
1840
|
+
var _a;
|
|
1841
|
+
if (((_a = data === null || data === void 0 ? void 0 : data.messages) === null || _a === void 0 ? void 0 : _a.totalCount) > channelMessages.length) {
|
|
1842
|
+
setLoadingOldMessages(true);
|
|
1843
|
+
refetch({ channelId: channelId === null || channelId === void 0 ? void 0 : channelId.toString(), parentId: null, skip: channelMessages.length });
|
|
1844
|
+
}
|
|
1845
|
+
}, [data, channelMessages]);
|
|
1846
|
+
// const onFetchOld = () => {
|
|
1847
|
+
// if(totalCount > channelMessages.length){
|
|
1848
|
+
// console.log('totalCount',totalCount)
|
|
1849
|
+
// console.log('channelMessages.length',channelMessages.length)
|
|
1850
|
+
// setLoadingOldMessages(true);
|
|
1851
|
+
// refetch({
|
|
1852
|
+
// skip: channelMessages.length
|
|
1853
|
+
// });
|
|
1854
|
+
// }
|
|
1855
|
+
// };
|
|
1856
|
+
// const isCloseToTop = ({ layoutMeasurement, contentOffset, contentSize }) => {
|
|
1857
|
+
// return contentOffset.y <= 100; // 100px from top
|
|
1858
|
+
// };
|
|
1859
|
+
const isCloseToTop = ({ layoutMeasurement, contentOffset, contentSize }) => {
|
|
1860
|
+
const paddingToTop = 60;
|
|
1861
|
+
return contentSize.height - layoutMeasurement.height - paddingToTop <= contentOffset.y;
|
|
1862
|
+
};
|
|
1863
|
+
const dataURLtoFile = (dataurl, filename) => {
|
|
1864
|
+
var arr = dataurl.split(','), mime = arr[0].match(/:(.*?);/)[1], bstr = (0, base_64_1.encode)(arr[1]), n = bstr.length, u8arr = new Uint8Array(n);
|
|
1865
|
+
while (n--) {
|
|
1866
|
+
u8arr[n] = bstr.charCodeAt(n);
|
|
1867
|
+
}
|
|
1868
|
+
return new File([u8arr], filename, { type: mime });
|
|
1869
|
+
};
|
|
1870
|
+
const onSelectImages = async () => {
|
|
1871
|
+
setImageLoading(true);
|
|
1872
|
+
let imageSource = await ImagePicker.launchImageLibraryAsync({
|
|
1873
|
+
mediaTypes: ImagePicker.MediaTypeOptions.Images,
|
|
1874
|
+
allowsEditing: true,
|
|
1875
|
+
aspect: [4, 3],
|
|
1876
|
+
quality: 1,
|
|
1877
|
+
base64: true,
|
|
1878
|
+
});
|
|
1879
|
+
if (!imageSource.cancelled) {
|
|
1880
|
+
const image = 'data:image/jpeg;base64,' + (imageSource === null || imageSource === void 0 ? void 0 : imageSource.base64);
|
|
1881
|
+
setImage(image);
|
|
1882
|
+
const file = dataURLtoFile(image, 'inputImage.jpg');
|
|
1883
|
+
setFiles((files) => files.concat(file));
|
|
1884
|
+
setImages((images) => images.concat(imageSource));
|
|
1885
|
+
}
|
|
1886
|
+
if (imageSource.cancelled)
|
|
1887
|
+
setLoading(false);
|
|
1888
|
+
};
|
|
1889
|
+
const sendPushNotification = async (title, body, data, to) => {
|
|
1890
|
+
try {
|
|
1891
|
+
const response = await fetch('https://exp.host/--/api/v2/push/send/', {
|
|
1892
|
+
method: 'POST',
|
|
1893
|
+
headers: {
|
|
1894
|
+
Accept: 'application/json',
|
|
1895
|
+
'Accept-Encoding': 'gzip, deflate',
|
|
1896
|
+
'Content-Type': 'application/json',
|
|
1897
|
+
},
|
|
1898
|
+
body: JSON.stringify({
|
|
1899
|
+
to: to,
|
|
1900
|
+
data: data,
|
|
1901
|
+
title: title,
|
|
1902
|
+
body: body,
|
|
1903
|
+
sound: react_native_1.Platform.OS === 'android' ? false || null : 'default',
|
|
1904
|
+
}),
|
|
1905
|
+
});
|
|
1906
|
+
const result = await response.json();
|
|
1907
|
+
console.log('expo api response', result);
|
|
1908
|
+
}
|
|
1909
|
+
catch (error) {
|
|
1910
|
+
console.error('Error:', error);
|
|
1911
|
+
}
|
|
1912
|
+
// fetch('https://exp.host/--/api/v2/push/send/', {
|
|
1913
|
+
// method: 'POST',
|
|
1914
|
+
// headers: {
|
|
1915
|
+
// Accept: 'application/json',
|
|
1916
|
+
// 'Accept-Encoding': 'gzip, deflate',
|
|
1917
|
+
// 'Content-Type': 'application/json',
|
|
1918
|
+
// },
|
|
1919
|
+
// body: JSON.stringify({
|
|
1920
|
+
// to: to,
|
|
1921
|
+
// data: data,
|
|
1922
|
+
// title: title,
|
|
1923
|
+
// body: body,
|
|
1924
|
+
// sound: Platform.OS === 'android' ? null : 'default',
|
|
1925
|
+
// }),
|
|
1926
|
+
// });
|
|
1927
|
+
};
|
|
1928
|
+
// const handleSend = useCallback(
|
|
1929
|
+
// async (message: string) => {
|
|
1930
|
+
// // if (!(message && channelId)) {
|
|
1931
|
+
// // return;
|
|
1932
|
+
// // }
|
|
1933
|
+
// if (!channelId) return;
|
|
1934
|
+
// if (!message && message != ' ' && images.length == 0) return;
|
|
1935
|
+
// setLoading(true);
|
|
1936
|
+
// const { data } = await sendMsg({
|
|
1937
|
+
// variables: {
|
|
1938
|
+
// channelId,
|
|
1939
|
+
// content: message,
|
|
1940
|
+
// },
|
|
1941
|
+
// update: (cache, { data, errors }) => {
|
|
1942
|
+
// if (!data || errors) {
|
|
1943
|
+
// setLoading(false);
|
|
1944
|
+
// return;
|
|
1945
|
+
// }
|
|
1946
|
+
// setChannelMessages((messages) => [...messages, data?.sendMessage]);
|
|
1947
|
+
// setTotalCount((t) => t + 1);
|
|
1948
|
+
// setChannelToTop(channelToTop + 1);
|
|
1949
|
+
// setLoading(false);
|
|
1950
|
+
// const title: String = currentUser?.givenName+' '+currentUser?.familyName+' in Followup Chat';
|
|
1951
|
+
// const body: String = message;
|
|
1952
|
+
// const notificationData: any = {
|
|
1953
|
+
// url: config.INBOX_MESSEGE_PATH,
|
|
1954
|
+
// params: { channelId, hideTabBar: true },
|
|
1955
|
+
// screen: 'DialogMessages',
|
|
1956
|
+
// };
|
|
1957
|
+
// console.log('expo to',JSON.stringify(expoTokens));
|
|
1958
|
+
// if (expoTokens?.length > 0) {
|
|
1959
|
+
// const to: any = expoTokens?.length > 0 ? expoTokens : [];
|
|
1960
|
+
// sendPushNotification(title, body, notificationData, to);
|
|
1961
|
+
// }
|
|
1962
|
+
// setMsg('');
|
|
1963
|
+
// },
|
|
1964
|
+
// });
|
|
1965
|
+
// if (images && images.length > 0 && data?.sendMessage?.id) {
|
|
1966
|
+
// const { id: postId } = data.sendMessage;
|
|
1967
|
+
// setLoading(true);
|
|
1968
|
+
// const uploadResponse = await startUpload({
|
|
1969
|
+
// file: images,
|
|
1970
|
+
// saveUploadedFile: {
|
|
1971
|
+
// variables: {
|
|
1972
|
+
// postId,
|
|
1973
|
+
// },
|
|
1974
|
+
// },
|
|
1975
|
+
// createUploadLink: {
|
|
1976
|
+
// variables: {
|
|
1977
|
+
// postId,
|
|
1978
|
+
// },
|
|
1979
|
+
// },
|
|
1980
|
+
// });
|
|
1981
|
+
// if (uploadResponse?.error) setLoading(false);
|
|
1982
|
+
// const uploadedFiles = uploadResponse.data as unknown as IFileInfo[];
|
|
1983
|
+
// if (uploadResponse.data) {
|
|
1984
|
+
// setImage('');
|
|
1985
|
+
// setFiles([]);
|
|
1986
|
+
// setImages([]);
|
|
1987
|
+
// setLoading(false);
|
|
1988
|
+
// }
|
|
1989
|
+
// setChannelMessages((messages) =>
|
|
1990
|
+
// messages.map((message) => {
|
|
1991
|
+
// if (message.id === postId) {
|
|
1992
|
+
// return {
|
|
1993
|
+
// ...message,
|
|
1994
|
+
// files: {
|
|
1995
|
+
// totalCount: uploadedFiles.length,
|
|
1996
|
+
// data: uploadedFiles,
|
|
1997
|
+
// },
|
|
1998
|
+
// };
|
|
1999
|
+
// }
|
|
2000
|
+
// return message;
|
|
2001
|
+
// }),
|
|
2002
|
+
// );
|
|
2003
|
+
// }
|
|
2004
|
+
// },
|
|
2005
|
+
// [setChannelMessages, currentUser, channelId, images,expoTokens],
|
|
2006
|
+
// );
|
|
2007
|
+
const handleSend = (0, react_1.useCallback)(async (message) => {
|
|
2008
|
+
var _a;
|
|
2009
|
+
if (!channelId)
|
|
2010
|
+
return;
|
|
2011
|
+
if (!message && message != ' ' && images.length == 0)
|
|
2012
|
+
return;
|
|
2013
|
+
if (images && images.length > 0) {
|
|
2014
|
+
const postId = mongooseObjectId === null || mongooseObjectId === void 0 ? void 0 : mongooseObjectId.getNewMongooseObjectId;
|
|
2015
|
+
setLoading(true);
|
|
2016
|
+
const uploadResponse = await startUpload({
|
|
2017
|
+
file: images,
|
|
2018
|
+
saveUploadedFile: {
|
|
2019
|
+
variables: {
|
|
2020
|
+
postId,
|
|
2021
|
+
},
|
|
2022
|
+
},
|
|
2023
|
+
createUploadLink: {
|
|
2024
|
+
variables: {
|
|
2025
|
+
postId,
|
|
2026
|
+
},
|
|
2027
|
+
},
|
|
2028
|
+
});
|
|
2029
|
+
if (uploadResponse === null || uploadResponse === void 0 ? void 0 : uploadResponse.error)
|
|
2030
|
+
setLoading(false);
|
|
2031
|
+
const uploadedFiles = uploadResponse.data;
|
|
2032
|
+
if (uploadResponse.data) {
|
|
2033
|
+
setImage('');
|
|
2034
|
+
setFiles([]);
|
|
2035
|
+
setImages([]);
|
|
2036
|
+
//setLoading(false);
|
|
2037
|
+
const files = (_a = uploadedFiles === null || uploadedFiles === void 0 ? void 0 : uploadedFiles.map((f) => f.id)) !== null && _a !== void 0 ? _a : null;
|
|
2038
|
+
await sendMsg({
|
|
2039
|
+
variables: {
|
|
2040
|
+
postId,
|
|
2041
|
+
channelId,
|
|
2042
|
+
content: message,
|
|
2043
|
+
files,
|
|
2044
|
+
},
|
|
2045
|
+
update: (cache, { data, errors }) => {
|
|
2046
|
+
if (!data || errors) {
|
|
2047
|
+
setLoading(false);
|
|
2048
|
+
return;
|
|
2049
|
+
}
|
|
2050
|
+
setChannelMessages((messages) => [
|
|
2051
|
+
...messages,
|
|
2052
|
+
Object.assign(Object.assign({}, data === null || data === void 0 ? void 0 : data.sendMessage), { files: {
|
|
2053
|
+
totalCount: uploadedFiles.length,
|
|
2054
|
+
data: uploadedFiles,
|
|
2055
|
+
} }),
|
|
2056
|
+
]);
|
|
2057
|
+
setTotalCount((t) => t + 1);
|
|
2058
|
+
setChannelToTop(channelToTop + 1);
|
|
2059
|
+
setLoading(false);
|
|
2060
|
+
setMsg('');
|
|
2061
|
+
const msg = message == '' ? 'Send a file' : message;
|
|
2062
|
+
fetchTokenAndSendPushNotification(msg, channelId);
|
|
2063
|
+
},
|
|
2064
|
+
});
|
|
2065
|
+
}
|
|
2066
|
+
}
|
|
2067
|
+
else {
|
|
2068
|
+
setLoading(true);
|
|
2069
|
+
const { data } = await sendMsg({
|
|
2070
|
+
variables: {
|
|
2071
|
+
channelId,
|
|
2072
|
+
content: message,
|
|
2073
|
+
},
|
|
2074
|
+
update: (cache, { data, errors }) => {
|
|
2075
|
+
if (!data || errors) {
|
|
2076
|
+
setLoading(false);
|
|
2077
|
+
return;
|
|
2078
|
+
}
|
|
2079
|
+
setChannelMessages((messages) => [...messages, data === null || data === void 0 ? void 0 : data.sendMessage]);
|
|
2080
|
+
setTotalCount((t) => t + 1);
|
|
2081
|
+
setChannelToTop(channelToTop + 1);
|
|
2082
|
+
setLoading(false);
|
|
2083
|
+
setMsg('');
|
|
2084
|
+
fetchTokenAndSendPushNotification(message, channelId);
|
|
2085
|
+
},
|
|
2086
|
+
});
|
|
2087
|
+
}
|
|
2088
|
+
}, [mongooseObjectId, setChannelMessages, channelId, images, channelToTop, expoTokens]);
|
|
2089
|
+
const fetchTokenAndSendPushNotification = (message, channelId) => {
|
|
2090
|
+
var _a, _b, _c, _d, _e;
|
|
2091
|
+
const givenName = (_b = (_a = auth === null || auth === void 0 ? void 0 : auth.profile) === null || _a === void 0 ? void 0 : _a.given_name) !== null && _b !== void 0 ? _b : '';
|
|
2092
|
+
const familyName = (_d = (_c = auth === null || auth === void 0 ? void 0 : auth.profile) === null || _c === void 0 ? void 0 : _c.family_name) !== null && _d !== void 0 ? _d : '';
|
|
2093
|
+
const fullName = givenName ? givenName + ' ' + familyName : '';
|
|
2094
|
+
const title = fullName ? fullName : 'Message';
|
|
2095
|
+
const body = message;
|
|
2096
|
+
const notificationData = {
|
|
2097
|
+
url: config_1.config.INBOX_MESSEGE_PATH,
|
|
2098
|
+
params: { channelId, hideTabBar: true },
|
|
2099
|
+
screen: 'DialogMessages',
|
|
2100
|
+
};
|
|
2101
|
+
(_e = refetchChannelDetail({ id: channelId === null || channelId === void 0 ? void 0 : channelId.toString() })) === null || _e === void 0 ? void 0 : _e.then((res) => {
|
|
2102
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
|
|
2103
|
+
if ((_c = (_b = (_a = res === null || res === void 0 ? void 0 : res.data) === null || _a === void 0 ? void 0 : _a.viewChannelDetail) === null || _b === void 0 ? void 0 : _b.members) === null || _c === void 0 ? void 0 : _c.length) {
|
|
2104
|
+
const channelData = (_g = (_f = (_e = (_d = res === null || res === void 0 ? void 0 : res.data) === null || _d === void 0 ? void 0 : _d.viewChannelDetail) === null || _e === void 0 ? void 0 : _e.members) === null || _f === void 0 ? void 0 : _f.filter((mu) => { var _a; return ((_a = mu === null || mu === void 0 ? void 0 : mu.user) === null || _a === void 0 ? void 0 : _a.id) != (auth === null || auth === void 0 ? void 0 : auth.id); })) !== null && _g !== void 0 ? _g : [];
|
|
2105
|
+
const tokens = (_l = (_k = (_j = (_h = channelData === null || channelData === void 0 ? void 0 : channelData.map((u) => {
|
|
2106
|
+
var _a, _b, _c, _d;
|
|
2107
|
+
return (_d = (_c = (_b = (_a = u === null || u === void 0 ? void 0 : u.user) === null || _a === void 0 ? void 0 : _a.tokens) === null || _b === void 0 ? void 0 : _b.filter((t) => (t === null || t === void 0 ? void 0 : t.type) == 'EXPO_NOTIFICATION_TOKEN')) === null || _c === void 0 ? void 0 : _c.map((et) => et === null || et === void 0 ? void 0 : et.token)) !== null && _d !== void 0 ? _d : [];
|
|
2108
|
+
})) === null || _h === void 0 ? void 0 : _h.flat(1)) === null || _j === void 0 ? void 0 : _j.filter((t) => t)) === null || _k === void 0 ? void 0 : _k.filter((value, index, array) => array.indexOf(value) === index)) !== null && _l !== void 0 ? _l : [];
|
|
2109
|
+
console.log('expo to', JSON.stringify(tokens));
|
|
2110
|
+
if ((tokens === null || tokens === void 0 ? void 0 : tokens.length) > 0) {
|
|
2111
|
+
const to = (tokens === null || tokens === void 0 ? void 0 : tokens.length) > 0 ? tokens : [];
|
|
2112
|
+
sendPushNotification(title, body, notificationData, to);
|
|
2113
|
+
}
|
|
2114
|
+
}
|
|
2115
|
+
});
|
|
2116
|
+
};
|
|
2117
|
+
// const handleSend1 = async (message: string) => {
|
|
2118
|
+
// if (!channelId) return;
|
|
2119
|
+
// if (!message && message != ' ' && images.length == 0) return;
|
|
2120
|
+
// setLoading(true);
|
|
2121
|
+
// const { data } = await sendMsg({
|
|
2122
|
+
// variables: {
|
|
2123
|
+
// channelId,
|
|
2124
|
+
// content: message,
|
|
2125
|
+
// },
|
|
2126
|
+
// update: (cache, { data, errors }: any) => {
|
|
2127
|
+
// if (!data || errors) {
|
|
2128
|
+
// setLoading(false);
|
|
2129
|
+
// return;
|
|
2130
|
+
// }
|
|
2131
|
+
// setChannelMessages((messages: any) => [...messages, data?.sendMessage]);
|
|
2132
|
+
// setTotalCount((t: any) => t + 1);
|
|
2133
|
+
// setChannelToTop(channelToTop + 1);
|
|
2134
|
+
// setLoading(false);
|
|
2135
|
+
// setMsg('');
|
|
2136
|
+
// const givenName = auth?.profile?.given_name ?? '';
|
|
2137
|
+
// const familyName = auth?.profile?.family_name ?? '';
|
|
2138
|
+
// const fullName = givenName ? givenName + ' ' + familyName : '';
|
|
2139
|
+
// const title: String = fullName ? fullName : 'Message';
|
|
2140
|
+
// const body: String = message;
|
|
2141
|
+
// const notificationData: any = {
|
|
2142
|
+
// url: config.INBOX_MESSEGE_PATH,
|
|
2143
|
+
// params: { channelId, hideTabBar: true },
|
|
2144
|
+
// screen: 'DialogMessages',
|
|
2145
|
+
// };
|
|
2146
|
+
// refetchChannelDetail({ id: channelId?.toString() })?.then((res: any) => {
|
|
2147
|
+
// if (res?.data?.viewChannelDetail?.members?.length) {
|
|
2148
|
+
// const channelData: any =
|
|
2149
|
+
// res?.data?.viewChannelDetail?.members?.filter((mu: any) => mu?.user?.id != auth?.id) ?? [];
|
|
2150
|
+
// const tokens: any =
|
|
2151
|
+
// channelData
|
|
2152
|
+
// ?.map(
|
|
2153
|
+
// (u: any) =>
|
|
2154
|
+
// u?.user?.tokens
|
|
2155
|
+
// ?.filter((t: any) => t?.type == 'EXPO_NOTIFICATION_TOKEN')
|
|
2156
|
+
// ?.map((et: any) => et?.token) ?? [],
|
|
2157
|
+
// )
|
|
2158
|
+
// ?.flat(1)
|
|
2159
|
+
// ?.filter((t: any) => t)
|
|
2160
|
+
// ?.filter((value: any, index: any, array: any) => array.indexOf(value) === index) ?? [];
|
|
2161
|
+
// console.log('expo to', JSON.stringify(tokens));
|
|
2162
|
+
// if (tokens?.length > 0) {
|
|
2163
|
+
// const to: any = tokens?.length > 0 ? tokens : [];
|
|
2164
|
+
// sendPushNotification(title, body, notificationData, to);
|
|
2165
|
+
// }
|
|
2166
|
+
// }
|
|
2167
|
+
// });
|
|
2168
|
+
// },
|
|
2169
|
+
// });
|
|
2170
|
+
// if (images && images.length > 0 && data?.sendMessage?.id) {
|
|
2171
|
+
// const { id: postId } = data.sendMessage;
|
|
2172
|
+
// setLoading(true);
|
|
2173
|
+
// const uploadResponse = await startUpload({
|
|
2174
|
+
// file: images,
|
|
2175
|
+
// saveUploadedFile: {
|
|
2176
|
+
// variables: {
|
|
2177
|
+
// postId,
|
|
2178
|
+
// },
|
|
2179
|
+
// },
|
|
2180
|
+
// createUploadLink: {
|
|
2181
|
+
// variables: {
|
|
2182
|
+
// postId,
|
|
2183
|
+
// },
|
|
2184
|
+
// },
|
|
2185
|
+
// });
|
|
2186
|
+
// if (uploadResponse?.error) setLoading(false);
|
|
2187
|
+
// const uploadedFiles = uploadResponse.data as unknown as IFileInfo[];
|
|
2188
|
+
// if (uploadResponse.data) {
|
|
2189
|
+
// setImage('');
|
|
2190
|
+
// setFiles([]);
|
|
2191
|
+
// setImages([]);
|
|
2192
|
+
// setLoading(false);
|
|
2193
|
+
// }
|
|
2194
|
+
// setChannelMessages((messages: any) =>
|
|
2195
|
+
// messages.map((message: any) => {
|
|
2196
|
+
// if (message.id === postId) {
|
|
2197
|
+
// return {
|
|
2198
|
+
// ...message,
|
|
2199
|
+
// files: {
|
|
2200
|
+
// totalCount: uploadedFiles.length,
|
|
2201
|
+
// data: uploadedFiles,
|
|
2202
|
+
// },
|
|
2203
|
+
// };
|
|
2204
|
+
// }
|
|
2205
|
+
// return message;
|
|
2206
|
+
// }),
|
|
2207
|
+
// );
|
|
2208
|
+
// }
|
|
2209
|
+
// };
|
|
2210
|
+
const messageList = (0, react_1.useMemo)(() => {
|
|
2211
|
+
let currentDate = '';
|
|
2212
|
+
let res = [];
|
|
2213
|
+
if (channelMessages.length) {
|
|
2214
|
+
(0, lodash_1.orderBy)(channelMessages, ['createdAt'], ['desc']).map((msg) => {
|
|
2215
|
+
var _a, _b, _c, _d;
|
|
2216
|
+
let message = {
|
|
2217
|
+
_id: '',
|
|
2218
|
+
text: '',
|
|
2219
|
+
createdAt: 0,
|
|
2220
|
+
user: {
|
|
2221
|
+
_id: '',
|
|
2222
|
+
name: '',
|
|
2223
|
+
avatar: '',
|
|
2224
|
+
},
|
|
2225
|
+
type: '',
|
|
2226
|
+
};
|
|
2227
|
+
const date = new Date(msg.createdAt);
|
|
2228
|
+
message._id = msg.id;
|
|
2229
|
+
message.text = msg.message;
|
|
2230
|
+
message.createdAt = date;
|
|
2231
|
+
(message.user = {
|
|
2232
|
+
_id: msg.author.id,
|
|
2233
|
+
name: msg.author.givenName + ' ' + msg.author.familyName,
|
|
2234
|
+
avatar: (_a = msg.author) === null || _a === void 0 ? void 0 : _a.picture,
|
|
2235
|
+
}),
|
|
2236
|
+
(message.image = (_c = (_b = msg.files) === null || _b === void 0 ? void 0 : _b.data[0]) === null || _c === void 0 ? void 0 : _c.url),
|
|
2237
|
+
(message.sent = msg === null || msg === void 0 ? void 0 : msg.isDelivered),
|
|
2238
|
+
(message.received = msg === null || msg === void 0 ? void 0 : msg.isRead);
|
|
2239
|
+
message.type = msg === null || msg === void 0 ? void 0 : msg.type;
|
|
2240
|
+
message.propsConfiguration = msg === null || msg === void 0 ? void 0 : msg.propsConfiguration;
|
|
2241
|
+
message.replies = (_d = msg === null || msg === void 0 ? void 0 : msg.replies) !== null && _d !== void 0 ? _d : [];
|
|
2242
|
+
res.push(message);
|
|
2243
|
+
});
|
|
2244
|
+
}
|
|
2245
|
+
return res;
|
|
2246
|
+
}, [channelMessages]);
|
|
2247
|
+
const renderSend = (props) => {
|
|
2248
|
+
return (react_1.default.createElement(react_native_gifted_chat_1.Send, Object.assign({}, props),
|
|
2249
|
+
react_1.default.createElement(native_base_1.Box, null,
|
|
2250
|
+
react_1.default.createElement(vector_icons_1.MaterialCommunityIcons, { name: "send-circle", style: { marginBottom: 5, marginRight: 5 }, size: 32, color: "#2e64e5" }))));
|
|
2251
|
+
};
|
|
2252
|
+
const renderMessageText = (props) => {
|
|
2253
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t;
|
|
2254
|
+
const { currentMessage } = props;
|
|
2255
|
+
const lastReply = ((_b = (_a = currentMessage === null || currentMessage === void 0 ? void 0 : currentMessage.replies) === null || _a === void 0 ? void 0 : _a.data) === null || _b === void 0 ? void 0 : _b.length) > 0 ? (_d = (_c = currentMessage === null || currentMessage === void 0 ? void 0 : currentMessage.replies) === null || _c === void 0 ? void 0 : _c.data) === null || _d === void 0 ? void 0 : _d[0] : null;
|
|
2256
|
+
if (currentMessage.type === 'ALERT') {
|
|
2257
|
+
const attachment = (_f = (_e = currentMessage === null || currentMessage === void 0 ? void 0 : currentMessage.propsConfiguration) === null || _e === void 0 ? void 0 : _e.contents) === null || _f === void 0 ? void 0 : _f.attachment;
|
|
2258
|
+
let action = '';
|
|
2259
|
+
let actionId = '';
|
|
2260
|
+
if ((_h = (_g = attachment === null || attachment === void 0 ? void 0 : attachment.callToAction) === null || _g === void 0 ? void 0 : _g.link) === null || _h === void 0 ? void 0 : _h.includes('my-reservation-details')) {
|
|
2261
|
+
action = CALL_TO_ACTION_PATH;
|
|
2262
|
+
actionId = (_j = attachment === null || attachment === void 0 ? void 0 : attachment.callToAction) === null || _j === void 0 ? void 0 : _j.link.split('/').pop();
|
|
2263
|
+
}
|
|
2264
|
+
// if (attachment?.callToAction?.link?.includes('my-reservation-details')) {
|
|
2265
|
+
// action = 'm-reservation-detail';
|
|
2266
|
+
// actionId = attachment?.callToAction?.link.split('/').pop();
|
|
2267
|
+
// }
|
|
2268
|
+
return (react_1.default.createElement(native_base_1.Box, { bg: CALL_TO_ACTION_BOX_BGCOLOR, borderRadius: 15, pb: 2 },
|
|
2269
|
+
(attachment === null || attachment === void 0 ? void 0 : attachment.callToAction) ? (react_1.default.createElement(native_base_1.Button, { variant: 'outline', size: 'sm', borderColor: CALL_TO_ACTION_BUTTON_BORDERCOLOR, onPress: () => navigation.navigate(action, { reservationId: actionId }) },
|
|
2270
|
+
react_1.default.createElement(native_base_1.Text, { color: CALL_TO_ACTION_TEXT_COLOR }, attachment.callToAction.title))) : null,
|
|
2271
|
+
react_1.default.createElement(react_native_gifted_chat_1.MessageText, Object.assign({}, props, { textStyle: { left: { marginLeft: 5, color: CALL_TO_ACTION_TEXT_COLOR, paddingHorizontal: 2 } } }))));
|
|
2272
|
+
}
|
|
2273
|
+
else {
|
|
2274
|
+
return (react_1.default.createElement(react_native_1.TouchableOpacity, { onPress: () => navigation.navigate(config_1.config.THREAD_MESSEGE_PATH, {
|
|
2275
|
+
channelId: channelId,
|
|
2276
|
+
title: 'Message',
|
|
2277
|
+
postParentId: currentMessage === null || currentMessage === void 0 ? void 0 : currentMessage._id,
|
|
2278
|
+
isPostParentIdThread: true,
|
|
2279
|
+
}) },
|
|
2280
|
+
react_1.default.createElement(react_native_gifted_chat_1.MessageText, Object.assign({}, props, { textStyle: { left: { marginLeft: 5 } } })),
|
|
2281
|
+
((_l = (_k = currentMessage === null || currentMessage === void 0 ? void 0 : currentMessage.replies) === null || _k === void 0 ? void 0 : _k.data) === null || _l === void 0 ? void 0 : _l.length) > 0 && (react_1.default.createElement(native_base_1.HStack, { space: 1, px: 1, alignItems: 'center' },
|
|
2282
|
+
react_1.default.createElement(native_base_1.HStack, null, (_r = (_q = (_p = (_o = (_m = currentMessage === null || currentMessage === void 0 ? void 0 : currentMessage.replies) === null || _m === void 0 ? void 0 : _m.data) === null || _o === void 0 ? void 0 : _o.filter((v, i, a) => a.findIndex((t) => { var _a, _b; return ((_a = t === null || t === void 0 ? void 0 : t.author) === null || _a === void 0 ? void 0 : _a.id) === ((_b = v === null || v === void 0 ? void 0 : v.author) === null || _b === void 0 ? void 0 : _b.id); }) === i)) === null || _p === void 0 ? void 0 : _p.slice(0, 2)) === null || _q === void 0 ? void 0 : _q.reverse()) === null || _r === void 0 ? void 0 : _r.map((p, i) => {
|
|
2283
|
+
var _a, _b, _c;
|
|
2284
|
+
return (react_1.default.createElement(native_base_1.Avatar, { key: 'key' + i, bg: 'transparent', size: 6,
|
|
2285
|
+
// top={i == 1 ? 4 : 0}
|
|
2286
|
+
// right={i == 1 ? -2 : 0}
|
|
2287
|
+
// zIndex={i == 1 ? 5 : 1}
|
|
2288
|
+
_image: { borderRadius: 6, borderWidth: 2, borderColor: '#fff' }, source: {
|
|
2289
|
+
uri: (_a = p === null || p === void 0 ? void 0 : p.author) === null || _a === void 0 ? void 0 : _a.picture,
|
|
2290
|
+
} }, (0, lodash_1.startCase)((_c = (_b = p === null || p === void 0 ? void 0 : p.author) === null || _b === void 0 ? void 0 : _b.username) === null || _c === void 0 ? void 0 : _c.charAt(0))));
|
|
2291
|
+
})),
|
|
2292
|
+
react_1.default.createElement(native_base_1.Text, { fontSize: 12, fontWeight: 'bold', color: 'blue.800' }, (_s = currentMessage === null || currentMessage === void 0 ? void 0 : currentMessage.replies) === null || _s === void 0 ? void 0 :
|
|
2293
|
+
_s.totalCount,
|
|
2294
|
+
' ',
|
|
2295
|
+
((_t = currentMessage === null || currentMessage === void 0 ? void 0 : currentMessage.replies) === null || _t === void 0 ? void 0 : _t.totalCount) == 1 ? 'reply' : 'replies'),
|
|
2296
|
+
react_1.default.createElement(native_base_1.Text, { fontSize: 12, fontWeight: 'bold', color: 'gray.500' }, lastReply ? createdAtText(lastReply === null || lastReply === void 0 ? void 0 : lastReply.createdAt) : '')))));
|
|
2297
|
+
}
|
|
2298
|
+
};
|
|
2299
|
+
const renderActions = (props) => {
|
|
2300
|
+
return (react_1.default.createElement(react_native_gifted_chat_1.Actions, Object.assign({}, props, { icon: () => react_1.default.createElement(native_base_1.Icon, { as: vector_icons_1.Ionicons, name: 'image', size: 'lg', color: 'black', onPress: onSelectImages }) })));
|
|
2301
|
+
};
|
|
2302
|
+
const renderAccessory = (props) => {
|
|
2303
|
+
return (react_1.default.createElement(native_base_1.Box, null, selectedImage !== '' ? (react_1.default.createElement(native_base_1.HStack, { alignItems: 'center' },
|
|
2304
|
+
react_1.default.createElement(native_base_1.Image, { ml: 3, key: selectedImage, alt: 'image', source: { uri: selectedImage }, size: 'xs' }),
|
|
2305
|
+
react_1.default.createElement(native_base_1.Button, { variant: 'ghost', colorScheme: 'secondary', onPress: () => {
|
|
2306
|
+
setFiles([]);
|
|
2307
|
+
setImage('');
|
|
2308
|
+
setImages([]);
|
|
2309
|
+
} }, "Cancel"))) : null));
|
|
2310
|
+
};
|
|
2311
|
+
const setImageViewerObject = (obj, v) => {
|
|
2312
|
+
setImageObject(obj);
|
|
2313
|
+
setImageViewer(v);
|
|
2314
|
+
};
|
|
2315
|
+
const modalContent = react_1.default.useMemo(() => {
|
|
2316
|
+
if (!imageObject)
|
|
2317
|
+
return react_1.default.createElement(react_1.default.Fragment, null);
|
|
2318
|
+
const { image, _id } = imageObject;
|
|
2319
|
+
return (react_1.default.createElement(CachedImage_1.default, { style: { width: '100%', height: '100%' }, resizeMode: 'cover',
|
|
2320
|
+
// cacheKey={`${_id}-conversation-modal-image-key`}
|
|
2321
|
+
cacheKey: `${_id}-slack-bubble-imageKey`, source: {
|
|
2322
|
+
uri: image,
|
|
2323
|
+
//headers: `Authorization: Bearer ${token}`,
|
|
2324
|
+
expiresIn: 86400,
|
|
2325
|
+
}, alt: 'image' }));
|
|
2326
|
+
}, [imageObject]);
|
|
2327
|
+
const renderMessage = (props) => {
|
|
2328
|
+
// const {
|
|
2329
|
+
// currentMessage: { text: currText },
|
|
2330
|
+
// } = props;
|
|
2331
|
+
//let messageTextStyle: any;
|
|
2332
|
+
// Make "pure emoji" messages much bigger than plain text.
|
|
2333
|
+
// if (currText && emojiUtils.isPureEmojiString(currText)) {
|
|
2334
|
+
// messageTextStyle = {
|
|
2335
|
+
// fontSize: 28,
|
|
2336
|
+
// // Emoji get clipped if lineHeight isn't increased; make it consistent across platforms.
|
|
2337
|
+
// lineHeight: Platform.OS === 'android' ? 34 : 30,
|
|
2338
|
+
// }
|
|
2339
|
+
// }
|
|
2340
|
+
// return <SlackMessage {...props} messageTextStyle={messageTextStyle} />;
|
|
2341
|
+
return react_1.default.createElement(SlackMessageContainer_1.SlackMessage, Object.assign({}, props, { isShowImageViewer: isShowImageViewer, setImageViewer: setImageViewerObject }));
|
|
2342
|
+
};
|
|
2343
|
+
let onScroll = false;
|
|
2344
|
+
const onEndReached = () => {
|
|
2345
|
+
console.log('on end reached');
|
|
2346
|
+
if (!onScroll)
|
|
2347
|
+
return;
|
|
2348
|
+
// load messages, show ActivityIndicator
|
|
2349
|
+
onScroll = false;
|
|
2350
|
+
// setLoadingOldMessages(true);
|
|
2351
|
+
};
|
|
2352
|
+
// const onMomentumScrollBegin = useCallback(
|
|
2353
|
+
// ({ nativeEvent }: any) => {
|
|
2354
|
+
// onScroll = true;
|
|
2355
|
+
// console.log('scroll top');
|
|
2356
|
+
// if (!loadingOldMessages && channelMessages?.length <= 10 && channelMessages?.length != totalCount) {
|
|
2357
|
+
// onFetchOld();
|
|
2358
|
+
// } else if (!loadingOldMessages && isCloseToTop(nativeEvent) && channelMessages?.length != totalCount) {
|
|
2359
|
+
// onFetchOld();
|
|
2360
|
+
// }
|
|
2361
|
+
// },
|
|
2362
|
+
// [loadingOldMessages, channelMessages],
|
|
2363
|
+
// );
|
|
2364
|
+
const onMomentumScrollBegin = ({ nativeEvent }) => {
|
|
2365
|
+
onScroll = true;
|
|
2366
|
+
console.log('scroll top');
|
|
2367
|
+
if (!loadingOldMessages &&
|
|
2368
|
+
((channelMessages === null || channelMessages === void 0 ? void 0 : channelMessages.length) <= 10 || isCloseToTop(nativeEvent)) &&
|
|
2369
|
+
(channelMessages === null || channelMessages === void 0 ? void 0 : channelMessages.length) != totalCount) {
|
|
2370
|
+
onFetchOld();
|
|
2371
|
+
}
|
|
2372
|
+
};
|
|
2373
|
+
return (react_1.default.createElement(react_1.default.Fragment, null,
|
|
2374
|
+
loadingOldMessages && react_1.default.createElement(native_base_1.Spinner, null),
|
|
2375
|
+
react_1.default.createElement(react_native_gifted_chat_1.GiftedChat, { wrapInSafeArea: false, renderLoading: () => react_1.default.createElement(native_base_1.Spinner, null), messages: messageList,
|
|
2376
|
+
// listViewProps={{
|
|
2377
|
+
// onEndReached: onEndReached,
|
|
2378
|
+
// onEndReachedThreshold: 0.5,
|
|
2379
|
+
// onMomentumScrollBegin: onMomentumScrollBegin,
|
|
2380
|
+
// }}////
|
|
2381
|
+
// listViewProps={{
|
|
2382
|
+
// scrollEventThrottle: 400,
|
|
2383
|
+
// onScroll: ({ nativeEvent }) => { console.log('scroll')
|
|
2384
|
+
// if (!loadingOldMessages && isCloseToTop(nativeEvent)) {
|
|
2385
|
+
// onFetchOld();
|
|
2386
|
+
// }
|
|
2387
|
+
// }
|
|
2388
|
+
// }}
|
|
2389
|
+
onSend: (messages) => { var _a, _b; return handleSend((_b = (_a = messages[0]) === null || _a === void 0 ? void 0 : _a.text) !== null && _b !== void 0 ? _b : ' '); }, text: msg ? msg : ' ', onInputTextChanged: (text) => setMsg(text), renderFooter: () => (loading ? react_1.default.createElement(native_base_1.Spinner, null) : imageLoading ? react_1.default.createElement(native_base_1.Spinner, null) : ''), scrollToBottom: true, user: {
|
|
2390
|
+
// _id: currentUser?.id || '',
|
|
2391
|
+
_id: (auth === null || auth === void 0 ? void 0 : auth.id) || '',
|
|
2392
|
+
}, isTyping: true, alwaysShowSend: loading ? false : true, onLoadEarlier: onFetchOld, infiniteScroll: true, renderSend: renderSend, loadEarlier: ((_a = data === null || data === void 0 ? void 0 : data.messages) === null || _a === void 0 ? void 0 : _a.totalCount) > channelMessages.length,
|
|
2393
|
+
//isLoadingEarlier={isLoadingEarlier}
|
|
2394
|
+
//extraData={{ isLoadingEarlier: loadingOldMessages }}
|
|
2395
|
+
//renderLoadEarlier={() => <Spinner />}}
|
|
2396
|
+
renderMessageText: renderMessageText, minInputToolbarHeight: 50, renderActions: renderActions, renderAccessory: renderAccessory, renderMessage: renderMessage, renderChatFooter: () => (react_1.default.createElement(SlackMessageContainer_1.ImageViewerModal, { isVisible: isShowImageViewer, setVisible: setImageViewer, modalContent: modalContent })), lightboxProps: {
|
|
2397
|
+
underlayColor: 'transparent',
|
|
2398
|
+
springConfig: { tension: 90000, friction: 90000 },
|
|
2399
|
+
disabled: true,
|
|
2400
|
+
} })));
|
|
2401
|
+
};
|
|
2402
|
+
exports.ConversationView = react_1.default.memo(ConversationViewComponent);
|
|
2403
|
+
|
|
2404
|
+
|
|
2405
|
+
/***/ }),
|
|
2406
|
+
|
|
2407
|
+
/***/ "./src/screens/inbox/containers/Dialogs.tsx":
|
|
2408
|
+
/*!**************************************************!*\
|
|
2409
|
+
!*** ./src/screens/inbox/containers/Dialogs.tsx ***!
|
|
2410
|
+
\**************************************************/
|
|
2411
|
+
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {
|
|
2412
|
+
|
|
2413
|
+
|
|
2414
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
2415
|
+
if (k2 === undefined) k2 = k;
|
|
2416
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
2417
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
2418
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
2419
|
+
}
|
|
2420
|
+
Object.defineProperty(o, k2, desc);
|
|
2421
|
+
}) : (function(o, m, k, k2) {
|
|
2422
|
+
if (k2 === undefined) k2 = k;
|
|
2423
|
+
o[k2] = m[k];
|
|
2424
|
+
}));
|
|
2425
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
2426
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
2427
|
+
}) : function(o, v) {
|
|
2428
|
+
o["default"] = v;
|
|
2429
|
+
});
|
|
2430
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
2431
|
+
if (mod && mod.__esModule) return mod;
|
|
2432
|
+
var result = {};
|
|
2433
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
2434
|
+
__setModuleDefault(result, mod);
|
|
2435
|
+
return result;
|
|
2436
|
+
};
|
|
2437
|
+
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
2438
|
+
exports.Dialogs = void 0;
|
|
2439
|
+
const react_1 = __importStar(__webpack_require__(/*! react */ "react"));
|
|
2440
|
+
const native_base_1 = __webpack_require__(/*! native-base */ "native-base");
|
|
2441
|
+
const vector_icons_1 = __webpack_require__(/*! @expo/vector-icons */ "@expo/vector-icons");
|
|
2442
|
+
const react_redux_1 = __webpack_require__(/*! react-redux */ "react-redux");
|
|
2443
|
+
const native_1 = __webpack_require__(/*! @react-navigation/native */ "@react-navigation/native");
|
|
2444
|
+
const DialogsListItem_1 = __webpack_require__(/*! ../components/DialogsListItem */ "./src/screens/inbox/components/DialogsListItem.tsx");
|
|
2445
|
+
const platform_client_1 = __webpack_require__(/*! @messenger-box/platform-client */ "@messenger-box/platform-client");
|
|
2446
|
+
const user_auth0_client_1 = __webpack_require__(/*! @adminide-stack/user-auth0-client */ "@adminide-stack/user-auth0-client");
|
|
2447
|
+
const config_1 = __webpack_require__(/*! ../config */ "./src/screens/inbox/config/index.ts");
|
|
2448
|
+
const DialogsComponent = (props) => {
|
|
2449
|
+
const { channelFilters, channelRole } = props;
|
|
2450
|
+
const { params } = (0, native_1.useRoute)();
|
|
2451
|
+
const auth = (0, react_redux_1.useSelector)(user_auth0_client_1.userSelector);
|
|
2452
|
+
const dispatch = (0, react_redux_1.useDispatch)();
|
|
2453
|
+
const navigation = (0, native_1.useNavigation)();
|
|
2454
|
+
const isFocused = (0, native_1.useIsFocused)();
|
|
2455
|
+
const [refreshing, setRefresh] = (0, react_1.useState)(false);
|
|
2456
|
+
// const [userDirectChannel, setUserDirectChannel] = useState<any>([]);
|
|
2457
|
+
const { data: userChannels, loading: userChannelsLoading, refetch: getChannelsRefetch, } = (0, platform_client_1.useGetChannelsByUserQuery)({
|
|
2458
|
+
variables: {
|
|
2459
|
+
role: channelRole,
|
|
2460
|
+
criteria: channelFilters,
|
|
2461
|
+
},
|
|
2462
|
+
onCompleted: (data) => {
|
|
2463
|
+
setRefresh(false);
|
|
2464
|
+
}
|
|
2465
|
+
});
|
|
2466
|
+
(0, native_1.useFocusEffect)(react_1.default.useCallback(() => {
|
|
2467
|
+
// Do something when the screen is focused
|
|
2468
|
+
setRefresh(false);
|
|
2469
|
+
getChannelsRefetch({ role: channelRole, criteria: channelFilters });
|
|
2470
|
+
return () => {
|
|
2471
|
+
// Do something when the screen is unfocused
|
|
2472
|
+
// Useful for cleanup functions
|
|
2473
|
+
};
|
|
2474
|
+
}, [channelFilters]));
|
|
2475
|
+
const channels = react_1.default.useMemo(() => {
|
|
2476
|
+
var _a, _b, _c;
|
|
2477
|
+
if (!((_a = userChannels === null || userChannels === void 0 ? void 0 : userChannels.channelsByUser) === null || _a === void 0 ? void 0 : _a.length))
|
|
2478
|
+
return null;
|
|
2479
|
+
let uChannels = (_c = (_b = userChannels === null || userChannels === void 0 ? void 0 : userChannels.channelsByUser) === null || _b === void 0 ? void 0 : _b.filter((c) => c.members.some((u) => { var _a; return ((_a = u === null || u === void 0 ? void 0 : u.user) === null || _a === void 0 ? void 0 : _a.id) != (auth === null || auth === void 0 ? void 0 : auth.id) && u.user.__typename == 'UserAccount'; }))) !== null && _c !== void 0 ? _c : [];
|
|
2480
|
+
return uChannels || [];
|
|
2481
|
+
}, [userChannels]);
|
|
2482
|
+
// useEffect(() => {
|
|
2483
|
+
// setTimeout(() => {
|
|
2484
|
+
// dispatch({
|
|
2485
|
+
// type: CHANGE_SETTINGS_ACTION,
|
|
2486
|
+
// payload: {
|
|
2487
|
+
// footerRender: false,
|
|
2488
|
+
// },
|
|
2489
|
+
// } as any);
|
|
2490
|
+
// }, 0);
|
|
2491
|
+
// return () => {
|
|
2492
|
+
// dispatch({
|
|
2493
|
+
// type: CHANGE_SETTINGS_ACTION,
|
|
2494
|
+
// payload: {
|
|
2495
|
+
// footerRender: true,
|
|
2496
|
+
// },
|
|
2497
|
+
// } as any);
|
|
2498
|
+
// };
|
|
2499
|
+
// }, []);
|
|
1151
2500
|
// useEffect(() => {
|
|
1152
|
-
// if (
|
|
1153
|
-
//
|
|
1154
|
-
//
|
|
1155
|
-
// messages &&
|
|
1156
|
-
// messages.length > 0 &&
|
|
1157
|
-
// totalCount !== messeageTotalCount &&
|
|
1158
|
-
// (loadingOldMessages || channelMessages.length === 0)
|
|
1159
|
-
// ) {
|
|
1160
|
-
// setChannelMessages((oldMessages: any) => uniqBy([...messages, ...oldMessages], ({ id }) => id));
|
|
1161
|
-
// setLoadingOldMessages(false);
|
|
1162
|
-
// setTotalCount(messeageTotalCount);
|
|
2501
|
+
// if (userChannels?.channelsByUser) {
|
|
2502
|
+
// if (userChannels?.channelsByUser?.length == 0) {
|
|
2503
|
+
// setUserDirectChannel([]);
|
|
1163
2504
|
// }
|
|
1164
|
-
// //
|
|
2505
|
+
// //Direct channel
|
|
2506
|
+
// let userDirectChannels: any =
|
|
2507
|
+
// userChannels?.channelsByUser
|
|
2508
|
+
// ?.filter((i: any) => i.type == 'DIRECT')
|
|
2509
|
+
// ?.filter((c: any) =>
|
|
2510
|
+
// c.members.some((u: any) => u?.user?.id != auth?.id && u.user.__typename == 'UserAccount'),
|
|
2511
|
+
// ) ?? [];
|
|
2512
|
+
// if (userDirectChannels?.length > 0) setUserDirectChannel(userDirectChannels);
|
|
1165
2513
|
// }
|
|
1166
|
-
// }, [
|
|
2514
|
+
// }, [userChannels?.channelsByUser]);
|
|
2515
|
+
const handleSelectChannel = (0, react_1.useCallback)((id, title) => {
|
|
2516
|
+
var _a;
|
|
2517
|
+
if (params === null || params === void 0 ? void 0 : params.channelId) {
|
|
2518
|
+
navigation.navigate(config_1.config.INBOX_MESSEGE_PATH, {
|
|
2519
|
+
channelId: params === null || params === void 0 ? void 0 : params.channelId,
|
|
2520
|
+
title: (_a = params === null || params === void 0 ? void 0 : params.title) !== null && _a !== void 0 ? _a : null,
|
|
2521
|
+
hideTabBar: true,
|
|
2522
|
+
});
|
|
2523
|
+
}
|
|
2524
|
+
else {
|
|
2525
|
+
navigation.navigate(config_1.config.INBOX_MESSEGE_PATH, {
|
|
2526
|
+
channelId: id,
|
|
2527
|
+
title: title,
|
|
2528
|
+
hideTabBar: true,
|
|
2529
|
+
});
|
|
2530
|
+
}
|
|
2531
|
+
}, []);
|
|
2532
|
+
const handleRefresh = (0, react_1.useCallback)(() => {
|
|
2533
|
+
//if(userChannels?.channelsByUser?.length != channels?.length)setRefresh(true);
|
|
2534
|
+
getChannelsRefetch({ role: channelRole, criteria: channelFilters });
|
|
2535
|
+
}, []);
|
|
2536
|
+
return (react_1.default.createElement(native_base_1.Box, { p: 2, pt: (props === null || props === void 0 ? void 0 : props.supportServices) ? 0 : 2 },
|
|
2537
|
+
react_1.default.createElement(native_base_1.FlatList, { data: channels && (channels === null || channels === void 0 ? void 0 : channels.length) > 0 ? channels : [], onRefresh: handleRefresh, refreshing: userChannelsLoading, contentContainerStyle: { minHeight: '100%' }, ItemSeparatorComponent: () => react_1.default.createElement(native_base_1.Box, { height: "0.5", backgroundColor: "gray.200" }), renderItem: ({ item: channel }) => (react_1.default.createElement(DialogsListItem_1.DialogsListItem, { onOpen: handleSelectChannel, currentUser: auth, channel: channel, selectedChannelId: params === null || params === void 0 ? void 0 : params.channelId })), ListEmptyComponent: () => (react_1.default.createElement(react_1.default.Fragment, null, userChannelsLoading ? (react_1.default.createElement(native_base_1.Spinner, null)) : (react_1.default.createElement(native_base_1.Box, { p: 5 },
|
|
2538
|
+
react_1.default.createElement(native_base_1.Heading, null, "Chat"),
|
|
2539
|
+
react_1.default.createElement(native_base_1.Input, { height: 50, mt: 3, placeholder: "Search", borderRadius: 50, borderColor: 'gray.200', borderWidth: 2 }),
|
|
2540
|
+
react_1.default.createElement(native_base_1.Center, { mt: 6 },
|
|
2541
|
+
react_1.default.createElement(native_base_1.Icon, { as: vector_icons_1.Ionicons, name: "chatbubbles", size: 'xl' }),
|
|
2542
|
+
react_1.default.createElement(native_base_1.Text, null, "You don't have any messages yet!")))))), keyExtractor: (item, index) => 'key' + index })));
|
|
2543
|
+
};
|
|
2544
|
+
exports.Dialogs = react_1.default.memo(DialogsComponent);
|
|
2545
|
+
|
|
2546
|
+
|
|
2547
|
+
/***/ }),
|
|
2548
|
+
|
|
2549
|
+
/***/ "./src/screens/inbox/containers/SupportServiceDialogs.tsx":
|
|
2550
|
+
/*!****************************************************************!*\
|
|
2551
|
+
!*** ./src/screens/inbox/containers/SupportServiceDialogs.tsx ***!
|
|
2552
|
+
\****************************************************************/
|
|
2553
|
+
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {
|
|
2554
|
+
|
|
2555
|
+
|
|
2556
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
2557
|
+
if (k2 === undefined) k2 = k;
|
|
2558
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
2559
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
2560
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
2561
|
+
}
|
|
2562
|
+
Object.defineProperty(o, k2, desc);
|
|
2563
|
+
}) : (function(o, m, k, k2) {
|
|
2564
|
+
if (k2 === undefined) k2 = k;
|
|
2565
|
+
o[k2] = m[k];
|
|
2566
|
+
}));
|
|
2567
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
2568
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
2569
|
+
}) : function(o, v) {
|
|
2570
|
+
o["default"] = v;
|
|
2571
|
+
});
|
|
2572
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
2573
|
+
if (mod && mod.__esModule) return mod;
|
|
2574
|
+
var result = {};
|
|
2575
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
2576
|
+
__setModuleDefault(result, mod);
|
|
2577
|
+
return result;
|
|
2578
|
+
};
|
|
2579
|
+
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
2580
|
+
exports.SupportServiceDialogs = void 0;
|
|
2581
|
+
const react_1 = __importStar(__webpack_require__(/*! react */ "react"));
|
|
2582
|
+
const native_base_1 = __webpack_require__(/*! native-base */ "native-base");
|
|
2583
|
+
const react_redux_1 = __webpack_require__(/*! react-redux */ "react-redux");
|
|
2584
|
+
const native_1 = __webpack_require__(/*! @react-navigation/native */ "@react-navigation/native");
|
|
2585
|
+
const SupportServiceDialogsListItem_1 = __webpack_require__(/*! ../components/SupportServiceDialogsListItem */ "./src/screens/inbox/components/SupportServiceDialogsListItem.tsx");
|
|
2586
|
+
const platform_client_1 = __webpack_require__(/*! @messenger-box/platform-client */ "@messenger-box/platform-client");
|
|
2587
|
+
const user_auth0_client_1 = __webpack_require__(/*! @adminide-stack/user-auth0-client */ "@adminide-stack/user-auth0-client");
|
|
2588
|
+
const config_1 = __webpack_require__(/*! ../config */ "./src/screens/inbox/config/index.ts");
|
|
2589
|
+
const SupportServiceDialogsComponent = (props) => {
|
|
2590
|
+
const { channelFilters, channelRole } = props;
|
|
2591
|
+
const { params } = (0, native_1.useRoute)();
|
|
2592
|
+
const auth = (0, react_redux_1.useSelector)(user_auth0_client_1.userSelector);
|
|
2593
|
+
const dispatch = (0, react_redux_1.useDispatch)();
|
|
2594
|
+
const navigation = (0, native_1.useNavigation)();
|
|
2595
|
+
const isFocused = (0, native_1.useIsFocused)();
|
|
2596
|
+
const [refreshing, setRefresh] = (0, react_1.useState)(false);
|
|
2597
|
+
// const [userDirectChannel, setUserDirectChannel] = useState<any>([]);
|
|
2598
|
+
const { data: serviceChannels, loading: serviceChannelsLoading, refetch: getServiceChannelsRefetch, } = (0, platform_client_1.useSupportServiceChannelsQuery)({
|
|
2599
|
+
variables: {
|
|
2600
|
+
criteria: { type: 'SERVICE' },
|
|
2601
|
+
},
|
|
2602
|
+
onCompleted: (data) => {
|
|
2603
|
+
//setRefresh(false);
|
|
2604
|
+
},
|
|
2605
|
+
});
|
|
2606
|
+
(0, native_1.useFocusEffect)(react_1.default.useCallback(() => {
|
|
2607
|
+
// Do something when the screen is focused
|
|
2608
|
+
setRefresh(false);
|
|
2609
|
+
getServiceChannelsRefetch({ criteria: { type: 'SERVICE' } });
|
|
2610
|
+
return () => {
|
|
2611
|
+
// Do something when the screen is unfocused
|
|
2612
|
+
// Useful for cleanup functions
|
|
2613
|
+
};
|
|
2614
|
+
}, []));
|
|
2615
|
+
const channels = react_1.default.useMemo(() => {
|
|
2616
|
+
var _a, _b, _c;
|
|
2617
|
+
if (!((_a = serviceChannels === null || serviceChannels === void 0 ? void 0 : serviceChannels.supportServiceChannels) === null || _a === void 0 ? void 0 : _a.length))
|
|
2618
|
+
return null;
|
|
2619
|
+
let uChannels = (_c = (_b = serviceChannels === null || serviceChannels === void 0 ? void 0 : serviceChannels.supportServiceChannels) === null || _b === void 0 ? void 0 : _b.filter((c) => c.members.some((u) => u.user.__typename == 'UserAccount'))) !== null && _c !== void 0 ? _c : [];
|
|
2620
|
+
return uChannels || [];
|
|
2621
|
+
}, [serviceChannels]);
|
|
2622
|
+
const handleSelectChannel = (0, react_1.useCallback)((id, title, postParentId) => {
|
|
2623
|
+
var _a;
|
|
2624
|
+
if (params === null || params === void 0 ? void 0 : params.channelId) {
|
|
2625
|
+
navigation.navigate((params === null || params === void 0 ? void 0 : params.postParentId) || (params === null || params === void 0 ? void 0 : params.postParentId) == 0 ? config_1.config.THREAD_MESSEGE_PATH : config_1.config.THREADS_PATH, {
|
|
2626
|
+
channelId: params === null || params === void 0 ? void 0 : params.channelId,
|
|
2627
|
+
role: params === null || params === void 0 ? void 0 : params.role,
|
|
2628
|
+
title: (_a = params === null || params === void 0 ? void 0 : params.title) !== null && _a !== void 0 ? _a : null,
|
|
2629
|
+
postParentId: params === null || params === void 0 ? void 0 : params.postParentId,
|
|
2630
|
+
hideTabBar: true,
|
|
2631
|
+
});
|
|
2632
|
+
}
|
|
2633
|
+
else {
|
|
2634
|
+
navigation.navigate(postParentId || postParentId == 0 ? config_1.config.THREAD_MESSEGE_PATH : config_1.config.THREADS_PATH, {
|
|
2635
|
+
channelId: id,
|
|
2636
|
+
role: channelRole,
|
|
2637
|
+
title: title,
|
|
2638
|
+
postParentId: postParentId,
|
|
2639
|
+
hideTabBar: true,
|
|
2640
|
+
});
|
|
2641
|
+
}
|
|
2642
|
+
}, []);
|
|
2643
|
+
const handleRefresh = (0, react_1.useCallback)(() => {
|
|
2644
|
+
var _a;
|
|
2645
|
+
//if(userChannels?.channelsByUser?.length != channels?.length)setRefresh(true);
|
|
2646
|
+
setRefresh(true);
|
|
2647
|
+
(_a = getServiceChannelsRefetch({ criteria: { type: 'SERVICE' } })) === null || _a === void 0 ? void 0 : _a.then((res) => setRefresh(false));
|
|
2648
|
+
}, []);
|
|
2649
|
+
return (react_1.default.createElement(native_base_1.Box, { p: 2, pb: 0 },
|
|
2650
|
+
react_1.default.createElement(native_base_1.FlatList, { data: channels && (channels === null || channels === void 0 ? void 0 : channels.length) > 0 ? channels : [], onRefresh: handleRefresh, refreshing: serviceChannelsLoading, contentContainerStyle: {}, ItemSeparatorComponent: () => react_1.default.createElement(native_base_1.Box, { height: "0.5", backgroundColor: "gray.200" }), renderItem: ({ item: channel }) => (react_1.default.createElement(SupportServiceDialogsListItem_1.SupportServiceDialogsListItem, { onOpen: handleSelectChannel, currentUser: auth, channel: channel, refreshing: refreshing, selectedChannelId: params === null || params === void 0 ? void 0 : params.channelId, role: channelRole })), keyExtractor: (item, index) => 'support-service-key' + index })));
|
|
2651
|
+
};
|
|
2652
|
+
exports.SupportServiceDialogs = react_1.default.memo(SupportServiceDialogsComponent);
|
|
2653
|
+
|
|
2654
|
+
|
|
2655
|
+
/***/ }),
|
|
2656
|
+
|
|
2657
|
+
/***/ "./src/screens/inbox/containers/ThreadConversationView.tsx":
|
|
2658
|
+
/*!*****************************************************************!*\
|
|
2659
|
+
!*** ./src/screens/inbox/containers/ThreadConversationView.tsx ***!
|
|
2660
|
+
\*****************************************************************/
|
|
2661
|
+
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {
|
|
2662
|
+
|
|
2663
|
+
|
|
2664
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
2665
|
+
if (k2 === undefined) k2 = k;
|
|
2666
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
2667
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
2668
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
2669
|
+
}
|
|
2670
|
+
Object.defineProperty(o, k2, desc);
|
|
2671
|
+
}) : (function(o, m, k, k2) {
|
|
2672
|
+
if (k2 === undefined) k2 = k;
|
|
2673
|
+
o[k2] = m[k];
|
|
2674
|
+
}));
|
|
2675
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
2676
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
2677
|
+
}) : function(o, v) {
|
|
2678
|
+
o["default"] = v;
|
|
2679
|
+
});
|
|
2680
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
2681
|
+
if (mod && mod.__esModule) return mod;
|
|
2682
|
+
var result = {};
|
|
2683
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
2684
|
+
__setModuleDefault(result, mod);
|
|
2685
|
+
return result;
|
|
2686
|
+
};
|
|
2687
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
2688
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
2689
|
+
};
|
|
2690
|
+
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
2691
|
+
exports.ThreadConversationView = void 0;
|
|
2692
|
+
const react_1 = __importStar(__webpack_require__(/*! react */ "react"));
|
|
2693
|
+
const native_base_1 = __webpack_require__(/*! native-base */ "native-base");
|
|
2694
|
+
const react_native_1 = __webpack_require__(/*! react-native */ "react-native");
|
|
2695
|
+
const native_1 = __webpack_require__(/*! @react-navigation/native */ "@react-navigation/native");
|
|
2696
|
+
const react_redux_1 = __webpack_require__(/*! react-redux */ "react-redux");
|
|
2697
|
+
const lodash_1 = __webpack_require__(/*! lodash */ "lodash");
|
|
2698
|
+
const ImagePicker = __importStar(__webpack_require__(/*! expo-image-picker */ "expo-image-picker"));
|
|
2699
|
+
const base_64_1 = __webpack_require__(/*! base-64 */ "base-64");
|
|
2700
|
+
const vector_icons_1 = __webpack_require__(/*! @expo/vector-icons */ "@expo/vector-icons");
|
|
2701
|
+
const react_native_gifted_chat_1 = __webpack_require__(/*! react-native-gifted-chat */ "react-native-gifted-chat");
|
|
2702
|
+
const platform_client_1 = __webpack_require__(/*! @messenger-box/platform-client */ "@messenger-box/platform-client");
|
|
2703
|
+
const config_1 = __webpack_require__(/*! ../config */ "./src/screens/inbox/config/index.ts");
|
|
2704
|
+
const user_auth0_client_1 = __webpack_require__(/*! @adminide-stack/user-auth0-client */ "@adminide-stack/user-auth0-client");
|
|
2705
|
+
const SlackMessageContainer_1 = __webpack_require__(/*! ../components/SlackMessageContainer */ "./src/screens/inbox/components/SlackMessageContainer/index.ts");
|
|
2706
|
+
const CachedImage_1 = __importDefault(__webpack_require__(/*! ../components/CachedImage */ "./src/screens/inbox/components/CachedImage/index.tsx"));
|
|
2707
|
+
const date_fns_1 = __webpack_require__(/*! date-fns */ "date-fns");
|
|
2708
|
+
const { MESSAGES_PER_PAGE, CALL_TO_ACTION_BOX_BGCOLOR, CALL_TO_ACTION_PATH, CALL_TO_ACTION_BUTTON_BORDERCOLOR, CALL_TO_ACTION_TEXT_COLOR, } = config_1.config;
|
|
2709
|
+
const createdAtText = (value) => {
|
|
2710
|
+
if (!value)
|
|
2711
|
+
return '';
|
|
2712
|
+
let date = new Date(value);
|
|
2713
|
+
if ((0, date_fns_1.isToday)(date))
|
|
2714
|
+
return 'Today';
|
|
2715
|
+
if ((0, date_fns_1.isYesterday)(date))
|
|
2716
|
+
return 'Yesterday';
|
|
2717
|
+
return (0, date_fns_1.format)(new Date(value), 'MMM dd, yyyy');
|
|
2718
|
+
};
|
|
2719
|
+
const ThreadConversationViewComponent = ({ channelId, postParentId, isPostParentIdThread, role }) => {
|
|
2720
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v;
|
|
2721
|
+
const { params } = (0, native_1.useRoute)();
|
|
2722
|
+
const [channelToTop, setChannelToTop] = (0, react_1.useState)(0);
|
|
2723
|
+
const [channelMessages, setChannelMessages] = (0, react_1.useState)([]);
|
|
2724
|
+
const auth = (0, react_redux_1.useSelector)(user_auth0_client_1.userSelector);
|
|
2725
|
+
const [totalCount, setTotalCount] = (0, react_1.useState)(0);
|
|
2726
|
+
const [selectedImage, setImage] = (0, react_1.useState)('');
|
|
2727
|
+
const [loadingOldMessages, setLoadingOldMessages] = (0, react_1.useState)(false);
|
|
2728
|
+
const color = (0, native_base_1.useColorModeValue)('white', 'black');
|
|
2729
|
+
// const color = useColorModeValue('black', 'white');
|
|
2730
|
+
const navigation = (0, native_1.useNavigation)();
|
|
2731
|
+
const [files, setFiles] = (0, react_1.useState)([]);
|
|
2732
|
+
const [images, setImages] = (0, react_1.useState)([]);
|
|
2733
|
+
const [msg, setMsg] = (0, react_1.useState)('');
|
|
2734
|
+
const [loading, setLoading] = (0, react_1.useState)(false);
|
|
2735
|
+
const [imageLoading, setImageLoading] = (0, react_1.useState)(false);
|
|
2736
|
+
const [expoTokens, setExpoTokens] = (0, react_1.useState)([]);
|
|
2737
|
+
const [isShowImageViewer, setImageViewer] = (0, react_1.useState)(false);
|
|
2738
|
+
const [imageObject, setImageObject] = (0, react_1.useState)({});
|
|
2739
|
+
const [parentId, setParentId] = (0, react_1.useState)(postParentId);
|
|
2740
|
+
const { startUpload } = (0, platform_client_1.useUploadFilesNative)();
|
|
2741
|
+
const [threadPost, setThreadPost] = (0, react_1.useState)([]);
|
|
2742
|
+
const { data: mongooseObjectId } = (0, platform_client_1.useGetNewMongooseObjectIdQuery)({
|
|
2743
|
+
fetchPolicy: 'network-only',
|
|
2744
|
+
pollInterval: 5000,
|
|
2745
|
+
});
|
|
2746
|
+
const [sendThreadMessage] = (0, platform_client_1.useSendThreadMessageMutation)();
|
|
2747
|
+
const [getThreadMessages, { data: threadMessagesData, loading: threadLoading, refetch: refetchThreadMessages }] = (0, platform_client_1.useThreadMessagesLazyQuery)({
|
|
2748
|
+
variables: {
|
|
2749
|
+
channelId: !parentId || parentId == 0 ? null : channelId === null || channelId === void 0 ? void 0 : channelId.toString(),
|
|
2750
|
+
role: role === null || role === void 0 ? void 0 : role.toString(),
|
|
2751
|
+
postParentId: !parentId || parentId == 0 ? null : parentId === null || parentId === void 0 ? void 0 : parentId.toString(),
|
|
2752
|
+
},
|
|
2753
|
+
fetchPolicy: 'cache-and-network',
|
|
2754
|
+
});
|
|
2755
|
+
const { data, loading: messageLoading, refetch, } = (0, platform_client_1.useMessagesQuery)({
|
|
2756
|
+
variables: {
|
|
2757
|
+
channelId: !parentId || parentId == 0 ? null : channelId === null || channelId === void 0 ? void 0 : channelId.toString(),
|
|
2758
|
+
parentId: !parentId || parentId == 0 ? null : parentId === null || parentId === void 0 ? void 0 : parentId.toString(),
|
|
2759
|
+
limit: MESSAGES_PER_PAGE,
|
|
2760
|
+
},
|
|
2761
|
+
skip: !channelId,
|
|
2762
|
+
fetchPolicy: 'cache-and-network',
|
|
2763
|
+
});
|
|
2764
|
+
const { data: checkForMessages } = (0, platform_client_1.useCheckForNewMessagesQuery)({
|
|
2765
|
+
variables: {
|
|
2766
|
+
channelId: !parentId || parentId == 0 ? null : channelId === null || channelId === void 0 ? void 0 : channelId.toString(),
|
|
2767
|
+
parentId: !parentId || parentId == 0 ? null : parentId === null || parentId === void 0 ? void 0 : parentId.toString(),
|
|
2768
|
+
},
|
|
2769
|
+
skip: !channelId,
|
|
2770
|
+
fetchPolicy: 'network-only',
|
|
2771
|
+
pollInterval: 5000,
|
|
2772
|
+
});
|
|
2773
|
+
(0, native_1.useFocusEffect)(react_1.default.useCallback(() => {
|
|
2774
|
+
var _a;
|
|
2775
|
+
navigation === null || navigation === void 0 ? void 0 : navigation.setOptions({ title: (_a = params === null || params === void 0 ? void 0 : params.title) !== null && _a !== void 0 ? _a : 'Thread' });
|
|
2776
|
+
if (parentId || parentId == 0) {
|
|
2777
|
+
refetchThreadMessages({
|
|
2778
|
+
channelId: !parentId || parentId == 0 ? null : channelId === null || channelId === void 0 ? void 0 : channelId.toString(),
|
|
2779
|
+
role: role === null || role === void 0 ? void 0 : role.toString(),
|
|
2780
|
+
postParentId: !parentId || parentId == 0 ? null : parentId === null || parentId === void 0 ? void 0 : parentId.toString(),
|
|
2781
|
+
});
|
|
2782
|
+
}
|
|
2783
|
+
refetch({
|
|
2784
|
+
channelId: !parentId || parentId == 0 ? null : channelId === null || channelId === void 0 ? void 0 : channelId.toString(),
|
|
2785
|
+
parentId: !parentId || parentId == 0 ? null : parentId === null || parentId === void 0 ? void 0 : parentId.toString(),
|
|
2786
|
+
limit: MESSAGES_PER_PAGE,
|
|
2787
|
+
}).then(({ data }) => {
|
|
2788
|
+
if (!(data === null || data === void 0 ? void 0 : data.messages)) {
|
|
2789
|
+
return;
|
|
2790
|
+
}
|
|
2791
|
+
const { data: messages, totalCount } = data.messages;
|
|
2792
|
+
setTotalCount(totalCount);
|
|
2793
|
+
setChannelMessages((oldMessages) => (0, lodash_1.uniqBy)([...oldMessages, ...messages], ({ id }) => id));
|
|
2794
|
+
});
|
|
2795
|
+
return () => {
|
|
2796
|
+
setTotalCount(0);
|
|
2797
|
+
setChannelMessages([]);
|
|
2798
|
+
};
|
|
2799
|
+
}, []));
|
|
2800
|
+
(0, react_1.useEffect)(() => {
|
|
2801
|
+
setParentId(postParentId);
|
|
2802
|
+
}, [postParentId]);
|
|
2803
|
+
(0, react_1.useEffect)(() => {
|
|
2804
|
+
if (parentId && parentId == 0) {
|
|
2805
|
+
getThreadMessages({
|
|
2806
|
+
variables: {
|
|
2807
|
+
channelId: !parentId || parentId == 0 ? null : channelId === null || channelId === void 0 ? void 0 : channelId.toString(),
|
|
2808
|
+
role: role === null || role === void 0 ? void 0 : role.toString(),
|
|
2809
|
+
postParentId: !parentId || parentId == 0 ? null : parentId === null || parentId === void 0 ? void 0 : parentId.toString(),
|
|
2810
|
+
},
|
|
2811
|
+
});
|
|
2812
|
+
}
|
|
2813
|
+
}, [parentId]);
|
|
2814
|
+
(0, react_1.useEffect)(() => {
|
|
2815
|
+
if (threadMessagesData === null || threadMessagesData === void 0 ? void 0 : threadMessagesData.threadMessages) {
|
|
2816
|
+
const { data: threads, totalCount: threadTotalCount } = threadMessagesData === null || threadMessagesData === void 0 ? void 0 : threadMessagesData.threadMessages;
|
|
2817
|
+
const threadMessage = threads === null || threads === void 0 ? void 0 : threads.map((t) => t === null || t === void 0 ? void 0 : t.post);
|
|
2818
|
+
setThreadPost(threadMessage);
|
|
2819
|
+
if (!isPostParentIdThread) {
|
|
2820
|
+
// setTotalCount((pc: any) => pc + threadTotalCount);
|
|
2821
|
+
setChannelMessages((oldMessages) => (0, lodash_1.uniqBy)([...threadMessage, ...oldMessages], ({ id }) => id));
|
|
2822
|
+
}
|
|
2823
|
+
}
|
|
2824
|
+
}, [threadMessagesData, isPostParentIdThread]);
|
|
1167
2825
|
(0, react_1.useEffect)(() => {
|
|
1168
2826
|
var _a;
|
|
1169
2827
|
if (((_a = data === null || data === void 0 ? void 0 : data.messages) === null || _a === void 0 ? void 0 : _a.data) && (loadingOldMessages || channelMessages.length === 0)) {
|
|
@@ -1176,32 +2834,6 @@ const ConversationViewComponent = ({ channelId }) => {
|
|
|
1176
2834
|
setTotalCount(messeageTotalCount);
|
|
1177
2835
|
}
|
|
1178
2836
|
}, [data, loadingOldMessages, channelMessages, totalCount]);
|
|
1179
|
-
// useEffect(() => {
|
|
1180
|
-
// if (data?.messages?.data) {
|
|
1181
|
-
// const { data: messages, totalCount: messeageTotalCount } = data.messages;
|
|
1182
|
-
// console.log('messeageTotalCount',messeageTotalCount)
|
|
1183
|
-
// console.log('totalCount',totalCount)
|
|
1184
|
-
// if (messages && messages.length > 0) {
|
|
1185
|
-
// setChannelMessages((oldMessages: any) => uniqBy([...messages, ...oldMessages], ({ id }) => id));
|
|
1186
|
-
// }
|
|
1187
|
-
// if (totalCount !== messeageTotalCount) setTotalCount(messeageTotalCount);
|
|
1188
|
-
// }
|
|
1189
|
-
// }, [data]);
|
|
1190
|
-
// useEffect(() => {
|
|
1191
|
-
// if (checkForMessages?.messages?.totalCount > totalCount) {
|
|
1192
|
-
// const numberOfNewMessages = checkForMessages?.messages?.totalCount - totalCount;
|
|
1193
|
-
// refetch({
|
|
1194
|
-
// limit: numberOfNewMessages,
|
|
1195
|
-
// }).then(({ data }) => {
|
|
1196
|
-
// if (!data?.messages) {
|
|
1197
|
-
// return;
|
|
1198
|
-
// }
|
|
1199
|
-
// const { data: messages, totalCount }:any = data.messages;
|
|
1200
|
-
// setTotalCount(totalCount);
|
|
1201
|
-
// setChannelMessages((oldMessages:any) => uniqBy([...oldMessages, ...messages], ({ id }) => id));
|
|
1202
|
-
// });
|
|
1203
|
-
// }
|
|
1204
|
-
// }, [checkForMessages, totalCount]);
|
|
1205
2837
|
(0, react_1.useEffect)(() => {
|
|
1206
2838
|
var _a, _b, _c;
|
|
1207
2839
|
if (!messageLoading &&
|
|
@@ -1210,6 +2842,8 @@ const ConversationViewComponent = ({ channelId }) => {
|
|
|
1210
2842
|
const numberOfNewMessages = ((_c = checkForMessages === null || checkForMessages === void 0 ? void 0 : checkForMessages.messages) === null || _c === void 0 ? void 0 : _c.totalCount) - totalCount;
|
|
1211
2843
|
console.log('new msg check');
|
|
1212
2844
|
refetch({
|
|
2845
|
+
channelId: !parentId || parentId == 0 ? null : channelId === null || channelId === void 0 ? void 0 : channelId.toString(),
|
|
2846
|
+
parentId: !parentId || parentId == 0 ? null : parentId === null || parentId === void 0 ? void 0 : parentId.toString(),
|
|
1213
2847
|
limit: numberOfNewMessages,
|
|
1214
2848
|
}).then(({ data }) => {
|
|
1215
2849
|
if (!(data === null || data === void 0 ? void 0 : data.messages)) {
|
|
@@ -1220,40 +2854,22 @@ const ConversationViewComponent = ({ channelId }) => {
|
|
|
1220
2854
|
setChannelMessages((oldMessages) => (0, lodash_1.uniqBy)([...oldMessages, ...messages], ({ id }) => id));
|
|
1221
2855
|
});
|
|
1222
2856
|
}
|
|
1223
|
-
}, [checkForMessages, totalCount]);
|
|
1224
|
-
|
|
1225
|
-
|
|
1226
|
-
|
|
1227
|
-
|
|
1228
|
-
// setLoadingOldMessages(true);
|
|
1229
|
-
// refetch({ skip: channelMessages.length });
|
|
1230
|
-
// }
|
|
1231
|
-
// }, [data, channelMessages]);
|
|
1232
|
-
// const onFetchOld = () => {
|
|
1233
|
-
// // if (data?.messages?.totalCount > channelMessages.length) {
|
|
1234
|
-
// //if(channelMessages.length !== data?.messages?.totalCount){
|
|
1235
|
-
// if(totalCount > channelMessages.length){
|
|
1236
|
-
// setLoadingOldMessages(true);
|
|
1237
|
-
// refetch({ skip: channelMessages.length });
|
|
1238
|
-
// }
|
|
1239
|
-
// };
|
|
2857
|
+
}, [checkForMessages, totalCount, parentId]);
|
|
2858
|
+
react_1.default.useEffect(() => {
|
|
2859
|
+
if (selectedImage)
|
|
2860
|
+
setImageLoading(false);
|
|
2861
|
+
}, [selectedImage]);
|
|
1240
2862
|
const onFetchOld = (0, react_1.useCallback)(() => {
|
|
1241
2863
|
var _a;
|
|
1242
2864
|
if (((_a = data === null || data === void 0 ? void 0 : data.messages) === null || _a === void 0 ? void 0 : _a.totalCount) > channelMessages.length) {
|
|
1243
2865
|
setLoadingOldMessages(true);
|
|
1244
|
-
refetch({
|
|
2866
|
+
refetch({
|
|
2867
|
+
channelId: !parentId || parentId == 0 ? null : channelId === null || channelId === void 0 ? void 0 : channelId.toString(),
|
|
2868
|
+
parentId: !parentId || parentId == 0 ? null : parentId === null || parentId === void 0 ? void 0 : parentId.toString(),
|
|
2869
|
+
skip: channelMessages.length,
|
|
2870
|
+
});
|
|
1245
2871
|
}
|
|
1246
2872
|
}, [data, channelMessages]);
|
|
1247
|
-
// const onFetchOld = () => {
|
|
1248
|
-
// if(totalCount > channelMessages.length){
|
|
1249
|
-
// console.log('totalCount',totalCount)
|
|
1250
|
-
// console.log('channelMessages.length',channelMessages.length)
|
|
1251
|
-
// setLoadingOldMessages(true);
|
|
1252
|
-
// refetch({
|
|
1253
|
-
// skip: channelMessages.length
|
|
1254
|
-
// });
|
|
1255
|
-
// }
|
|
1256
|
-
// };
|
|
1257
2873
|
// const isCloseToTop = ({ layoutMeasurement, contentOffset, contentSize }) => {
|
|
1258
2874
|
// return contentOffset.y <= 100; // 100px from top
|
|
1259
2875
|
// };
|
|
@@ -1288,175 +2904,39 @@ const ConversationViewComponent = ({ channelId }) => {
|
|
|
1288
2904
|
setLoading(false);
|
|
1289
2905
|
};
|
|
1290
2906
|
const sendPushNotification = async (title, body, data, to) => {
|
|
1291
|
-
try {
|
|
1292
|
-
const response = await fetch('https://exp.host/--/api/v2/push/send/', {
|
|
1293
|
-
method: 'POST',
|
|
1294
|
-
headers: {
|
|
1295
|
-
Accept: 'application/json',
|
|
1296
|
-
'Accept-Encoding': 'gzip, deflate',
|
|
1297
|
-
'Content-Type': 'application/json',
|
|
1298
|
-
},
|
|
1299
|
-
body: JSON.stringify({
|
|
1300
|
-
to: to,
|
|
1301
|
-
data: data,
|
|
1302
|
-
title: title,
|
|
1303
|
-
body: body,
|
|
1304
|
-
sound: react_native_1.Platform.OS === 'android' ? false || null : 'default',
|
|
1305
|
-
}),
|
|
1306
|
-
});
|
|
1307
|
-
const result = await response.json();
|
|
1308
|
-
console.log('expo api response', result);
|
|
1309
|
-
}
|
|
1310
|
-
catch (error) {
|
|
1311
|
-
console.error('Error:', error);
|
|
1312
|
-
}
|
|
1313
|
-
|
|
1314
|
-
|
|
1315
|
-
|
|
1316
|
-
|
|
1317
|
-
// 'Accept-Encoding': 'gzip, deflate',
|
|
1318
|
-
// 'Content-Type': 'application/json',
|
|
1319
|
-
// },
|
|
1320
|
-
// body: JSON.stringify({
|
|
1321
|
-
// to: to,
|
|
1322
|
-
// data: data,
|
|
1323
|
-
// title: title,
|
|
1324
|
-
// body: body,
|
|
1325
|
-
// sound: Platform.OS === 'android' ? null : 'default',
|
|
1326
|
-
// }),
|
|
1327
|
-
// });
|
|
1328
|
-
};
|
|
1329
|
-
// const handleSend = useCallback(
|
|
1330
|
-
// async (message: string) => {
|
|
1331
|
-
// // if (!(message && channelId)) {
|
|
1332
|
-
// // return;
|
|
1333
|
-
// // }
|
|
1334
|
-
// if (!channelId) return;
|
|
1335
|
-
// if (!message && message != ' ' && images.length == 0) return;
|
|
1336
|
-
// setLoading(true);
|
|
1337
|
-
// const { data } = await sendMsg({
|
|
1338
|
-
// variables: {
|
|
1339
|
-
// channelId,
|
|
1340
|
-
// content: message,
|
|
1341
|
-
// },
|
|
1342
|
-
// update: (cache, { data, errors }) => {
|
|
1343
|
-
// if (!data || errors) {
|
|
1344
|
-
// setLoading(false);
|
|
1345
|
-
// return;
|
|
1346
|
-
// }
|
|
1347
|
-
// setChannelMessages((messages) => [...messages, data?.sendMessage]);
|
|
1348
|
-
// setTotalCount((t) => t + 1);
|
|
1349
|
-
// setChannelToTop(channelToTop + 1);
|
|
1350
|
-
// setLoading(false);
|
|
1351
|
-
// const title: String = currentUser?.givenName+' '+currentUser?.familyName+' in Followup Chat';
|
|
1352
|
-
// const body: String = message;
|
|
1353
|
-
// const notificationData: any = {
|
|
1354
|
-
// url: config.INBOX_MESSEGE_PATH,
|
|
1355
|
-
// params: { channelId, hideTabBar: true },
|
|
1356
|
-
// screen: 'DialogMessages',
|
|
1357
|
-
// };
|
|
1358
|
-
// console.log('expo to',JSON.stringify(expoTokens));
|
|
1359
|
-
// if (expoTokens?.length > 0) {
|
|
1360
|
-
// const to: any = expoTokens?.length > 0 ? expoTokens : [];
|
|
1361
|
-
// sendPushNotification(title, body, notificationData, to);
|
|
1362
|
-
// }
|
|
1363
|
-
// setMsg('');
|
|
1364
|
-
// },
|
|
1365
|
-
// });
|
|
1366
|
-
// if (images && images.length > 0 && data?.sendMessage?.id) {
|
|
1367
|
-
// const { id: postId } = data.sendMessage;
|
|
1368
|
-
// setLoading(true);
|
|
1369
|
-
// const uploadResponse = await startUpload({
|
|
1370
|
-
// file: images,
|
|
1371
|
-
// saveUploadedFile: {
|
|
1372
|
-
// variables: {
|
|
1373
|
-
// postId,
|
|
1374
|
-
// },
|
|
1375
|
-
// },
|
|
1376
|
-
// createUploadLink: {
|
|
1377
|
-
// variables: {
|
|
1378
|
-
// postId,
|
|
1379
|
-
// },
|
|
1380
|
-
// },
|
|
1381
|
-
// });
|
|
1382
|
-
// if (uploadResponse?.error) setLoading(false);
|
|
1383
|
-
// const uploadedFiles = uploadResponse.data as unknown as IFileInfo[];
|
|
1384
|
-
// if (uploadResponse.data) {
|
|
1385
|
-
// setImage('');
|
|
1386
|
-
// setFiles([]);
|
|
1387
|
-
// setImages([]);
|
|
1388
|
-
// setLoading(false);
|
|
1389
|
-
// }
|
|
1390
|
-
// setChannelMessages((messages) =>
|
|
1391
|
-
// messages.map((message) => {
|
|
1392
|
-
// if (message.id === postId) {
|
|
1393
|
-
// return {
|
|
1394
|
-
// ...message,
|
|
1395
|
-
// files: {
|
|
1396
|
-
// totalCount: uploadedFiles.length,
|
|
1397
|
-
// data: uploadedFiles,
|
|
1398
|
-
// },
|
|
1399
|
-
// };
|
|
1400
|
-
// }
|
|
1401
|
-
// return message;
|
|
1402
|
-
// }),
|
|
1403
|
-
// );
|
|
1404
|
-
// }
|
|
1405
|
-
// },
|
|
1406
|
-
// [setChannelMessages, currentUser, channelId, images,expoTokens],
|
|
1407
|
-
// );
|
|
1408
|
-
const handleSend = async (message) => {
|
|
2907
|
+
try {
|
|
2908
|
+
const response = await fetch('https://exp.host/--/api/v2/push/send/', {
|
|
2909
|
+
method: 'POST',
|
|
2910
|
+
headers: {
|
|
2911
|
+
Accept: 'application/json',
|
|
2912
|
+
'Accept-Encoding': 'gzip, deflate',
|
|
2913
|
+
'Content-Type': 'application/json',
|
|
2914
|
+
},
|
|
2915
|
+
body: JSON.stringify({
|
|
2916
|
+
to: to,
|
|
2917
|
+
data: data,
|
|
2918
|
+
title: title,
|
|
2919
|
+
body: body,
|
|
2920
|
+
sound: react_native_1.Platform.OS === 'android' ? false || null : 'default',
|
|
2921
|
+
}),
|
|
2922
|
+
});
|
|
2923
|
+
const result = await response.json();
|
|
2924
|
+
console.log('expo api response', result);
|
|
2925
|
+
}
|
|
2926
|
+
catch (error) {
|
|
2927
|
+
console.error('Error:', error);
|
|
2928
|
+
}
|
|
2929
|
+
};
|
|
2930
|
+
// const ObjectId = (m = Math, d = Date, h = 16, s = (s:any) => m.floor(s).toString(h)) =>
|
|
2931
|
+
// s(d.now() / 1000) + ' '.repeat(h).replace(/./g, () => s(m.random() * h))
|
|
2932
|
+
const handleSend = (0, react_1.useCallback)(async (message) => {
|
|
1409
2933
|
var _a;
|
|
1410
2934
|
if (!channelId)
|
|
1411
2935
|
return;
|
|
1412
2936
|
if (!message && message != ' ' && images.length == 0)
|
|
1413
2937
|
return;
|
|
1414
|
-
|
|
1415
|
-
|
|
1416
|
-
variables: {
|
|
1417
|
-
channelId,
|
|
1418
|
-
content: message,
|
|
1419
|
-
},
|
|
1420
|
-
update: (cache, { data, errors }) => {
|
|
1421
|
-
var _a, _b, _c, _d, _e;
|
|
1422
|
-
if (!data || errors) {
|
|
1423
|
-
setLoading(false);
|
|
1424
|
-
return;
|
|
1425
|
-
}
|
|
1426
|
-
setChannelMessages((messages) => [...messages, data === null || data === void 0 ? void 0 : data.sendMessage]);
|
|
1427
|
-
setTotalCount((t) => t + 1);
|
|
1428
|
-
setChannelToTop(channelToTop + 1);
|
|
1429
|
-
setLoading(false);
|
|
1430
|
-
setMsg('');
|
|
1431
|
-
const givenName = (_b = (_a = auth === null || auth === void 0 ? void 0 : auth.profile) === null || _a === void 0 ? void 0 : _a.given_name) !== null && _b !== void 0 ? _b : '';
|
|
1432
|
-
const familyName = (_d = (_c = auth === null || auth === void 0 ? void 0 : auth.profile) === null || _c === void 0 ? void 0 : _c.family_name) !== null && _d !== void 0 ? _d : '';
|
|
1433
|
-
const fullName = givenName ? givenName + ' ' + familyName : '';
|
|
1434
|
-
const title = fullName ? fullName : 'Message';
|
|
1435
|
-
const body = message;
|
|
1436
|
-
const notificationData = {
|
|
1437
|
-
url: config_1.config.INBOX_MESSEGE_PATH,
|
|
1438
|
-
params: { channelId, hideTabBar: true },
|
|
1439
|
-
screen: 'DialogMessages',
|
|
1440
|
-
};
|
|
1441
|
-
(_e = refetchChannelDetail({ id: channelId === null || channelId === void 0 ? void 0 : channelId.toString() })) === null || _e === void 0 ? void 0 : _e.then((res) => {
|
|
1442
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
|
|
1443
|
-
if ((_c = (_b = (_a = res === null || res === void 0 ? void 0 : res.data) === null || _a === void 0 ? void 0 : _a.viewChannelDetail) === null || _b === void 0 ? void 0 : _b.members) === null || _c === void 0 ? void 0 : _c.length) {
|
|
1444
|
-
const channelData = (_g = (_f = (_e = (_d = res === null || res === void 0 ? void 0 : res.data) === null || _d === void 0 ? void 0 : _d.viewChannelDetail) === null || _e === void 0 ? void 0 : _e.members) === null || _f === void 0 ? void 0 : _f.filter((mu) => { var _a; return ((_a = mu === null || mu === void 0 ? void 0 : mu.user) === null || _a === void 0 ? void 0 : _a.id) != (auth === null || auth === void 0 ? void 0 : auth.id); })) !== null && _g !== void 0 ? _g : [];
|
|
1445
|
-
const tokens = (_l = (_k = (_j = (_h = channelData === null || channelData === void 0 ? void 0 : channelData.map((u) => {
|
|
1446
|
-
var _a, _b, _c, _d;
|
|
1447
|
-
return (_d = (_c = (_b = (_a = u === null || u === void 0 ? void 0 : u.user) === null || _a === void 0 ? void 0 : _a.tokens) === null || _b === void 0 ? void 0 : _b.filter((t) => (t === null || t === void 0 ? void 0 : t.type) == 'EXPO_NOTIFICATION_TOKEN')) === null || _c === void 0 ? void 0 : _c.map((et) => et === null || et === void 0 ? void 0 : et.token)) !== null && _d !== void 0 ? _d : [];
|
|
1448
|
-
})) === null || _h === void 0 ? void 0 : _h.flat(1)) === null || _j === void 0 ? void 0 : _j.filter((t) => t)) === null || _k === void 0 ? void 0 : _k.filter((value, index, array) => array.indexOf(value) === index)) !== null && _l !== void 0 ? _l : [];
|
|
1449
|
-
console.log('expo to', JSON.stringify(tokens));
|
|
1450
|
-
if ((tokens === null || tokens === void 0 ? void 0 : tokens.length) > 0) {
|
|
1451
|
-
const to = (tokens === null || tokens === void 0 ? void 0 : tokens.length) > 0 ? tokens : [];
|
|
1452
|
-
sendPushNotification(title, body, notificationData, to);
|
|
1453
|
-
}
|
|
1454
|
-
}
|
|
1455
|
-
});
|
|
1456
|
-
},
|
|
1457
|
-
});
|
|
1458
|
-
if (images && images.length > 0 && ((_a = data === null || data === void 0 ? void 0 : data.sendMessage) === null || _a === void 0 ? void 0 : _a.id)) {
|
|
1459
|
-
const { id: postId } = data.sendMessage;
|
|
2938
|
+
if (images && images.length > 0) {
|
|
2939
|
+
const postId = mongooseObjectId === null || mongooseObjectId === void 0 ? void 0 : mongooseObjectId.getNewMongooseObjectId;
|
|
1460
2940
|
setLoading(true);
|
|
1461
2941
|
const uploadResponse = await startUpload({
|
|
1462
2942
|
file: images,
|
|
@@ -1478,25 +2958,118 @@ const ConversationViewComponent = ({ channelId }) => {
|
|
|
1478
2958
|
setImage('');
|
|
1479
2959
|
setFiles([]);
|
|
1480
2960
|
setImages([]);
|
|
1481
|
-
setLoading(false);
|
|
2961
|
+
//setLoading(false);
|
|
2962
|
+
const files = (_a = uploadedFiles === null || uploadedFiles === void 0 ? void 0 : uploadedFiles.map((f) => f.id)) !== null && _a !== void 0 ? _a : null;
|
|
2963
|
+
await sendThreadMessage({
|
|
2964
|
+
variables: {
|
|
2965
|
+
postId,
|
|
2966
|
+
channelId,
|
|
2967
|
+
postParentId: !parentId || parentId == 0 ? null : parentId,
|
|
2968
|
+
threadMessageInput: {
|
|
2969
|
+
content: message,
|
|
2970
|
+
files,
|
|
2971
|
+
role,
|
|
2972
|
+
},
|
|
2973
|
+
},
|
|
2974
|
+
update: (cache, { data, errors }) => {
|
|
2975
|
+
var _a;
|
|
2976
|
+
if (!data || errors) {
|
|
2977
|
+
setLoading(false);
|
|
2978
|
+
return;
|
|
2979
|
+
}
|
|
2980
|
+
const responseMessage = (_a = data === null || data === void 0 ? void 0 : data.sendThreadMessage) === null || _a === void 0 ? void 0 : _a.lastMessage;
|
|
2981
|
+
setChannelMessages((messages) => [
|
|
2982
|
+
...messages,
|
|
2983
|
+
Object.assign(Object.assign({}, responseMessage), { files: {
|
|
2984
|
+
totalCount: uploadedFiles.length,
|
|
2985
|
+
data: uploadedFiles,
|
|
2986
|
+
} }),
|
|
2987
|
+
]);
|
|
2988
|
+
setTotalCount((t) => t + 1);
|
|
2989
|
+
setChannelToTop(channelToTop + 1);
|
|
2990
|
+
setLoading(false);
|
|
2991
|
+
setMsg('');
|
|
2992
|
+
if (!parentId || parentId == 0) {
|
|
2993
|
+
setParentId(responseMessage === null || responseMessage === void 0 ? void 0 : responseMessage.id);
|
|
2994
|
+
}
|
|
2995
|
+
const msg = message == '' ? 'Send a file' : message;
|
|
2996
|
+
fetchTokenAndSendPushNotification(msg, channelId, parentId);
|
|
2997
|
+
},
|
|
2998
|
+
});
|
|
1482
2999
|
}
|
|
1483
|
-
|
|
1484
|
-
|
|
1485
|
-
|
|
1486
|
-
|
|
1487
|
-
|
|
1488
|
-
|
|
3000
|
+
}
|
|
3001
|
+
else {
|
|
3002
|
+
setLoading(true);
|
|
3003
|
+
await sendThreadMessage({
|
|
3004
|
+
variables: {
|
|
3005
|
+
channelId,
|
|
3006
|
+
postParentId: !parentId || parentId == 0 ? null : parentId,
|
|
3007
|
+
threadMessageInput: {
|
|
3008
|
+
content: message,
|
|
3009
|
+
role,
|
|
3010
|
+
},
|
|
3011
|
+
},
|
|
3012
|
+
update: (cache, { data, errors }) => {
|
|
3013
|
+
var _a;
|
|
3014
|
+
if (!data || errors) {
|
|
3015
|
+
setLoading(false);
|
|
3016
|
+
return;
|
|
3017
|
+
}
|
|
3018
|
+
const responseMessage = (_a = data === null || data === void 0 ? void 0 : data.sendThreadMessage) === null || _a === void 0 ? void 0 : _a.lastMessage;
|
|
3019
|
+
setChannelMessages((messages) => [...messages, responseMessage]);
|
|
3020
|
+
setTotalCount((t) => t + 1);
|
|
3021
|
+
setChannelToTop(channelToTop + 1);
|
|
3022
|
+
setLoading(false);
|
|
3023
|
+
setMsg('');
|
|
3024
|
+
if (!parentId || parentId == 0) {
|
|
3025
|
+
setParentId(responseMessage === null || responseMessage === void 0 ? void 0 : responseMessage.id);
|
|
3026
|
+
}
|
|
3027
|
+
fetchTokenAndSendPushNotification(message, channelId, parentId);
|
|
3028
|
+
},
|
|
3029
|
+
});
|
|
3030
|
+
}
|
|
3031
|
+
}, [mongooseObjectId, setChannelMessages, channelId, images, parentId, expoTokens]);
|
|
3032
|
+
const fetchTokenAndSendPushNotification = (message, channelId, parentId) => {
|
|
3033
|
+
var _a, _b, _c, _d, _e, _f;
|
|
3034
|
+
const givenName = (_b = (_a = auth === null || auth === void 0 ? void 0 : auth.profile) === null || _a === void 0 ? void 0 : _a.given_name) !== null && _b !== void 0 ? _b : '';
|
|
3035
|
+
const familyName = (_d = (_c = auth === null || auth === void 0 ? void 0 : auth.profile) === null || _c === void 0 ? void 0 : _c.family_name) !== null && _d !== void 0 ? _d : '';
|
|
3036
|
+
const fullName = givenName ? givenName + ' ' + familyName : '';
|
|
3037
|
+
const title = fullName ? fullName : 'Message';
|
|
3038
|
+
const body = message;
|
|
3039
|
+
const notificationData = {
|
|
3040
|
+
url: config_1.config.THREAD_MESSEGE_PATH,
|
|
3041
|
+
params: { channelId, title: (_e = params === null || params === void 0 ? void 0 : params.title) !== null && _e !== void 0 ? _e : 'Thread', postParentId: parentId, hideTabBar: true },
|
|
3042
|
+
screen: 'DialogThreadMessages',
|
|
3043
|
+
};
|
|
3044
|
+
if (parentId || parentId == 0) {
|
|
3045
|
+
(_f = refetchThreadMessages({
|
|
3046
|
+
channelId: !parentId || parentId == 0 ? null : channelId === null || channelId === void 0 ? void 0 : channelId.toString(),
|
|
3047
|
+
role: role === null || role === void 0 ? void 0 : role.toString(),
|
|
3048
|
+
postParentId: !parentId || parentId == 0 ? null : parentId === null || parentId === void 0 ? void 0 : parentId.toString(),
|
|
3049
|
+
})) === null || _f === void 0 ? void 0 : _f.then((res) => {
|
|
3050
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
|
|
3051
|
+
if (((_c = (_b = (_a = res === null || res === void 0 ? void 0 : res.data) === null || _a === void 0 ? void 0 : _a.threadMessages) === null || _b === void 0 ? void 0 : _b.data) === null || _c === void 0 ? void 0 : _c.length) > 0) {
|
|
3052
|
+
const participants = (_h = (_g = (_f = (_e = (_d = res === null || res === void 0 ? void 0 : res.data) === null || _d === void 0 ? void 0 : _d.threadMessages) === null || _e === void 0 ? void 0 : _e.data) === null || _f === void 0 ? void 0 : _f.map((t) => t === null || t === void 0 ? void 0 : t.participants)) === null || _g === void 0 ? void 0 : _g.flat(1)) !== null && _h !== void 0 ? _h : [];
|
|
3053
|
+
const participantsTokens = (participants === null || participants === void 0 ? void 0 : participants.length) > 0
|
|
3054
|
+
? (_k = (_j = participants === null || participants === void 0 ? void 0 : participants.filter((u) => (u === null || u === void 0 ? void 0 : u.id) != (auth === null || auth === void 0 ? void 0 : auth.id))) === null || _j === void 0 ? void 0 : _j.map((p) => p.tokens)) === null || _k === void 0 ? void 0 : _k.flat(1)
|
|
3055
|
+
: [];
|
|
3056
|
+
const expoTokens = (participantsTokens === null || participantsTokens === void 0 ? void 0 : participantsTokens.length) > 0
|
|
3057
|
+
? (_l = participantsTokens === null || participantsTokens === void 0 ? void 0 : participantsTokens.filter((t) => (t === null || t === void 0 ? void 0 : t.type) == 'EXPO_NOTIFICATION_TOKEN')) === null || _l === void 0 ? void 0 : _l.map((et) => et === null || et === void 0 ? void 0 : et.token)
|
|
3058
|
+
: [];
|
|
3059
|
+
if ((expoTokens === null || expoTokens === void 0 ? void 0 : expoTokens.length) > 0) {
|
|
3060
|
+
const to = expoTokens;
|
|
3061
|
+
sendPushNotification(title, body, notificationData, to);
|
|
3062
|
+
}
|
|
1489
3063
|
}
|
|
1490
|
-
|
|
1491
|
-
}));
|
|
3064
|
+
});
|
|
1492
3065
|
}
|
|
1493
3066
|
};
|
|
1494
3067
|
const messageList = (0, react_1.useMemo)(() => {
|
|
1495
3068
|
let currentDate = '';
|
|
1496
3069
|
let res = [];
|
|
1497
|
-
if (channelMessages.length) {
|
|
3070
|
+
if (channelMessages === null || channelMessages === void 0 ? void 0 : channelMessages.length) {
|
|
1498
3071
|
(0, lodash_1.orderBy)(channelMessages, ['createdAt'], ['desc']).map((msg) => {
|
|
1499
|
-
var _a, _b, _c;
|
|
3072
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p;
|
|
1500
3073
|
let message = {
|
|
1501
3074
|
_id: '',
|
|
1502
3075
|
text: '',
|
|
@@ -1513,11 +3086,11 @@ const ConversationViewComponent = ({ channelId }) => {
|
|
|
1513
3086
|
message.text = msg.message;
|
|
1514
3087
|
message.createdAt = date;
|
|
1515
3088
|
(message.user = {
|
|
1516
|
-
_id: msg.author.id,
|
|
1517
|
-
name: msg.author.givenName + ' ' + msg.author.familyName,
|
|
1518
|
-
avatar: (
|
|
3089
|
+
_id: (_b = (_a = msg === null || msg === void 0 ? void 0 : msg.author) === null || _a === void 0 ? void 0 : _a.id) !== null && _b !== void 0 ? _b : (_c = auth === null || auth === void 0 ? void 0 : auth.profile) === null || _c === void 0 ? void 0 : _c.id,
|
|
3090
|
+
name: (_h = (_e = (_d = msg === null || msg === void 0 ? void 0 : msg.author) === null || _d === void 0 ? void 0 : _d.givenName) !== null && _e !== void 0 ? _e : ((_f = auth === null || auth === void 0 ? void 0 : auth.profile) === null || _f === void 0 ? void 0 : _f.given_name) + ' ' + ((_g = msg === null || msg === void 0 ? void 0 : msg.author) === null || _g === void 0 ? void 0 : _g.familyName)) !== null && _h !== void 0 ? _h : (_j = auth === null || auth === void 0 ? void 0 : auth.profile) === null || _j === void 0 ? void 0 : _j.family_name,
|
|
3091
|
+
avatar: (_l = (_k = msg === null || msg === void 0 ? void 0 : msg.author) === null || _k === void 0 ? void 0 : _k.picture) !== null && _l !== void 0 ? _l : (_m = auth === null || auth === void 0 ? void 0 : auth.profile) === null || _m === void 0 ? void 0 : _m.picture,
|
|
1519
3092
|
}),
|
|
1520
|
-
(message.image = (
|
|
3093
|
+
(message.image = (_p = (_o = msg.files) === null || _o === void 0 ? void 0 : _o.data[0]) === null || _p === void 0 ? void 0 : _p.url),
|
|
1521
3094
|
(message.sent = msg === null || msg === void 0 ? void 0 : msg.isDelivered),
|
|
1522
3095
|
(message.received = msg === null || msg === void 0 ? void 0 : msg.isRead);
|
|
1523
3096
|
message.type = msg === null || msg === void 0 ? void 0 : msg.type;
|
|
@@ -1543,10 +3116,6 @@ const ConversationViewComponent = ({ channelId }) => {
|
|
|
1543
3116
|
action = CALL_TO_ACTION_PATH;
|
|
1544
3117
|
actionId = (_e = attachment === null || attachment === void 0 ? void 0 : attachment.callToAction) === null || _e === void 0 ? void 0 : _e.link.split('/').pop();
|
|
1545
3118
|
}
|
|
1546
|
-
// if (attachment?.callToAction?.link?.includes('my-reservation-details')) {
|
|
1547
|
-
// action = 'm-reservation-detail';
|
|
1548
|
-
// actionId = attachment?.callToAction?.link.split('/').pop();
|
|
1549
|
-
// }
|
|
1550
3119
|
return (react_1.default.createElement(native_base_1.Box, { bg: CALL_TO_ACTION_BOX_BGCOLOR, borderRadius: 15, pb: 2 },
|
|
1551
3120
|
(attachment === null || attachment === void 0 ? void 0 : attachment.callToAction) ? (react_1.default.createElement(native_base_1.Button, { variant: 'outline', size: 'sm', borderColor: CALL_TO_ACTION_BUTTON_BORDERCOLOR, onPress: () => navigation.navigate(action, { reservationId: actionId }) },
|
|
1552
3121
|
react_1.default.createElement(native_base_1.Text, { color: CALL_TO_ACTION_TEXT_COLOR }, attachment.callToAction.title))) : null,
|
|
@@ -1585,89 +3154,52 @@ const ConversationViewComponent = ({ channelId }) => {
|
|
|
1585
3154
|
}, alt: 'image' }));
|
|
1586
3155
|
}, [imageObject]);
|
|
1587
3156
|
const renderMessage = (props) => {
|
|
1588
|
-
// const {
|
|
1589
|
-
// currentMessage: { text: currText },
|
|
1590
|
-
// } = props;
|
|
1591
|
-
//let messageTextStyle: any;
|
|
1592
|
-
// Make "pure emoji" messages much bigger than plain text.
|
|
1593
|
-
// if (currText && emojiUtils.isPureEmojiString(currText)) {
|
|
1594
|
-
// messageTextStyle = {
|
|
1595
|
-
// fontSize: 28,
|
|
1596
|
-
// // Emoji get clipped if lineHeight isn't increased; make it consistent across platforms.
|
|
1597
|
-
// lineHeight: Platform.OS === 'android' ? 34 : 30,
|
|
1598
|
-
// }
|
|
1599
|
-
// }
|
|
1600
|
-
// return <SlackMessage {...props} messageTextStyle={messageTextStyle} />;
|
|
1601
3157
|
return react_1.default.createElement(SlackMessageContainer_1.SlackMessage, Object.assign({}, props, { isShowImageViewer: isShowImageViewer, setImageViewer: setImageViewerObject }));
|
|
1602
3158
|
};
|
|
1603
|
-
let onScroll = false;
|
|
1604
|
-
const onEndReached = () => {
|
|
1605
|
-
console.log('on end reached');
|
|
1606
|
-
if (!onScroll)
|
|
1607
|
-
return;
|
|
1608
|
-
// load messages, show ActivityIndicator
|
|
1609
|
-
onScroll = false;
|
|
1610
|
-
// setLoadingOldMessages(true);
|
|
1611
|
-
};
|
|
1612
|
-
// const onMomentumScrollBegin = useCallback(
|
|
1613
|
-
// ({ nativeEvent }: any) => {
|
|
1614
|
-
// onScroll = true;
|
|
1615
|
-
// console.log('scroll top');
|
|
1616
|
-
// if (!loadingOldMessages && channelMessages?.length <= 10 && channelMessages?.length != totalCount) {
|
|
1617
|
-
// onFetchOld();
|
|
1618
|
-
// } else if (!loadingOldMessages && isCloseToTop(nativeEvent) && channelMessages?.length != totalCount) {
|
|
1619
|
-
// onFetchOld();
|
|
1620
|
-
// }
|
|
1621
|
-
// },
|
|
1622
|
-
// [loadingOldMessages, channelMessages],
|
|
1623
|
-
// );
|
|
1624
|
-
const onMomentumScrollBegin = ({ nativeEvent }) => {
|
|
1625
|
-
onScroll = true;
|
|
1626
|
-
console.log('scroll top');
|
|
1627
|
-
if (!loadingOldMessages &&
|
|
1628
|
-
((channelMessages === null || channelMessages === void 0 ? void 0 : channelMessages.length) <= 10 || isCloseToTop(nativeEvent)) &&
|
|
1629
|
-
(channelMessages === null || channelMessages === void 0 ? void 0 : channelMessages.length) != totalCount) {
|
|
1630
|
-
onFetchOld();
|
|
1631
|
-
}
|
|
1632
|
-
};
|
|
1633
3159
|
return (react_1.default.createElement(react_1.default.Fragment, null,
|
|
1634
3160
|
loadingOldMessages && react_1.default.createElement(native_base_1.Spinner, null),
|
|
1635
|
-
react_1.default.createElement(
|
|
1636
|
-
|
|
1637
|
-
|
|
1638
|
-
|
|
1639
|
-
|
|
1640
|
-
|
|
1641
|
-
|
|
1642
|
-
|
|
1643
|
-
|
|
1644
|
-
|
|
1645
|
-
|
|
1646
|
-
|
|
1647
|
-
|
|
1648
|
-
|
|
1649
|
-
|
|
1650
|
-
|
|
3161
|
+
isPostParentIdThread && (react_1.default.createElement(react_1.default.Fragment, null, (threadPost === null || threadPost === void 0 ? void 0 : threadPost.length) > 0 && (react_1.default.createElement(react_1.default.Fragment, null,
|
|
3162
|
+
react_1.default.createElement(native_base_1.VStack, { px: 2, pt: 2, pb: 0, space: 2 },
|
|
3163
|
+
react_1.default.createElement(native_base_1.HStack, { space: 2, alignItems: 'center' },
|
|
3164
|
+
react_1.default.createElement(native_base_1.Avatar, { bg: 'transparent', size: 10, _image: { borderRadius: 6, borderWidth: 2, borderColor: '#fff' }, source: {
|
|
3165
|
+
uri: (_b = (_a = threadPost[0]) === null || _a === void 0 ? void 0 : _a.author) === null || _b === void 0 ? void 0 : _b.picture,
|
|
3166
|
+
} }, (0, lodash_1.startCase)((_e = (_d = (_c = threadPost[0]) === null || _c === void 0 ? void 0 : _c.author) === null || _d === void 0 ? void 0 : _d.username) === null || _e === void 0 ? void 0 : _e.charAt(0))),
|
|
3167
|
+
react_1.default.createElement(native_base_1.Box, null,
|
|
3168
|
+
react_1.default.createElement(native_base_1.Text, { color: 'black', fontWeight: 'bold' }, (_h = (_g = (_f = threadPost[0]) === null || _f === void 0 ? void 0 : _f.author) === null || _g === void 0 ? void 0 : _g.givenName) !== null && _h !== void 0 ? _h : '',
|
|
3169
|
+
' ', (_l = (_k = (_j = threadPost[0]) === null || _j === void 0 ? void 0 : _j.author) === null || _k === void 0 ? void 0 : _k.familyName) !== null && _l !== void 0 ? _l : ''),
|
|
3170
|
+
react_1.default.createElement(native_base_1.Text, { color: 'gray.500', pl: 0 },
|
|
3171
|
+
createdAtText((_m = threadPost[0]) === null || _m === void 0 ? void 0 : _m.createdAt),
|
|
3172
|
+
" at",
|
|
3173
|
+
' ',
|
|
3174
|
+
(0, date_fns_1.format)(new Date((_o = threadPost[0]) === null || _o === void 0 ? void 0 : _o.createdAt), 'hh:ss:a')))),
|
|
3175
|
+
react_1.default.createElement(native_base_1.HStack, { px: 2, space: 2, alignItems: 'center' },
|
|
3176
|
+
react_1.default.createElement(native_base_1.Text, null, (_q = (_p = threadPost[0]) === null || _p === void 0 ? void 0 : _p.message) !== null && _q !== void 0 ? _q : ''))),
|
|
3177
|
+
react_1.default.createElement(native_base_1.Box, { py: 4 },
|
|
3178
|
+
react_1.default.createElement(native_base_1.Box, { px: 4, borderTopWidth: 1, borderBottomWidth: 1, py: 2, borderColor: 'gray.200' },
|
|
3179
|
+
react_1.default.createElement(native_base_1.Text, { color: 'gray.600', fontWeight: 'bold' }, (_s = (_r = threadPost[0]) === null || _r === void 0 ? void 0 : _r.replies) === null || _s === void 0 ? void 0 :
|
|
3180
|
+
_s.totalCount,
|
|
3181
|
+
' ',
|
|
3182
|
+
((_u = (_t = threadPost[0]) === null || _t === void 0 ? void 0 : _t.replies) === null || _u === void 0 ? void 0 : _u.totalCount) > 0 ? 'replies' : 'reply'))))))),
|
|
3183
|
+
react_1.default.createElement(react_native_gifted_chat_1.GiftedChat, { wrapInSafeArea: false, renderLoading: () => react_1.default.createElement(native_base_1.Spinner, null), messages: messageList, onSend: (messages) => { var _a, _b; return handleSend((_b = (_a = messages[0]) === null || _a === void 0 ? void 0 : _a.text) !== null && _b !== void 0 ? _b : ' '); }, text: msg ? msg : ' ', onInputTextChanged: (text) => setMsg(text), renderFooter: () => (loading ? react_1.default.createElement(native_base_1.Spinner, null) : imageLoading ? react_1.default.createElement(native_base_1.Spinner, null) : ''), scrollToBottom: true, user: {
|
|
1651
3184
|
_id: (auth === null || auth === void 0 ? void 0 : auth.id) || '',
|
|
1652
|
-
}, isTyping: true, alwaysShowSend: loading ? false : true, onLoadEarlier: onFetchOld, infiniteScroll: true, renderSend: renderSend, loadEarlier: ((
|
|
1653
|
-
|
|
1654
|
-
|
|
1655
|
-
|
|
1656
|
-
renderMessageText: renderMessageText, minInputToolbarHeight: 50, renderActions: renderActions, renderAccessory: renderAccessory, renderMessage: renderMessage, renderChatFooter: () => (react_1.default.createElement(SlackMessageContainer_1.ImageViewerModal, { isVisible: isShowImageViewer, setVisible: setImageViewer, modalContent: modalContent })), lightboxProps: {
|
|
3185
|
+
}, isTyping: true, alwaysShowSend: loading ? false : true, onLoadEarlier: onFetchOld, infiniteScroll: true, renderSend: renderSend, loadEarlier: ((_v = data === null || data === void 0 ? void 0 : data.messages) === null || _v === void 0 ? void 0 : _v.totalCount) > channelMessages.length, renderMessageText: renderMessageText, minInputToolbarHeight: 50, renderActions: renderActions, renderAccessory: renderAccessory, renderMessage: renderMessage, renderChatFooter: () => (react_1.default.createElement(SlackMessageContainer_1.ImageViewerModal, { isVisible: isShowImageViewer, setVisible: setImageViewer, modalContent: modalContent })), messagesContainerStyle: (messageList === null || messageList === void 0 ? void 0 : messageList.length) == 0 && { transform: [{ scaleY: -1 }] }, renderChatEmpty: () => (react_1.default.createElement(react_1.default.Fragment, null, !threadLoading && !messageLoading && messageList && (messageList === null || messageList === void 0 ? void 0 : messageList.length) == 0 && (react_1.default.createElement(native_base_1.Box, { p: 5 },
|
|
3186
|
+
react_1.default.createElement(native_base_1.Center, { mt: 6 },
|
|
3187
|
+
react_1.default.createElement(native_base_1.Icon, { as: vector_icons_1.Ionicons, name: "chatbubbles", size: 'xl' }),
|
|
3188
|
+
react_1.default.createElement(native_base_1.Text, null, "You don't have any message yet!")))))), lightboxProps: {
|
|
1657
3189
|
underlayColor: 'transparent',
|
|
1658
3190
|
springConfig: { tension: 90000, friction: 90000 },
|
|
1659
3191
|
disabled: true,
|
|
1660
3192
|
} })));
|
|
1661
3193
|
};
|
|
1662
|
-
exports.
|
|
3194
|
+
exports.ThreadConversationView = react_1.default.memo(ThreadConversationViewComponent);
|
|
1663
3195
|
|
|
1664
3196
|
|
|
1665
3197
|
/***/ }),
|
|
1666
3198
|
|
|
1667
|
-
/***/ "./src/screens/inbox/containers/
|
|
1668
|
-
|
|
1669
|
-
!*** ./src/screens/inbox/containers/
|
|
1670
|
-
|
|
3199
|
+
/***/ "./src/screens/inbox/containers/ThreadsView.tsx":
|
|
3200
|
+
/*!******************************************************!*\
|
|
3201
|
+
!*** ./src/screens/inbox/containers/ThreadsView.tsx ***!
|
|
3202
|
+
\******************************************************/
|
|
1671
3203
|
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {
|
|
1672
3204
|
|
|
1673
3205
|
|
|
@@ -1695,113 +3227,137 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
1695
3227
|
return result;
|
|
1696
3228
|
};
|
|
1697
3229
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
1698
|
-
exports.
|
|
3230
|
+
exports.ThreadsView = void 0;
|
|
1699
3231
|
const react_1 = __importStar(__webpack_require__(/*! react */ "react"));
|
|
1700
3232
|
const native_base_1 = __webpack_require__(/*! native-base */ "native-base");
|
|
1701
3233
|
const vector_icons_1 = __webpack_require__(/*! @expo/vector-icons */ "@expo/vector-icons");
|
|
1702
3234
|
const react_redux_1 = __webpack_require__(/*! react-redux */ "react-redux");
|
|
1703
3235
|
const native_1 = __webpack_require__(/*! @react-navigation/native */ "@react-navigation/native");
|
|
1704
|
-
const
|
|
3236
|
+
const lodash_1 = __webpack_require__(/*! lodash */ "lodash");
|
|
3237
|
+
const ThreadsViewItem_1 = __webpack_require__(/*! ../components/ThreadsViewItem */ "./src/screens/inbox/components/ThreadsViewItem.tsx");
|
|
1705
3238
|
const platform_client_1 = __webpack_require__(/*! @messenger-box/platform-client */ "@messenger-box/platform-client");
|
|
1706
3239
|
const user_auth0_client_1 = __webpack_require__(/*! @adminide-stack/user-auth0-client */ "@adminide-stack/user-auth0-client");
|
|
1707
3240
|
const config_1 = __webpack_require__(/*! ../config */ "./src/screens/inbox/config/index.ts");
|
|
1708
|
-
const
|
|
1709
|
-
|
|
3241
|
+
const { MESSAGES_PER_PAGE } = config_1.config;
|
|
3242
|
+
const ThreadsViewComponent = ({ channelId, role, channelsDetail, refetchChannelDetail }) => {
|
|
1710
3243
|
const { params } = (0, native_1.useRoute)();
|
|
1711
3244
|
const auth = (0, react_redux_1.useSelector)(user_auth0_client_1.userSelector);
|
|
1712
3245
|
const dispatch = (0, react_redux_1.useDispatch)();
|
|
1713
3246
|
const navigation = (0, native_1.useNavigation)();
|
|
1714
3247
|
const isFocused = (0, native_1.useIsFocused)();
|
|
1715
3248
|
const [refreshing, setRefresh] = (0, react_1.useState)(false);
|
|
1716
|
-
|
|
1717
|
-
const { data
|
|
3249
|
+
const [threadData, setThreadsData] = (0, react_1.useState)([]);
|
|
3250
|
+
const { data, loading: threadLoading, error, refetch, } = (0, platform_client_1.useThreadMessagesQuery)({
|
|
1718
3251
|
variables: {
|
|
1719
|
-
|
|
1720
|
-
|
|
3252
|
+
channelId: channelId === null || channelId === void 0 ? void 0 : channelId.toString(),
|
|
3253
|
+
role: role === null || role === void 0 ? void 0 : role.toString(),
|
|
3254
|
+
limit: MESSAGES_PER_PAGE,
|
|
1721
3255
|
},
|
|
1722
|
-
|
|
1723
|
-
setRefresh(false);
|
|
1724
|
-
}
|
|
3256
|
+
fetchPolicy: 'cache-and-network',
|
|
1725
3257
|
});
|
|
1726
3258
|
(0, native_1.useFocusEffect)(react_1.default.useCallback(() => {
|
|
3259
|
+
var _a;
|
|
1727
3260
|
// Do something when the screen is focused
|
|
1728
|
-
|
|
1729
|
-
|
|
3261
|
+
navigation === null || navigation === void 0 ? void 0 : navigation.setOptions({ title: (_a = params === null || params === void 0 ? void 0 : params.title) !== null && _a !== void 0 ? _a : 'Thread' });
|
|
3262
|
+
refetch({
|
|
3263
|
+
channelId: channelId === null || channelId === void 0 ? void 0 : channelId.toString(),
|
|
3264
|
+
role: role === null || role === void 0 ? void 0 : role.toString(),
|
|
3265
|
+
limit: MESSAGES_PER_PAGE,
|
|
3266
|
+
}).then(({ data }) => {
|
|
3267
|
+
var _a, _b, _c;
|
|
3268
|
+
if (!((_a = data === null || data === void 0 ? void 0 : data.threadMessages) === null || _a === void 0 ? void 0 : _a.data)) {
|
|
3269
|
+
return;
|
|
3270
|
+
}
|
|
3271
|
+
if ((_c = (_b = data === null || data === void 0 ? void 0 : data.threadMessages) === null || _b === void 0 ? void 0 : _b.data) === null || _c === void 0 ? void 0 : _c.length) {
|
|
3272
|
+
const { data: newThreads } = data === null || data === void 0 ? void 0 : data.threadMessages;
|
|
3273
|
+
setThreadsData((oldThreads) => (0, lodash_1.uniqBy)([...oldThreads, ...newThreads], ({ id }) => id));
|
|
3274
|
+
}
|
|
3275
|
+
});
|
|
1730
3276
|
return () => {
|
|
1731
3277
|
// Do something when the screen is unfocused
|
|
1732
3278
|
// Useful for cleanup functions
|
|
1733
3279
|
};
|
|
1734
|
-
}, [
|
|
1735
|
-
|
|
1736
|
-
var _a, _b
|
|
1737
|
-
if (
|
|
1738
|
-
|
|
1739
|
-
|
|
1740
|
-
return uChannels || [];
|
|
1741
|
-
}, [userChannels]);
|
|
1742
|
-
// useEffect(() => {
|
|
1743
|
-
// setTimeout(() => {
|
|
1744
|
-
// dispatch({
|
|
1745
|
-
// type: CHANGE_SETTINGS_ACTION,
|
|
1746
|
-
// payload: {
|
|
1747
|
-
// footerRender: false,
|
|
1748
|
-
// },
|
|
1749
|
-
// } as any);
|
|
1750
|
-
// }, 0);
|
|
1751
|
-
// return () => {
|
|
1752
|
-
// dispatch({
|
|
1753
|
-
// type: CHANGE_SETTINGS_ACTION,
|
|
1754
|
-
// payload: {
|
|
1755
|
-
// footerRender: true,
|
|
1756
|
-
// },
|
|
1757
|
-
// } as any);
|
|
1758
|
-
// };
|
|
1759
|
-
// }, []);
|
|
1760
|
-
// useEffect(() => {
|
|
1761
|
-
// if (userChannels?.channelsByUser) {
|
|
1762
|
-
// if (userChannels?.channelsByUser?.length == 0) {
|
|
1763
|
-
// setUserDirectChannel([]);
|
|
1764
|
-
// }
|
|
1765
|
-
// //Direct channel
|
|
1766
|
-
// let userDirectChannels: any =
|
|
1767
|
-
// userChannels?.channelsByUser
|
|
1768
|
-
// ?.filter((i: any) => i.type == 'DIRECT')
|
|
1769
|
-
// ?.filter((c: any) =>
|
|
1770
|
-
// c.members.some((u: any) => u?.user?.id != auth?.id && u.user.__typename == 'UserAccount'),
|
|
1771
|
-
// ) ?? [];
|
|
1772
|
-
// if (userDirectChannels?.length > 0) setUserDirectChannel(userDirectChannels);
|
|
1773
|
-
// }
|
|
1774
|
-
// }, [userChannels?.channelsByUser]);
|
|
1775
|
-
const handleSelectChannel = (0, react_1.useCallback)((id, title) => {
|
|
1776
|
-
var _a;
|
|
1777
|
-
if (params === null || params === void 0 ? void 0 : params.channelId) {
|
|
1778
|
-
navigation.navigate(config_1.config.INBOX_MESSEGE_PATH, {
|
|
1779
|
-
channelId: params === null || params === void 0 ? void 0 : params.channelId,
|
|
1780
|
-
title: (_a = params === null || params === void 0 ? void 0 : params.title) !== null && _a !== void 0 ? _a : null,
|
|
1781
|
-
hideTabBar: true,
|
|
1782
|
-
});
|
|
1783
|
-
}
|
|
1784
|
-
else {
|
|
1785
|
-
navigation.navigate(config_1.config.INBOX_MESSEGE_PATH, {
|
|
1786
|
-
channelId: id,
|
|
1787
|
-
title: title,
|
|
1788
|
-
hideTabBar: true,
|
|
1789
|
-
});
|
|
3280
|
+
}, []));
|
|
3281
|
+
react_1.default.useEffect(() => {
|
|
3282
|
+
var _a, _b;
|
|
3283
|
+
if ((_b = (_a = data === null || data === void 0 ? void 0 : data.threadMessages) === null || _a === void 0 ? void 0 : _a.data) === null || _b === void 0 ? void 0 : _b.length) {
|
|
3284
|
+
const { data: newThreads } = data === null || data === void 0 ? void 0 : data.threadMessages;
|
|
3285
|
+
setThreadsData((oldThreads) => (0, lodash_1.uniqBy)([...oldThreads, ...newThreads], ({ id }) => id));
|
|
1790
3286
|
}
|
|
3287
|
+
}, [data]);
|
|
3288
|
+
const threads = react_1.default.useMemo(() => {
|
|
3289
|
+
if (!(threadData === null || threadData === void 0 ? void 0 : threadData.length))
|
|
3290
|
+
return null;
|
|
3291
|
+
return threadData || [];
|
|
3292
|
+
}, [threadData]);
|
|
3293
|
+
// const threads = React.useMemo(() => {
|
|
3294
|
+
// if (!data?.threadMessages?.data?.length) return null;
|
|
3295
|
+
// return data?.threadMessages?.data || [];
|
|
3296
|
+
// }, [data]);
|
|
3297
|
+
const handleSelectThread = (0, react_1.useCallback)((id, title, postParentId) => {
|
|
3298
|
+
navigation.navigate(config_1.config.THREAD_MESSEGE_PATH, {
|
|
3299
|
+
channelId: id,
|
|
3300
|
+
role: role === null || role === void 0 ? void 0 : role.toString(),
|
|
3301
|
+
title: title,
|
|
3302
|
+
postParentId: postParentId,
|
|
3303
|
+
hideTabBar: true,
|
|
3304
|
+
});
|
|
3305
|
+
// if (params?.channelId) {
|
|
3306
|
+
// navigation.navigate(config.THREAD_MESSEGE_PATH as any, {
|
|
3307
|
+
// channelId: params?.channelId,
|
|
3308
|
+
// title: params?.title ?? null,
|
|
3309
|
+
// postParentId: postParentId,
|
|
3310
|
+
// hideTabBar: true,
|
|
3311
|
+
// });
|
|
3312
|
+
// } else {
|
|
3313
|
+
// navigation.navigate(config.THREAD_MESSEGE_PATH as any, {
|
|
3314
|
+
// channelId: id,
|
|
3315
|
+
// title: title,
|
|
3316
|
+
// postParentId: postParentId,
|
|
3317
|
+
// hideTabBar: true,
|
|
3318
|
+
// });
|
|
3319
|
+
// }
|
|
1791
3320
|
}, []);
|
|
1792
3321
|
const handleRefresh = (0, react_1.useCallback)(() => {
|
|
1793
|
-
|
|
1794
|
-
|
|
3322
|
+
refetch({
|
|
3323
|
+
channelId: channelId === null || channelId === void 0 ? void 0 : channelId.toString(),
|
|
3324
|
+
role: role === null || role === void 0 ? void 0 : role.toString(),
|
|
3325
|
+
limit: MESSAGES_PER_PAGE,
|
|
3326
|
+
}).then(({ data }) => {
|
|
3327
|
+
var _a, _b, _c;
|
|
3328
|
+
if (!((_a = data === null || data === void 0 ? void 0 : data.threadMessages) === null || _a === void 0 ? void 0 : _a.data)) {
|
|
3329
|
+
return;
|
|
3330
|
+
}
|
|
3331
|
+
if ((_c = (_b = data === null || data === void 0 ? void 0 : data.threadMessages) === null || _b === void 0 ? void 0 : _b.data) === null || _c === void 0 ? void 0 : _c.length) {
|
|
3332
|
+
const { data: newThreads } = data === null || data === void 0 ? void 0 : data.threadMessages;
|
|
3333
|
+
setThreadsData((oldThreads) => (0, lodash_1.uniqBy)([...oldThreads, ...newThreads], ({ id }) => id));
|
|
3334
|
+
}
|
|
3335
|
+
});
|
|
1795
3336
|
}, []);
|
|
1796
|
-
|
|
1797
|
-
|
|
1798
|
-
|
|
1799
|
-
|
|
1800
|
-
|
|
1801
|
-
|
|
1802
|
-
|
|
3337
|
+
const fetchMoreThreads = (0, react_1.useCallback)(() => {
|
|
3338
|
+
refetch({
|
|
3339
|
+
channelId: channelId === null || channelId === void 0 ? void 0 : channelId.toString(),
|
|
3340
|
+
role: role === null || role === void 0 ? void 0 : role.toString(),
|
|
3341
|
+
skip: threads === null || threads === void 0 ? void 0 : threads.length,
|
|
3342
|
+
});
|
|
3343
|
+
}, []);
|
|
3344
|
+
return (react_1.default.createElement(native_base_1.Box, { flex: 1, p: 2, pb: 0, _dark: {
|
|
3345
|
+
borderColor: 'coolGray.600',
|
|
3346
|
+
backgroundColor: 'gray.700',
|
|
3347
|
+
}, _web: {
|
|
3348
|
+
shadow: 2,
|
|
3349
|
+
borderWidth: 0,
|
|
3350
|
+
}, _light: {
|
|
3351
|
+
backgroundColor: 'gray.50',
|
|
3352
|
+
} },
|
|
3353
|
+
react_1.default.createElement(native_base_1.FlatList, { style: { flex: 1 }, data: threads && (threads === null || threads === void 0 ? void 0 : threads.length) > 0 ? threads : [], onRefresh: handleRefresh, refreshing: threadLoading, contentContainerStyle: { paddingBottom: 60 }, ItemSeparatorComponent: () => react_1.default.createElement(native_base_1.Box, { height: "0.5", backgroundColor: "gray.200" }), renderItem: ({ item: thread }) => (react_1.default.createElement(ThreadsViewItem_1.ThreadViewItem, { onOpen: handleSelectThread, currentUser: auth, thread: thread })), ListEmptyComponent: () => (react_1.default.createElement(react_1.default.Fragment, null,
|
|
3354
|
+
!threadLoading || (threads === null || threads === void 0 ? void 0 : threads.length) == 0,
|
|
3355
|
+
react_1.default.createElement(native_base_1.Box, { p: 5 },
|
|
3356
|
+
react_1.default.createElement(native_base_1.Center, { mt: 6 },
|
|
3357
|
+
react_1.default.createElement(native_base_1.Icon, { as: vector_icons_1.Ionicons, name: "chatbubbles", size: 'xl' }),
|
|
3358
|
+
react_1.default.createElement(native_base_1.Text, null, "You don't have any message yet!"))))), keyExtractor: (item, index) => 'threads-view-key' + index, onEndReached: fetchMoreThreads, onEndReachedThreshold: 0.1 })));
|
|
1803
3359
|
};
|
|
1804
|
-
exports.
|
|
3360
|
+
exports.ThreadsView = react_1.default.memo(ThreadsViewComponent);
|
|
1805
3361
|
|
|
1806
3362
|
|
|
1807
3363
|
/***/ }),
|
|
@@ -1830,6 +3386,8 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
1830
3386
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
1831
3387
|
__exportStar(__webpack_require__(/*! ./inbox/Inbox */ "./src/screens/inbox/Inbox.tsx"), exports);
|
|
1832
3388
|
__exportStar(__webpack_require__(/*! ./inbox/DialogMessages */ "./src/screens/inbox/DialogMessages.tsx"), exports);
|
|
3389
|
+
__exportStar(__webpack_require__(/*! ./inbox/DialogThreads */ "./src/screens/inbox/DialogThreads.tsx"), exports);
|
|
3390
|
+
__exportStar(__webpack_require__(/*! ./inbox/DialogThreadMessages */ "./src/screens/inbox/DialogThreadMessages.tsx"), exports);
|
|
1833
3391
|
|
|
1834
3392
|
|
|
1835
3393
|
/***/ }),
|