@messenger-box/platform-mobile 0.0.1-alpha.310 → 0.0.1-alpha.314
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 +431 -68
- package/lib/index.js.map +1 -1
- package/lib/screens/inbox/components/SlackMessageContainer/SlackBubble.d.ts +32 -0
- package/lib/screens/inbox/components/SlackMessageContainer/SlackMessage.d.ts +23 -0
- package/lib/screens/inbox/components/SlackMessageContainer/index.d.ts +2 -0
- package/lib/screens/inbox/containers/Dialogs.d.ts +1 -2
- package/package.json +4 -4
- package/src/screens/inbox/components/DialogsListItem.tsx +109 -53
- package/src/screens/inbox/components/SlackMessageContainer/SlackBubble.tsx +242 -0
- package/src/screens/inbox/components/SlackMessageContainer/SlackMessage.tsx +115 -0
- package/src/screens/inbox/components/SlackMessageContainer/index.ts +2 -0
- package/src/screens/inbox/containers/ConversationView.tsx +32 -9
- package/src/screens/inbox/containers/Dialogs.tsx +49 -54
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,14 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
## [0.0.1-alpha.314](https://github.com/CDEBase/messenger-box/compare/v0.0.1-alpha.313...v0.0.1-alpha.314) (2023-04-03)
|
|
7
|
+
|
|
8
|
+
**Note:** Version bump only for package @messenger-box/platform-mobile
|
|
9
|
+
|
|
10
|
+
## [0.0.1-alpha.312](https://github.com/CDEBase/messenger-box/compare/v0.0.1-alpha.311...v0.0.1-alpha.312) (2023-03-29)
|
|
11
|
+
|
|
12
|
+
**Note:** Version bump only for package @messenger-box/platform-mobile
|
|
13
|
+
|
|
6
14
|
## [0.0.1-alpha.310](https://github.com/CDEBase/messenger-box/compare/v0.0.1-alpha.309...v0.0.1-alpha.310) (2023-03-25)
|
|
7
15
|
|
|
8
16
|
### Features
|
package/lib/index.js
CHANGED
|
@@ -265,6 +265,7 @@ exports.DialogsListItem = void 0;
|
|
|
265
265
|
const react_1 = __importStar(__webpack_require__(/*! react */ "react"));
|
|
266
266
|
const native_base_1 = __webpack_require__(/*! native-base */ "native-base");
|
|
267
267
|
const date_fns_1 = __webpack_require__(/*! date-fns */ "date-fns");
|
|
268
|
+
const native_1 = __webpack_require__(/*! @react-navigation/native */ "@react-navigation/native");
|
|
268
269
|
const platform_client_1 = __webpack_require__(/*! @messenger-box/platform-client */ "@messenger-box/platform-client");
|
|
269
270
|
const lodash_1 = __webpack_require__(/*! lodash */ "lodash");
|
|
270
271
|
const createdAtText = (value) => {
|
|
@@ -282,30 +283,26 @@ const createdAtText = (value) => {
|
|
|
282
283
|
* - Get Reservation info: reservation date, status
|
|
283
284
|
* - Add ability to get property information: name, logo
|
|
284
285
|
*/
|
|
285
|
-
const DialogsListItem = function DialogsListItem({ currentUser,
|
|
286
|
-
|
|
287
|
-
|
|
286
|
+
const DialogsListItem = function DialogsListItem({ currentUser,
|
|
287
|
+
// users,
|
|
288
|
+
selectedChannelId, channel, onOpen, }) {
|
|
289
|
+
var _a, _b, _c;
|
|
290
|
+
const { data: messagesQuery, loading: messageLoading, refetch: refetchMessages, } = (0, platform_client_1.useMessagesQuery)({
|
|
288
291
|
variables: {
|
|
289
292
|
channelId: (_a = channel === null || channel === void 0 ? void 0 : channel.id) === null || _a === void 0 ? void 0 : _a.toString(),
|
|
290
293
|
limit: 1,
|
|
291
294
|
},
|
|
292
295
|
fetchPolicy: 'cache-and-network',
|
|
293
296
|
});
|
|
294
|
-
|
|
297
|
+
(0, native_1.useFocusEffect)(react_1.default.useCallback(() => {
|
|
295
298
|
var _a;
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
}
|
|
303
|
-
const { data: userQuery } = (0, platform_client_1.useUserAccountQuery)({
|
|
304
|
-
variables: {
|
|
305
|
-
userId: chatUser === null || chatUser === void 0 ? void 0 : chatUser.id,
|
|
306
|
-
},
|
|
307
|
-
skip: !(chatUser === null || chatUser === void 0 ? void 0 : chatUser.id),
|
|
308
|
-
});
|
|
299
|
+
// Do something when the screen is focused
|
|
300
|
+
refetchMessages({ channelId: (_a = channel === null || channel === void 0 ? void 0 : channel.id) === null || _a === void 0 ? void 0 : _a.toString(), limit: 1 });
|
|
301
|
+
return () => {
|
|
302
|
+
// Do something when the screen is unfocused
|
|
303
|
+
// Useful for cleanup functions
|
|
304
|
+
};
|
|
305
|
+
}, []));
|
|
309
306
|
const lastMessage = (0, react_1.useMemo)(() => {
|
|
310
307
|
var _a, _b;
|
|
311
308
|
if (!((_b = (_a = messagesQuery === null || messagesQuery === void 0 ? void 0 : messagesQuery.messages) === null || _a === void 0 ? void 0 : _a.data) === null || _b === void 0 ? void 0 : _b.length)) {
|
|
@@ -314,13 +311,15 @@ const DialogsListItem = function DialogsListItem({ currentUser, users, selectedC
|
|
|
314
311
|
const { data } = messagesQuery.messages;
|
|
315
312
|
return data[data.length - 1];
|
|
316
313
|
}, [messagesQuery]);
|
|
317
|
-
const
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
314
|
+
const channelMembers = (0, react_1.useMemo)(() => {
|
|
315
|
+
var _a, _b, _c;
|
|
316
|
+
return (_c = (_b = (_a = channel === null || channel === void 0 ? void 0 : channel.members) === null || _a === void 0 ? void 0 : _a.filter((ch) => { var _a, _b; return ((_a = ch === null || ch === void 0 ? void 0 : ch.user) === null || _a === void 0 ? void 0 : _a.id) != (currentUser === null || currentUser === void 0 ? void 0 : currentUser.id) && ((_b = ch === null || ch === void 0 ? void 0 : ch.user) === null || _b === void 0 ? void 0 : _b.__typename) == 'UserAccount'; })) === null || _b === void 0 ? void 0 : _b.map((m) => m === null || m === void 0 ? void 0 : m.user)) !== null && _c !== void 0 ? _c : null;
|
|
317
|
+
}, [currentUser, channel]);
|
|
318
|
+
const title = (0, react_1.useMemo)(() => {
|
|
319
|
+
var _a, _b, _c;
|
|
320
|
+
return (_c = (_b = (_a = channelMembers === null || channelMembers === void 0 ? void 0 : channelMembers.map((u) => { var _a; return (_a = (u === null || u === void 0 ? void 0 : u.givenName) + ' ' + (u === null || u === void 0 ? void 0 : u.familyName)) !== null && _a !== void 0 ? _a : ''; })) === null || _a === void 0 ? void 0 : _a.filter((mu) => mu)) === null || _b === void 0 ? void 0 : _b.join(', ')) !== null && _c !== void 0 ? _c : '';
|
|
321
|
+
}, [channelMembers]);
|
|
322
|
+
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, title), borderWidth: '1', borderRadius: 10, borderColor: 'gray.200', flex: 1, _dark: {
|
|
324
323
|
borderColor: 'coolGray.600',
|
|
325
324
|
backgroundColor: 'gray.700',
|
|
326
325
|
}, _web: {
|
|
@@ -329,22 +328,362 @@ const DialogsListItem = function DialogsListItem({ currentUser, users, selectedC
|
|
|
329
328
|
}, _light: {
|
|
330
329
|
backgroundColor: 'gray.50',
|
|
331
330
|
} },
|
|
332
|
-
react_1.default.createElement(native_base_1.HStack
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
331
|
+
react_1.default.createElement(native_base_1.HStack
|
|
332
|
+
// px={2}
|
|
333
|
+
// pl={3}
|
|
334
|
+
, {
|
|
335
|
+
// px={2}
|
|
336
|
+
// pl={3}
|
|
337
|
+
py: 3, space: 2, w: '100%', flex: 1, direction: 'row', justifyContent: 'space-between', alignItems: 'center' },
|
|
338
|
+
react_1.default.createElement(native_base_1.Box, { flex: 0.1, alignItems: 'flex-start', pl: 3 },
|
|
339
|
+
react_1.default.createElement(native_base_1.Avatar.Group, { _avatar: {
|
|
340
|
+
size: 'sm',
|
|
341
|
+
bg: 'transparent',
|
|
342
|
+
} }, channelMembers &&
|
|
343
|
+
(channelMembers === null || channelMembers === void 0 ? void 0 : channelMembers.length) > 0 &&
|
|
344
|
+
((_b = channelMembers === null || channelMembers === void 0 ? void 0 : channelMembers.slice(0, 2)) === null || _b === void 0 ? void 0 : _b.map((ch, i) => {
|
|
345
|
+
var _a;
|
|
346
|
+
return (react_1.default.createElement(native_base_1.Avatar, { key: 'key' + i, bg: 'transparent', size: 9, top: i == 1 ? 4 : 0, right: i == 1 ? -2 : 0, zIndex: i == 1 ? 5 : 1, _image: { borderRadius: 6, borderWidth: 2, borderColor: '#fff' }, source: {
|
|
347
|
+
uri: ch === null || ch === void 0 ? void 0 : ch.picture,
|
|
348
|
+
} },
|
|
349
|
+
(0, lodash_1.startCase)((_a = ch === null || ch === void 0 ? void 0 : ch.username) === null || _a === void 0 ? void 0 : _a.charAt(0)),
|
|
350
|
+
(channelMembers === null || channelMembers === void 0 ? void 0 : channelMembers.length) == 1 && (react_1.default.createElement(native_base_1.Avatar.Badge, { bg: "green.800", bottom: -4, right: -4 }))));
|
|
351
|
+
})))),
|
|
352
|
+
react_1.default.createElement(native_base_1.Box, { flex: 0.9 },
|
|
353
|
+
react_1.default.createElement(native_base_1.HStack, { space: 1, flex: 1, direction: 'row', justifyContent: 'center', alignItems: 'center' },
|
|
354
|
+
react_1.default.createElement(native_base_1.Box, { flex: 0.8 },
|
|
355
|
+
react_1.default.createElement(native_base_1.Text, { color: "gray.600", fontSize: "lg", flexWrap: 'wrap', fontWeight: "semibold" }, title),
|
|
356
|
+
react_1.default.createElement(native_base_1.Text, { color: "gray.600", noOfLines: 1 }, (_c = lastMessage === null || lastMessage === void 0 ? void 0 : lastMessage.message) !== null && _c !== void 0 ? _c : '')),
|
|
357
|
+
react_1.default.createElement(native_base_1.Box, { flex: 0.2 },
|
|
358
|
+
react_1.default.createElement(native_base_1.Text, { color: "gray.500" }, lastMessage ? createdAtText(lastMessage === null || lastMessage === void 0 ? void 0 : lastMessage.createdAt) : '')))))));
|
|
344
359
|
};
|
|
345
360
|
exports.DialogsListItem = DialogsListItem;
|
|
346
361
|
|
|
347
362
|
|
|
363
|
+
/***/ }),
|
|
364
|
+
|
|
365
|
+
/***/ "./src/screens/inbox/components/SlackMessageContainer/SlackBubble.tsx":
|
|
366
|
+
/*!****************************************************************************!*\
|
|
367
|
+
!*** ./src/screens/inbox/components/SlackMessageContainer/SlackBubble.tsx ***!
|
|
368
|
+
\****************************************************************************/
|
|
369
|
+
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {
|
|
370
|
+
|
|
371
|
+
|
|
372
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
373
|
+
var t = {};
|
|
374
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
375
|
+
t[p] = s[p];
|
|
376
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
377
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
378
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
379
|
+
t[p[i]] = s[p[i]];
|
|
380
|
+
}
|
|
381
|
+
return t;
|
|
382
|
+
};
|
|
383
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
384
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
385
|
+
};
|
|
386
|
+
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
387
|
+
/* eslint-disable no-underscore-dangle, no-use-before-define */
|
|
388
|
+
const react_1 = __importDefault(__webpack_require__(/*! react */ "react"));
|
|
389
|
+
const react_native_1 = __webpack_require__(/*! react-native */ "react-native");
|
|
390
|
+
const react_native_gifted_chat_1 = __webpack_require__(/*! react-native-gifted-chat */ "react-native-gifted-chat");
|
|
391
|
+
const { isSameUser, isSameDay } = react_native_gifted_chat_1.utils;
|
|
392
|
+
class Bubble extends react_1.default.Component {
|
|
393
|
+
constructor(props) {
|
|
394
|
+
super(props);
|
|
395
|
+
}
|
|
396
|
+
renderMessageText() {
|
|
397
|
+
if (this.props.currentMessage.text) {
|
|
398
|
+
const _a = this.props, { containerStyle, wrapperStyle, messageTextStyle } = _a, messageTextProps = __rest(_a, ["containerStyle", "wrapperStyle", "messageTextStyle"]);
|
|
399
|
+
if (this.props.renderMessageText) {
|
|
400
|
+
return this.props.renderMessageText(messageTextProps);
|
|
401
|
+
}
|
|
402
|
+
return (react_1.default.createElement(react_native_gifted_chat_1.MessageText, Object.assign({}, messageTextProps, { textStyle: {
|
|
403
|
+
left: [
|
|
404
|
+
styles.standardFont,
|
|
405
|
+
styles.slackMessageText,
|
|
406
|
+
messageTextProps.textStyle,
|
|
407
|
+
messageTextStyle,
|
|
408
|
+
],
|
|
409
|
+
} })));
|
|
410
|
+
}
|
|
411
|
+
return null;
|
|
412
|
+
}
|
|
413
|
+
renderMessageImage() {
|
|
414
|
+
if (this.props.currentMessage.image) {
|
|
415
|
+
const _a = this.props, { containerStyle, wrapperStyle } = _a, messageImageProps = __rest(_a, ["containerStyle", "wrapperStyle"]);
|
|
416
|
+
if (this.props.renderMessageImage) {
|
|
417
|
+
return this.props.renderMessageImage(messageImageProps);
|
|
418
|
+
}
|
|
419
|
+
return (react_1.default.createElement(react_native_gifted_chat_1.MessageImage, Object.assign({}, messageImageProps, { imageStyle: [styles.slackImage, messageImageProps.imageStyle] })));
|
|
420
|
+
}
|
|
421
|
+
return null;
|
|
422
|
+
}
|
|
423
|
+
renderTicks() {
|
|
424
|
+
const { currentMessage } = this.props;
|
|
425
|
+
if (this.props.renderTicks) {
|
|
426
|
+
return this.props.renderTicks(currentMessage);
|
|
427
|
+
}
|
|
428
|
+
if (currentMessage.user._id !== this.props.user._id) {
|
|
429
|
+
return null;
|
|
430
|
+
}
|
|
431
|
+
if (currentMessage.sent || currentMessage.received) {
|
|
432
|
+
return (react_1.default.createElement(react_native_1.View, { style: [styles.headerItem, styles.tickView] },
|
|
433
|
+
currentMessage.sent && (react_1.default.createElement(react_native_1.Text, { style: [styles.standardFont, styles.tick, this.props.tickStyle] }, "\u2713")),
|
|
434
|
+
currentMessage.received && (react_1.default.createElement(react_native_1.Text, { style: [styles.standardFont, styles.tick, this.props.tickStyle] }, "\u2713"))));
|
|
435
|
+
}
|
|
436
|
+
return null;
|
|
437
|
+
}
|
|
438
|
+
renderUsername() {
|
|
439
|
+
const username = this.props.currentMessage.user.name;
|
|
440
|
+
if (username) {
|
|
441
|
+
const _a = this.props, { containerStyle, wrapperStyle } = _a, usernameProps = __rest(_a, ["containerStyle", "wrapperStyle"]);
|
|
442
|
+
if (this.props.renderUsername) {
|
|
443
|
+
return this.props.renderUsername(usernameProps);
|
|
444
|
+
}
|
|
445
|
+
return (react_1.default.createElement(react_native_1.Text, { style: [styles.standardFont, styles.headerItem, styles.username, this.props.usernameStyle] }, username));
|
|
446
|
+
}
|
|
447
|
+
return null;
|
|
448
|
+
}
|
|
449
|
+
renderTime() {
|
|
450
|
+
if (this.props.currentMessage.createdAt) {
|
|
451
|
+
const _a = this.props, { containerStyle, wrapperStyle } = _a, timeProps = __rest(_a, ["containerStyle", "wrapperStyle"]);
|
|
452
|
+
if (this.props.renderTime) {
|
|
453
|
+
return this.props.renderTime(timeProps);
|
|
454
|
+
}
|
|
455
|
+
return (react_1.default.createElement(react_native_gifted_chat_1.Time, Object.assign({}, timeProps, { containerStyle: { left: [styles.timeContainer] }, textStyle: {
|
|
456
|
+
left: [styles.standardFont, styles.headerItem, styles.time, timeProps.textStyle],
|
|
457
|
+
} })));
|
|
458
|
+
}
|
|
459
|
+
return null;
|
|
460
|
+
}
|
|
461
|
+
renderCustomView() {
|
|
462
|
+
if (this.props.renderCustomView) {
|
|
463
|
+
return this.props.renderCustomView(this.props);
|
|
464
|
+
}
|
|
465
|
+
return null;
|
|
466
|
+
}
|
|
467
|
+
render() {
|
|
468
|
+
const isSameThread = isSameUser(this.props.currentMessage, this.props.previousMessage) &&
|
|
469
|
+
isSameDay(this.props.currentMessage, this.props.previousMessage);
|
|
470
|
+
const messageHeader = isSameThread ? null : (react_1.default.createElement(react_native_1.View, { style: styles.headerView },
|
|
471
|
+
this.renderUsername(),
|
|
472
|
+
this.renderTime(),
|
|
473
|
+
this.renderTicks()));
|
|
474
|
+
return (react_1.default.createElement(react_native_1.View, { style: [styles.container, this.props.containerStyle] },
|
|
475
|
+
react_1.default.createElement(react_native_1.TouchableOpacity, Object.assign({ disabled: true, accessibilityTraits: "text" }, this.props.touchableProps),
|
|
476
|
+
react_1.default.createElement(react_native_1.View, { style: [styles.wrapper, this.props.wrapperStyle] },
|
|
477
|
+
react_1.default.createElement(react_native_1.View, null,
|
|
478
|
+
this.renderCustomView(),
|
|
479
|
+
messageHeader,
|
|
480
|
+
this.renderMessageImage(),
|
|
481
|
+
this.renderMessageText())))));
|
|
482
|
+
}
|
|
483
|
+
}
|
|
484
|
+
exports["default"] = Bubble;
|
|
485
|
+
// Note: Everything is forced to be "left" positioned with this component.
|
|
486
|
+
// The "right" position is only used in the default Bubble.
|
|
487
|
+
const styles = react_native_1.StyleSheet.create({
|
|
488
|
+
standardFont: {
|
|
489
|
+
fontSize: 15,
|
|
490
|
+
},
|
|
491
|
+
slackMessageText: {
|
|
492
|
+
marginLeft: 0,
|
|
493
|
+
marginRight: 0,
|
|
494
|
+
},
|
|
495
|
+
container: {
|
|
496
|
+
flex: 1,
|
|
497
|
+
alignItems: 'flex-start',
|
|
498
|
+
},
|
|
499
|
+
wrapper: {
|
|
500
|
+
marginRight: 60,
|
|
501
|
+
minHeight: 20,
|
|
502
|
+
justifyContent: 'flex-end',
|
|
503
|
+
},
|
|
504
|
+
username: {
|
|
505
|
+
fontWeight: 'bold',
|
|
506
|
+
top: 4,
|
|
507
|
+
},
|
|
508
|
+
time: {
|
|
509
|
+
textAlign: 'left',
|
|
510
|
+
fontSize: 12,
|
|
511
|
+
},
|
|
512
|
+
timeContainer: {
|
|
513
|
+
marginLeft: 0,
|
|
514
|
+
marginRight: 0,
|
|
515
|
+
marginBottom: 0,
|
|
516
|
+
},
|
|
517
|
+
headerItem: {
|
|
518
|
+
marginRight: 10,
|
|
519
|
+
},
|
|
520
|
+
headerView: {
|
|
521
|
+
// Try to align it better with the avatar on Android.
|
|
522
|
+
marginTop: react_native_1.Platform.OS === 'android' ? -2 : 0,
|
|
523
|
+
flexDirection: 'row',
|
|
524
|
+
alignItems: 'baseline',
|
|
525
|
+
},
|
|
526
|
+
/* eslint-disable react-native/no-color-literals */
|
|
527
|
+
tick: {
|
|
528
|
+
backgroundColor: 'transparent',
|
|
529
|
+
color: 'white',
|
|
530
|
+
},
|
|
531
|
+
/* eslint-enable react-native/no-color-literals */
|
|
532
|
+
tickView: {
|
|
533
|
+
flexDirection: 'row',
|
|
534
|
+
},
|
|
535
|
+
slackImage: {
|
|
536
|
+
borderRadius: 3,
|
|
537
|
+
marginLeft: 0,
|
|
538
|
+
marginRight: 0,
|
|
539
|
+
},
|
|
540
|
+
});
|
|
541
|
+
// Bubble.contextTypes = {
|
|
542
|
+
// actionSheet: PropTypes.func,
|
|
543
|
+
// };
|
|
544
|
+
Bubble.defaultProps = {
|
|
545
|
+
touchableProps: {},
|
|
546
|
+
onLongPress: null,
|
|
547
|
+
renderMessageImage: null,
|
|
548
|
+
renderMessageText: null,
|
|
549
|
+
renderCustomView: null,
|
|
550
|
+
renderTime: null,
|
|
551
|
+
currentMessage: {
|
|
552
|
+
text: null,
|
|
553
|
+
createdAt: null,
|
|
554
|
+
image: null,
|
|
555
|
+
},
|
|
556
|
+
nextMessage: {},
|
|
557
|
+
previousMessage: {},
|
|
558
|
+
containerStyle: {},
|
|
559
|
+
wrapperStyle: {},
|
|
560
|
+
tickStyle: {},
|
|
561
|
+
containerToNextStyle: {},
|
|
562
|
+
containerToPreviousStyle: {},
|
|
563
|
+
};
|
|
564
|
+
|
|
565
|
+
|
|
566
|
+
/***/ }),
|
|
567
|
+
|
|
568
|
+
/***/ "./src/screens/inbox/components/SlackMessageContainer/SlackMessage.tsx":
|
|
569
|
+
/*!*****************************************************************************!*\
|
|
570
|
+
!*** ./src/screens/inbox/components/SlackMessageContainer/SlackMessage.tsx ***!
|
|
571
|
+
\*****************************************************************************/
|
|
572
|
+
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {
|
|
573
|
+
|
|
574
|
+
|
|
575
|
+
/* eslint-disable no-underscore-dangle, no-use-before-define */
|
|
576
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
577
|
+
var t = {};
|
|
578
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
579
|
+
t[p] = s[p];
|
|
580
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
581
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
582
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
583
|
+
t[p[i]] = s[p[i]];
|
|
584
|
+
}
|
|
585
|
+
return t;
|
|
586
|
+
};
|
|
587
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
588
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
589
|
+
};
|
|
590
|
+
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
591
|
+
const react_1 = __importDefault(__webpack_require__(/*! react */ "react"));
|
|
592
|
+
const react_native_1 = __webpack_require__(/*! react-native */ "react-native");
|
|
593
|
+
const react_native_gifted_chat_1 = __webpack_require__(/*! react-native-gifted-chat */ "react-native-gifted-chat");
|
|
594
|
+
const SlackBubble_1 = __importDefault(__webpack_require__(/*! ./SlackBubble */ "./src/screens/inbox/components/SlackMessageContainer/SlackBubble.tsx"));
|
|
595
|
+
const { isSameUser, isSameDay } = react_native_gifted_chat_1.utils;
|
|
596
|
+
class Message extends react_1.default.Component {
|
|
597
|
+
getInnerComponentProps() {
|
|
598
|
+
const _a = this.props, { containerStyle } = _a, props = __rest(_a, ["containerStyle"]);
|
|
599
|
+
return Object.assign(Object.assign({}, props), { position: 'left', isSameUser,
|
|
600
|
+
isSameDay });
|
|
601
|
+
}
|
|
602
|
+
renderDay() {
|
|
603
|
+
if (this.props.currentMessage.createdAt) {
|
|
604
|
+
const dayProps = this.getInnerComponentProps();
|
|
605
|
+
if (this.props.renderDay) {
|
|
606
|
+
return this.props.renderDay(dayProps);
|
|
607
|
+
}
|
|
608
|
+
return react_1.default.createElement(react_native_gifted_chat_1.Day, Object.assign({}, dayProps));
|
|
609
|
+
}
|
|
610
|
+
return null;
|
|
611
|
+
}
|
|
612
|
+
renderBubble() {
|
|
613
|
+
const bubbleProps = this.getInnerComponentProps();
|
|
614
|
+
if (this.props.renderBubble) {
|
|
615
|
+
return this.props.renderBubble(bubbleProps);
|
|
616
|
+
}
|
|
617
|
+
return react_1.default.createElement(SlackBubble_1.default, Object.assign({}, bubbleProps));
|
|
618
|
+
}
|
|
619
|
+
renderAvatar() {
|
|
620
|
+
let extraStyle;
|
|
621
|
+
if (isSameUser(this.props.currentMessage, this.props.previousMessage) &&
|
|
622
|
+
isSameDay(this.props.currentMessage, this.props.previousMessage)) {
|
|
623
|
+
// Set the invisible avatar height to 0, but keep the width, padding, etc.
|
|
624
|
+
extraStyle = { height: 0 };
|
|
625
|
+
}
|
|
626
|
+
const avatarProps = this.getInnerComponentProps();
|
|
627
|
+
return (react_1.default.createElement(react_native_gifted_chat_1.Avatar, Object.assign({}, avatarProps, { showAvatarForEveryMessage: true, imageStyle: {
|
|
628
|
+
left: [styles.slackAvatar, avatarProps.imageStyle, extraStyle],
|
|
629
|
+
} })));
|
|
630
|
+
}
|
|
631
|
+
render() {
|
|
632
|
+
const marginBottom = isSameUser(this.props.currentMessage, this.props.nextMessage) ? 2 : 10;
|
|
633
|
+
return (react_1.default.createElement(react_native_1.View, null,
|
|
634
|
+
this.renderDay(),
|
|
635
|
+
react_1.default.createElement(react_native_1.View, { style: [styles.container, { marginBottom }, this.props.containerStyle] },
|
|
636
|
+
this.renderAvatar(),
|
|
637
|
+
this.renderBubble())));
|
|
638
|
+
}
|
|
639
|
+
}
|
|
640
|
+
exports["default"] = Message;
|
|
641
|
+
const styles = react_native_1.StyleSheet.create({
|
|
642
|
+
container: {
|
|
643
|
+
flexDirection: 'row',
|
|
644
|
+
alignItems: 'flex-end',
|
|
645
|
+
justifyContent: 'flex-start',
|
|
646
|
+
marginLeft: 8,
|
|
647
|
+
marginRight: 0,
|
|
648
|
+
},
|
|
649
|
+
slackAvatar: {
|
|
650
|
+
// The bottom should roughly line up with the first line of message text.
|
|
651
|
+
height: 40,
|
|
652
|
+
width: 40,
|
|
653
|
+
borderRadius: 3,
|
|
654
|
+
marginTop: 0,
|
|
655
|
+
},
|
|
656
|
+
});
|
|
657
|
+
Message.defaultProps = {
|
|
658
|
+
renderAvatar: undefined,
|
|
659
|
+
renderBubble: null,
|
|
660
|
+
renderDay: null,
|
|
661
|
+
currentMessage: {},
|
|
662
|
+
nextMessage: {},
|
|
663
|
+
previousMessage: {},
|
|
664
|
+
user: {},
|
|
665
|
+
containerStyle: {},
|
|
666
|
+
};
|
|
667
|
+
|
|
668
|
+
|
|
669
|
+
/***/ }),
|
|
670
|
+
|
|
671
|
+
/***/ "./src/screens/inbox/components/SlackMessageContainer/index.ts":
|
|
672
|
+
/*!*********************************************************************!*\
|
|
673
|
+
!*** ./src/screens/inbox/components/SlackMessageContainer/index.ts ***!
|
|
674
|
+
\*********************************************************************/
|
|
675
|
+
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {
|
|
676
|
+
|
|
677
|
+
|
|
678
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
679
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
680
|
+
};
|
|
681
|
+
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
682
|
+
exports.SlackMessage = void 0;
|
|
683
|
+
const SlackMessage_1 = __importDefault(__webpack_require__(/*! ./SlackMessage */ "./src/screens/inbox/components/SlackMessageContainer/SlackMessage.tsx"));
|
|
684
|
+
exports.SlackMessage = SlackMessage_1.default;
|
|
685
|
+
|
|
686
|
+
|
|
348
687
|
/***/ }),
|
|
349
688
|
|
|
350
689
|
/***/ "./src/screens/inbox/config/config.ts":
|
|
@@ -425,6 +764,7 @@ const react_native_gifted_chat_1 = __webpack_require__(/*! react-native-gifted-c
|
|
|
425
764
|
const platform_client_1 = __webpack_require__(/*! @messenger-box/platform-client */ "@messenger-box/platform-client");
|
|
426
765
|
const config_1 = __webpack_require__(/*! ../config */ "./src/screens/inbox/config/index.ts");
|
|
427
766
|
const user_auth0_client_1 = __webpack_require__(/*! @adminide-stack/user-auth0-client */ "@adminide-stack/user-auth0-client");
|
|
767
|
+
const SlackMessageContainer_1 = __webpack_require__(/*! ../components/SlackMessageContainer */ "./src/screens/inbox/components/SlackMessageContainer/index.ts");
|
|
428
768
|
const { MESSAGES_PER_PAGE } = config_1.config;
|
|
429
769
|
function ConversationView({ channelId }) {
|
|
430
770
|
var _a;
|
|
@@ -483,12 +823,12 @@ function ConversationView({ channelId }) {
|
|
|
483
823
|
(0, react_1.useEffect)(() => {
|
|
484
824
|
var _a;
|
|
485
825
|
if (((_a = data === null || data === void 0 ? void 0 : data.messages) === null || _a === void 0 ? void 0 : _a.data) && (loadingOldMessages || channelMessages.length === 0)) {
|
|
486
|
-
const { data: messages, totalCount } = data.messages;
|
|
487
|
-
if (messages && messages.length > 0) {
|
|
826
|
+
const { data: messages, totalCount: messeageTotalCount } = data.messages;
|
|
827
|
+
if (messages && messages.length > 0 && totalCount !== messeageTotalCount) {
|
|
488
828
|
setChannelMessages((oldMessages) => (0, lodash_1.uniqBy)([...messages, ...oldMessages], ({ id }) => id));
|
|
489
829
|
}
|
|
490
|
-
if (totalCount)
|
|
491
|
-
setTotalCount(
|
|
830
|
+
if (totalCount !== messeageTotalCount)
|
|
831
|
+
setTotalCount(messeageTotalCount);
|
|
492
832
|
}
|
|
493
833
|
}, [data, loadingOldMessages, channelMessages]);
|
|
494
834
|
(0, react_1.useEffect)(() => {
|
|
@@ -656,7 +996,7 @@ function ConversationView({ channelId }) {
|
|
|
656
996
|
message.createdAt = date;
|
|
657
997
|
(message.user = {
|
|
658
998
|
_id: msg.author.id,
|
|
659
|
-
name: msg.author.givenName + msg.author.familyName,
|
|
999
|
+
name: msg.author.givenName + ' ' + msg.author.familyName,
|
|
660
1000
|
avatar: (_a = msg.author) === null || _a === void 0 ? void 0 : _a.picture,
|
|
661
1001
|
}),
|
|
662
1002
|
(message.image = (_c = (_b = msg.files) === null || _b === void 0 ? void 0 : _b.data[0]) === null || _c === void 0 ? void 0 : _c.url),
|
|
@@ -688,10 +1028,10 @@ function ConversationView({ channelId }) {
|
|
|
688
1028
|
return (react_1.default.createElement(native_base_1.Box, null,
|
|
689
1029
|
(attachment === null || attachment === void 0 ? void 0 : attachment.callToAction) ? (react_1.default.createElement(native_base_1.Button, { variant: 'outline', size: 'sm', borderColor: color, onPress: () => navigation.navigate(action, { reservationId: actionId }) },
|
|
690
1030
|
react_1.default.createElement(native_base_1.Text, { color: color }, attachment.callToAction.title))) : null,
|
|
691
|
-
react_1.default.createElement(react_native_gifted_chat_1.MessageText, Object.assign({}, props))));
|
|
1031
|
+
react_1.default.createElement(react_native_gifted_chat_1.MessageText, Object.assign({}, props, { textStyle: { left: { marginLeft: 5 } } }))));
|
|
692
1032
|
}
|
|
693
1033
|
else {
|
|
694
|
-
return react_1.default.createElement(react_native_gifted_chat_1.MessageText, Object.assign({}, props));
|
|
1034
|
+
return react_1.default.createElement(react_native_gifted_chat_1.MessageText, Object.assign({}, props, { textStyle: { left: { marginLeft: 5 } } }));
|
|
695
1035
|
}
|
|
696
1036
|
};
|
|
697
1037
|
const renderActions = (props) => {
|
|
@@ -706,12 +1046,30 @@ function ConversationView({ channelId }) {
|
|
|
706
1046
|
setImages([]);
|
|
707
1047
|
} }, "Cancel"))) : null));
|
|
708
1048
|
};
|
|
1049
|
+
const renderMessage = (props) => {
|
|
1050
|
+
// const {
|
|
1051
|
+
// currentMessage: { text: currText },
|
|
1052
|
+
// } = props;
|
|
1053
|
+
//let messageTextStyle: any;
|
|
1054
|
+
// Make "pure emoji" messages much bigger than plain text.
|
|
1055
|
+
// if (currText && emojiUtils.isPureEmojiString(currText)) {
|
|
1056
|
+
// messageTextStyle = {
|
|
1057
|
+
// fontSize: 28,
|
|
1058
|
+
// // Emoji get clipped if lineHeight isn't increased; make it consistent across platforms.
|
|
1059
|
+
// lineHeight: Platform.OS === 'android' ? 34 : 30,
|
|
1060
|
+
// }
|
|
1061
|
+
// }
|
|
1062
|
+
// return <SlackMessage {...props} messageTextStyle={messageTextStyle} />;
|
|
1063
|
+
return react_1.default.createElement(SlackMessageContainer_1.SlackMessage, Object.assign({}, props));
|
|
1064
|
+
};
|
|
709
1065
|
return (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) => {
|
|
710
1066
|
var _a, _b;
|
|
711
1067
|
handleSend((_b = (_a = messages[0]) === null || _a === void 0 ? void 0 : _a.text) !== null && _b !== void 0 ? _b : ' ');
|
|
712
1068
|
}, 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: {
|
|
713
1069
|
_id: (currentUser === null || currentUser === void 0 ? void 0 : currentUser.id) || '',
|
|
714
|
-
}, isTyping: true, alwaysShowSend: loading ? false : true, onLoadEarlier: onFetchOld, infiniteScroll: true, renderSend: renderSend, loadEarlier:
|
|
1070
|
+
}, isTyping: true, alwaysShowSend: loading ? false : true, onLoadEarlier: onFetchOld, infiniteScroll: true, renderSend: renderSend, loadEarlier: ((_a = checkForMessages === null || checkForMessages === void 0 ? void 0 : checkForMessages.messages) === null || _a === void 0 ? void 0 : _a.totalCount) > totalCount,
|
|
1071
|
+
// loadEarlier={channelMessages.length !== data?.messages?.totalCount}
|
|
1072
|
+
renderMessageText: renderMessageText, minInputToolbarHeight: 50, renderActions: renderActions, renderAccessory: renderAccessory, renderMessage: renderMessage }));
|
|
715
1073
|
}
|
|
716
1074
|
exports.ConversationView = ConversationView;
|
|
717
1075
|
|
|
@@ -760,8 +1118,7 @@ const platform_client_1 = __webpack_require__(/*! @messenger-box/platform-client
|
|
|
760
1118
|
const user_auth0_client_1 = __webpack_require__(/*! @adminide-stack/user-auth0-client */ "@adminide-stack/user-auth0-client");
|
|
761
1119
|
const client_1 = __webpack_require__(/*! @admin-layout/client */ "@admin-layout/client");
|
|
762
1120
|
const config_1 = __webpack_require__(/*! ../config */ "./src/screens/inbox/config/index.ts");
|
|
763
|
-
|
|
764
|
-
var _a;
|
|
1121
|
+
const Dialogs = (props) => {
|
|
765
1122
|
const { channelFilters, channelRole } = props;
|
|
766
1123
|
const { params } = (0, native_1.useRoute)();
|
|
767
1124
|
const auth = (0, react_redux_1.useSelector)(user_auth0_client_1.userSelector);
|
|
@@ -775,11 +1132,14 @@ function Dialogs(props) {
|
|
|
775
1132
|
criteria: channelFilters,
|
|
776
1133
|
},
|
|
777
1134
|
});
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
1135
|
+
(0, native_1.useFocusEffect)(react_1.default.useCallback(() => {
|
|
1136
|
+
// Do something when the screen is focused
|
|
1137
|
+
getChannelsRefetch({ role: channelRole, criteria: channelFilters });
|
|
1138
|
+
return () => {
|
|
1139
|
+
// Do something when the screen is unfocused
|
|
1140
|
+
// Useful for cleanup functions
|
|
1141
|
+
};
|
|
1142
|
+
}, [channelFilters]));
|
|
783
1143
|
(0, react_1.useEffect)(() => {
|
|
784
1144
|
setTimeout(() => {
|
|
785
1145
|
dispatch({
|
|
@@ -801,8 +1161,8 @@ function Dialogs(props) {
|
|
|
801
1161
|
(0, react_1.useEffect)(() => {
|
|
802
1162
|
var _a, _b, _c;
|
|
803
1163
|
if (userChannels === null || userChannels === void 0 ? void 0 : userChannels.channelsByUser) {
|
|
804
|
-
//Direct channel
|
|
805
|
-
let userDirectChannels = (_c = (_b = (_a = userChannels === null || userChannels === void 0 ? void 0 : userChannels.channelsByUser) === null || _a === void 0 ? void 0 : _a.filter((i) => i.type == 'DIRECT')) === null || _b === void 0 ? void 0 : _b.filter((c) => c.members.some((u) => u.user.__typename == 'UserAccount'))) !== null && _c !== void 0 ? _c : [];
|
|
1164
|
+
//Direct channel
|
|
1165
|
+
let userDirectChannels = (_c = (_b = (_a = userChannels === null || userChannels === void 0 ? void 0 : userChannels.channelsByUser) === null || _a === void 0 ? void 0 : _a.filter((i) => i.type == 'DIRECT')) === 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 : [];
|
|
806
1166
|
if ((userDirectChannels === null || userDirectChannels === void 0 ? void 0 : userDirectChannels.length) > 0)
|
|
807
1167
|
setUserDirectChannel(userDirectChannels);
|
|
808
1168
|
}
|
|
@@ -824,21 +1184,14 @@ function Dialogs(props) {
|
|
|
824
1184
|
});
|
|
825
1185
|
}
|
|
826
1186
|
}, []);
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
react_1.default.createElement(native_base_1.Text, null, "You don't have any messages yet!")))) : (react_1.default.createElement(react_1.default.Fragment, null,
|
|
836
|
-
react_1.default.createElement(native_base_1.FlatList
|
|
837
|
-
// data={userChannels?.channelsByUser?.filter((i:any)=>i.type=='DIRECT')??[]}
|
|
838
|
-
, {
|
|
839
|
-
// data={userChannels?.channelsByUser?.filter((i:any)=>i.type=='DIRECT')??[]}
|
|
840
|
-
data: (userDirectChannel === null || userDirectChannel === void 0 ? void 0 : userDirectChannel.length) > 0 ? userDirectChannel : [], onRefresh: getChannelsRefetch, 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, { users: users === null || users === void 0 ? void 0 : users.getUsers, onOpen: handleSelectChannel, currentUser: currentUser, channel: channel, selectedChannelId: params === null || params === void 0 ? void 0 : params.channelId })) })))));
|
|
841
|
-
}
|
|
1187
|
+
return (react_1.default.createElement(native_base_1.Box, { p: 2 },
|
|
1188
|
+
react_1.default.createElement(native_base_1.FlatList, { data: (userDirectChannel === null || userDirectChannel === void 0 ? void 0 : userDirectChannel.length) > 0 ? userDirectChannel : [], onRefresh: getChannelsRefetch, 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(native_base_1.Box, { p: 5 },
|
|
1189
|
+
react_1.default.createElement(native_base_1.Heading, null, "Chat"),
|
|
1190
|
+
react_1.default.createElement(native_base_1.Input, { height: 50, mt: 3, placeholder: "Search", borderRadius: 50, borderColor: 'gray.200', borderWidth: 2 }),
|
|
1191
|
+
react_1.default.createElement(native_base_1.Center, { mt: 6 },
|
|
1192
|
+
react_1.default.createElement(native_base_1.Icon, { as: vector_icons_1.Ionicons, name: "chatbubbles", size: 'xl' }),
|
|
1193
|
+
react_1.default.createElement(native_base_1.Text, null, "You don't have any messages yet!")))), keyExtractor: (item, index) => 'key' + index })));
|
|
1194
|
+
};
|
|
842
1195
|
exports.Dialogs = Dialogs;
|
|
843
1196
|
|
|
844
1197
|
|
|
@@ -1002,6 +1355,16 @@ module.exports = require("react");
|
|
|
1002
1355
|
|
|
1003
1356
|
/***/ }),
|
|
1004
1357
|
|
|
1358
|
+
/***/ "react-native":
|
|
1359
|
+
/*!*******************************!*\
|
|
1360
|
+
!*** external "react-native" ***!
|
|
1361
|
+
\*******************************/
|
|
1362
|
+
/***/ ((module) => {
|
|
1363
|
+
|
|
1364
|
+
module.exports = require("react-native");
|
|
1365
|
+
|
|
1366
|
+
/***/ }),
|
|
1367
|
+
|
|
1005
1368
|
/***/ "react-native-gifted-chat":
|
|
1006
1369
|
/*!*******************************************!*\
|
|
1007
1370
|
!*** external "react-native-gifted-chat" ***!
|