@messenger-box/platform-mobile 0.0.1-alpha.338 → 0.0.1-alpha.341
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 +287 -63
- package/lib/index.js.map +1 -1
- package/lib/screens/inbox/components/CachedImage/consts.d.ts +2 -0
- package/lib/screens/inbox/components/CachedImage/index.d.ts +8 -0
- package/package.json +2 -2
- package/src/screens/inbox/components/CachedImage/consts.ts +5 -0
- package/src/screens/inbox/components/CachedImage/index.tsx +103 -0
- package/src/screens/inbox/components/SlackMessageContainer/SlackBubble.tsx +34 -7
- package/src/screens/inbox/containers/ConversationView.tsx +59 -21
- package/src/screens/inbox/containers/Dialogs.tsx +78 -50
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.341](https://github.com/CDEBase/messenger-box/compare/v0.0.1-alpha.340...v0.0.1-alpha.341) (2023-05-08)
|
|
7
|
+
|
|
8
|
+
**Note:** Version bump only for package @messenger-box/platform-mobile
|
|
9
|
+
|
|
10
|
+
## [0.0.1-alpha.340](https://github.com/CDEBase/messenger-box/compare/v0.0.1-alpha.339...v0.0.1-alpha.340) (2023-05-07)
|
|
11
|
+
|
|
12
|
+
**Note:** Version bump only for package @messenger-box/platform-mobile
|
|
13
|
+
|
|
6
14
|
## [0.0.1-alpha.338](https://github.com/CDEBase/messenger-box/compare/v0.0.1-alpha.337...v0.0.1-alpha.338) (2023-04-19)
|
|
7
15
|
|
|
8
16
|
**Note:** Version bump only for package @messenger-box/platform-mobile
|
package/lib/index.js
CHANGED
|
@@ -233,6 +233,164 @@ const Inbox = (props) => {
|
|
|
233
233
|
exports.Inbox = Inbox;
|
|
234
234
|
|
|
235
235
|
|
|
236
|
+
/***/ }),
|
|
237
|
+
|
|
238
|
+
/***/ "./src/screens/inbox/components/CachedImage/consts.ts":
|
|
239
|
+
/*!************************************************************!*\
|
|
240
|
+
!*** ./src/screens/inbox/components/CachedImage/consts.ts ***!
|
|
241
|
+
\************************************************************/
|
|
242
|
+
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {
|
|
243
|
+
|
|
244
|
+
|
|
245
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
246
|
+
if (k2 === undefined) k2 = k;
|
|
247
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
248
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
249
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
250
|
+
}
|
|
251
|
+
Object.defineProperty(o, k2, desc);
|
|
252
|
+
}) : (function(o, m, k, k2) {
|
|
253
|
+
if (k2 === undefined) k2 = k;
|
|
254
|
+
o[k2] = m[k];
|
|
255
|
+
}));
|
|
256
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
257
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
258
|
+
}) : function(o, v) {
|
|
259
|
+
o["default"] = v;
|
|
260
|
+
});
|
|
261
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
262
|
+
if (mod && mod.__esModule) return mod;
|
|
263
|
+
var result = {};
|
|
264
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
265
|
+
__setModuleDefault(result, mod);
|
|
266
|
+
return result;
|
|
267
|
+
};
|
|
268
|
+
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
269
|
+
exports.IMAGE_CACHE_FOLDER = void 0;
|
|
270
|
+
const FileSystem = __importStar(__webpack_require__(/*! expo-file-system */ "expo-file-system"));
|
|
271
|
+
exports.IMAGE_CACHE_FOLDER = `${FileSystem.cacheDirectory}`;
|
|
272
|
+
// export const IMAGE_CACHE_FOLDER = `${FileSystem.documentDirectory}images/`
|
|
273
|
+
exports["default"] = exports.IMAGE_CACHE_FOLDER;
|
|
274
|
+
|
|
275
|
+
|
|
276
|
+
/***/ }),
|
|
277
|
+
|
|
278
|
+
/***/ "./src/screens/inbox/components/CachedImage/index.tsx":
|
|
279
|
+
/*!************************************************************!*\
|
|
280
|
+
!*** ./src/screens/inbox/components/CachedImage/index.tsx ***!
|
|
281
|
+
\************************************************************/
|
|
282
|
+
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {
|
|
283
|
+
|
|
284
|
+
|
|
285
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
286
|
+
if (k2 === undefined) k2 = k;
|
|
287
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
288
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
289
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
290
|
+
}
|
|
291
|
+
Object.defineProperty(o, k2, desc);
|
|
292
|
+
}) : (function(o, m, k, k2) {
|
|
293
|
+
if (k2 === undefined) k2 = k;
|
|
294
|
+
o[k2] = m[k];
|
|
295
|
+
}));
|
|
296
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
297
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
298
|
+
}) : function(o, v) {
|
|
299
|
+
o["default"] = v;
|
|
300
|
+
});
|
|
301
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
302
|
+
if (mod && mod.__esModule) return mod;
|
|
303
|
+
var result = {};
|
|
304
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
305
|
+
__setModuleDefault(result, mod);
|
|
306
|
+
return result;
|
|
307
|
+
};
|
|
308
|
+
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
309
|
+
exports.CacheManager = void 0;
|
|
310
|
+
const react_1 = __importStar(__webpack_require__(/*! react */ "react"));
|
|
311
|
+
const native_base_1 = __webpack_require__(/*! native-base */ "native-base");
|
|
312
|
+
// import { Image } from "react-native"
|
|
313
|
+
const FileSystem = __importStar(__webpack_require__(/*! expo-file-system */ "expo-file-system"));
|
|
314
|
+
const CONST = __importStar(__webpack_require__(/*! ./consts */ "./src/screens/inbox/components/CachedImage/consts.ts"));
|
|
315
|
+
const CachedImage = (props) => {
|
|
316
|
+
const { source, cacheKey, placeholderContent } = props;
|
|
317
|
+
const { uri, headers, expiresIn } = source;
|
|
318
|
+
const fileURI = `${CONST.IMAGE_CACHE_FOLDER}${cacheKey}`;
|
|
319
|
+
const [imgUri, setImgUri] = (0, react_1.useState)(fileURI);
|
|
320
|
+
const componentIsMounted = (0, react_1.useRef)(true);
|
|
321
|
+
const requestOption = headers ? { headers } : {};
|
|
322
|
+
const _callback = (downloadProgress) => {
|
|
323
|
+
if (componentIsMounted.current === false) {
|
|
324
|
+
downloadResumableRef.current.pauseAsync();
|
|
325
|
+
FileSystem.deleteAsync(fileURI, { idempotent: true }); // delete file locally if it was not downloaded properly
|
|
326
|
+
}
|
|
327
|
+
};
|
|
328
|
+
const downloadResumableRef = (0, react_1.useRef)(FileSystem.createDownloadResumable(uri, fileURI, requestOption, _callback));
|
|
329
|
+
(0, react_1.useEffect)(() => {
|
|
330
|
+
loadImage();
|
|
331
|
+
return () => {
|
|
332
|
+
componentIsMounted.current = false;
|
|
333
|
+
};
|
|
334
|
+
}, []); // eslint-disable-line react-hooks/exhaustive-deps
|
|
335
|
+
const loadImage = async () => {
|
|
336
|
+
try {
|
|
337
|
+
// Use the cached image if it exists
|
|
338
|
+
const metadata = await FileSystem.getInfoAsync(fileURI);
|
|
339
|
+
const expired = expiresIn && new Date().getTime() / 1000 - (metadata === null || metadata === void 0 ? void 0 : metadata.modificationTime) > expiresIn;
|
|
340
|
+
// console.log({expiresIn, expired})
|
|
341
|
+
// console.log({modificationTime: metadata.modificationTime, currentTime: new Date().getTime() / 1000})
|
|
342
|
+
// console.log({metadata})
|
|
343
|
+
if (!metadata.exists || (metadata === null || metadata === void 0 ? void 0 : metadata.size) === 0 || expired) {
|
|
344
|
+
if (componentIsMounted.current) {
|
|
345
|
+
setImgUri(null);
|
|
346
|
+
if (expired) {
|
|
347
|
+
await FileSystem.deleteAsync(fileURI, { idempotent: true });
|
|
348
|
+
}
|
|
349
|
+
// download to cache
|
|
350
|
+
setImgUri(null);
|
|
351
|
+
const response = await downloadResumableRef.current.downloadAsync();
|
|
352
|
+
if (componentIsMounted.current && response.status === 200) {
|
|
353
|
+
setImgUri(`${fileURI}?`); // deep clone to force re-render
|
|
354
|
+
}
|
|
355
|
+
if (response.status !== 200) {
|
|
356
|
+
FileSystem.deleteAsync(fileURI, { idempotent: true }); // delete file locally if it was not downloaded properly
|
|
357
|
+
}
|
|
358
|
+
}
|
|
359
|
+
}
|
|
360
|
+
}
|
|
361
|
+
catch (err) {
|
|
362
|
+
// console.log({ err })
|
|
363
|
+
}
|
|
364
|
+
};
|
|
365
|
+
// console.log({placeholderContent})
|
|
366
|
+
if (!imgUri)
|
|
367
|
+
return placeholderContent || null;
|
|
368
|
+
return (react_1.default.createElement(native_base_1.Image
|
|
369
|
+
// eslint-disable-next-line react/jsx-props-no-spreading
|
|
370
|
+
, Object.assign({}, props, { source: Object.assign(Object.assign({}, source), { uri: imgUri }) })));
|
|
371
|
+
};
|
|
372
|
+
exports.CacheManager = {
|
|
373
|
+
addToCache: async ({ file, key }) => {
|
|
374
|
+
await FileSystem.copyAsync({
|
|
375
|
+
from: file,
|
|
376
|
+
to: `${CONST.IMAGE_CACHE_FOLDER}${key}`,
|
|
377
|
+
});
|
|
378
|
+
// const uri = await FileSystem.getContentUriAsync(`${CONST.IMAGE_CACHE_FOLDER}${key}`)
|
|
379
|
+
// return uri
|
|
380
|
+
const uri = await exports.CacheManager.getCachedUri({ key });
|
|
381
|
+
return uri;
|
|
382
|
+
},
|
|
383
|
+
getCachedUri: async ({ key }) => {
|
|
384
|
+
const uri = await FileSystem.getContentUriAsync(`${CONST.IMAGE_CACHE_FOLDER}${key}`);
|
|
385
|
+
return uri;
|
|
386
|
+
},
|
|
387
|
+
downloadAsync: async ({ uri, key, options }) => {
|
|
388
|
+
return await FileSystem.downloadAsync(uri, `${CONST.IMAGE_CACHE_FOLDER}${key}`, options);
|
|
389
|
+
},
|
|
390
|
+
};
|
|
391
|
+
exports["default"] = CachedImage;
|
|
392
|
+
|
|
393
|
+
|
|
236
394
|
/***/ }),
|
|
237
395
|
|
|
238
396
|
/***/ "./src/screens/inbox/components/DialogsListItem.tsx":
|
|
@@ -499,7 +657,10 @@ Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
|
499
657
|
const react_1 = __importDefault(__webpack_require__(/*! react */ "react"));
|
|
500
658
|
const react_native_1 = __webpack_require__(/*! react-native */ "react-native");
|
|
501
659
|
const react_native_gifted_chat_1 = __webpack_require__(/*! react-native-gifted-chat */ "react-native-gifted-chat");
|
|
660
|
+
const CachedImage_1 = __importDefault(__webpack_require__(/*! ../CachedImage */ "./src/screens/inbox/components/CachedImage/index.tsx"));
|
|
502
661
|
const { isSameUser, isSameDay } = react_native_gifted_chat_1.utils;
|
|
662
|
+
const windowWidth = react_native_1.Dimensions.get('window').width;
|
|
663
|
+
const windowHeight = react_native_1.Dimensions.get('window').height;
|
|
503
664
|
class Bubble extends react_1.default.Component {
|
|
504
665
|
constructor(props) {
|
|
505
666
|
super(props);
|
|
@@ -527,9 +688,17 @@ class Bubble extends react_1.default.Component {
|
|
|
527
688
|
if (this.props.renderMessageImage) {
|
|
528
689
|
return this.props.renderMessageImage(messageImageProps);
|
|
529
690
|
}
|
|
691
|
+
const { image, _id } = messageImageProps === null || messageImageProps === void 0 ? void 0 : messageImageProps.currentMessage;
|
|
530
692
|
return (react_1.default.createElement(react_native_1.TouchableOpacity, { onPress: () => this.props.setImageViewer(messageImageProps === null || messageImageProps === void 0 ? void 0 : messageImageProps.currentMessage, true) },
|
|
531
|
-
react_1.default.createElement(react_native_1.
|
|
532
|
-
|
|
693
|
+
react_1.default.createElement(react_native_1.View, { style: {
|
|
694
|
+
width: windowWidth - (windowWidth - 150),
|
|
695
|
+
height: windowHeight - (windowHeight - 100),
|
|
696
|
+
} },
|
|
697
|
+
react_1.default.createElement(CachedImage_1.default, { style: [styles.slackImage, { width: '100%', height: '100%' }], cacheKey: `${_id}-slack-bubble-imageKey`, source: {
|
|
698
|
+
uri: image,
|
|
699
|
+
//headers: `Authorization: Bearer ${token}`,
|
|
700
|
+
expiresIn: 86400,
|
|
701
|
+
}, resizeMode: 'cover', alt: 'image' }))));
|
|
533
702
|
}
|
|
534
703
|
return null;
|
|
535
704
|
}
|
|
@@ -875,6 +1044,9 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
875
1044
|
__setModuleDefault(result, mod);
|
|
876
1045
|
return result;
|
|
877
1046
|
};
|
|
1047
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
1048
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
1049
|
+
};
|
|
878
1050
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
879
1051
|
exports.ConversationView = void 0;
|
|
880
1052
|
const react_1 = __importStar(__webpack_require__(/*! react */ "react"));
|
|
@@ -891,6 +1063,7 @@ const platform_client_1 = __webpack_require__(/*! @messenger-box/platform-client
|
|
|
891
1063
|
const config_1 = __webpack_require__(/*! ../config */ "./src/screens/inbox/config/index.ts");
|
|
892
1064
|
const user_auth0_client_1 = __webpack_require__(/*! @adminide-stack/user-auth0-client */ "@adminide-stack/user-auth0-client");
|
|
893
1065
|
const SlackMessageContainer_1 = __webpack_require__(/*! ../components/SlackMessageContainer */ "./src/screens/inbox/components/SlackMessageContainer/index.ts");
|
|
1066
|
+
const CachedImage_1 = __importDefault(__webpack_require__(/*! ../components/CachedImage */ "./src/screens/inbox/components/CachedImage/index.tsx"));
|
|
894
1067
|
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;
|
|
895
1068
|
const ConversationViewComponent = ({ channelId }) => {
|
|
896
1069
|
var _a;
|
|
@@ -957,13 +1130,13 @@ const ConversationViewComponent = ({ channelId }) => {
|
|
|
957
1130
|
};
|
|
958
1131
|
}, []));
|
|
959
1132
|
react_1.default.useEffect(() => {
|
|
960
|
-
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
1133
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j;
|
|
961
1134
|
if ((_b = (_a = channelsDetail === null || channelsDetail === void 0 ? void 0 : channelsDetail.viewChannelDetail) === null || _a === void 0 ? void 0 : _a.members) === null || _b === void 0 ? void 0 : _b.length) {
|
|
962
1135
|
const channelData = (_e = (_d = (_c = channelsDetail === null || channelsDetail === void 0 ? void 0 : channelsDetail.viewChannelDetail) === null || _c === void 0 ? void 0 : _c.members) === null || _d === void 0 ? void 0 : _d.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 && _e !== void 0 ? _e : [];
|
|
963
|
-
const tokens = (_h = (_g = (_f = channelData === null || channelData === void 0 ? void 0 : channelData.map((u) => {
|
|
1136
|
+
const tokens = (_j = (_h = (_g = (_f = channelData === null || channelData === void 0 ? void 0 : channelData.map((u) => {
|
|
964
1137
|
var _a, _b, _c, _d;
|
|
965
1138
|
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 : [];
|
|
966
|
-
})) === null || _f === void 0 ? void 0 : _f.flat(1)) === null || _g === void 0 ? void 0 : _g.filter((t) => t)) !== null &&
|
|
1139
|
+
})) === null || _f === void 0 ? void 0 : _f.flat(1)) === null || _g === void 0 ? void 0 : _g.filter((t) => t)) === null || _h === void 0 ? void 0 : _h.filter((value, index, array) => array.indexOf(value) === index)) !== null && _j !== void 0 ? _j : [];
|
|
967
1140
|
if ((tokens === null || tokens === void 0 ? void 0 : tokens.length) > 0)
|
|
968
1141
|
setExpoTokens(tokens);
|
|
969
1142
|
}
|
|
@@ -1106,22 +1279,45 @@ const ConversationViewComponent = ({ channelId }) => {
|
|
|
1106
1279
|
if (imageSource.cancelled)
|
|
1107
1280
|
setLoading(false);
|
|
1108
1281
|
};
|
|
1109
|
-
const sendPushNotification = (title, body, data, to) => {
|
|
1110
|
-
|
|
1111
|
-
|
|
1112
|
-
|
|
1113
|
-
|
|
1114
|
-
|
|
1115
|
-
|
|
1116
|
-
|
|
1117
|
-
|
|
1118
|
-
|
|
1119
|
-
|
|
1120
|
-
|
|
1121
|
-
|
|
1122
|
-
|
|
1123
|
-
|
|
1124
|
-
|
|
1282
|
+
const sendPushNotification = async (title, body, data, to) => {
|
|
1283
|
+
try {
|
|
1284
|
+
const response = await fetch("https://exp.host/--/api/v2/push/send/", {
|
|
1285
|
+
method: 'POST',
|
|
1286
|
+
headers: {
|
|
1287
|
+
Accept: 'application/json',
|
|
1288
|
+
'Accept-Encoding': 'gzip, deflate',
|
|
1289
|
+
'Content-Type': 'application/json',
|
|
1290
|
+
},
|
|
1291
|
+
body: JSON.stringify({
|
|
1292
|
+
to: to,
|
|
1293
|
+
data: data,
|
|
1294
|
+
title: title,
|
|
1295
|
+
body: body,
|
|
1296
|
+
sound: react_native_1.Platform.OS === 'android' ? null : 'default',
|
|
1297
|
+
}),
|
|
1298
|
+
});
|
|
1299
|
+
const result = await response.json();
|
|
1300
|
+
alert(JSON.stringify(result));
|
|
1301
|
+
}
|
|
1302
|
+
catch (error) {
|
|
1303
|
+
console.error("Error:", error);
|
|
1304
|
+
alert(JSON.stringify(error));
|
|
1305
|
+
}
|
|
1306
|
+
// fetch('https://exp.host/--/api/v2/push/send/', {
|
|
1307
|
+
// method: 'POST',
|
|
1308
|
+
// headers: {
|
|
1309
|
+
// Accept: 'application/json',
|
|
1310
|
+
// 'Accept-Encoding': 'gzip, deflate',
|
|
1311
|
+
// 'Content-Type': 'application/json',
|
|
1312
|
+
// },
|
|
1313
|
+
// body: JSON.stringify({
|
|
1314
|
+
// to: to,
|
|
1315
|
+
// data: data,
|
|
1316
|
+
// title: title,
|
|
1317
|
+
// body: body,
|
|
1318
|
+
// sound: Platform.OS === 'android' ? null : 'default',
|
|
1319
|
+
// }),
|
|
1320
|
+
// });
|
|
1125
1321
|
};
|
|
1126
1322
|
// const handleSend = useCallback(
|
|
1127
1323
|
// async (message: string) => {
|
|
@@ -1236,6 +1432,7 @@ const ConversationViewComponent = ({ channelId }) => {
|
|
|
1236
1432
|
screen: 'DialogMessages',
|
|
1237
1433
|
};
|
|
1238
1434
|
console.log('expo to', JSON.stringify(expoTokens));
|
|
1435
|
+
alert(JSON.stringify(expoTokens));
|
|
1239
1436
|
if ((expoTokens === null || expoTokens === void 0 ? void 0 : expoTokens.length) > 0) {
|
|
1240
1437
|
const to = (expoTokens === null || expoTokens === void 0 ? void 0 : expoTokens.length) > 0 ? expoTokens : [];
|
|
1241
1438
|
sendPushNotification(title, body, notificationData, to);
|
|
@@ -1362,8 +1559,14 @@ const ConversationViewComponent = ({ channelId }) => {
|
|
|
1362
1559
|
const modalContent = react_1.default.useMemo(() => {
|
|
1363
1560
|
if (!imageObject)
|
|
1364
1561
|
return react_1.default.createElement(react_1.default.Fragment, null);
|
|
1365
|
-
const { image } = imageObject;
|
|
1366
|
-
return react_1.default.createElement(
|
|
1562
|
+
const { image, _id } = imageObject;
|
|
1563
|
+
return (react_1.default.createElement(CachedImage_1.default, { style: { width: '100%', height: '100%' }, resizeMode: 'cover',
|
|
1564
|
+
// cacheKey={`${_id}-conversation-modal-image-key`}
|
|
1565
|
+
cacheKey: `${_id}-slack-bubble-imageKey`, source: {
|
|
1566
|
+
uri: image,
|
|
1567
|
+
//headers: `Authorization: Bearer ${token}`,
|
|
1568
|
+
expiresIn: 86400,
|
|
1569
|
+
}, alt: 'image' }));
|
|
1367
1570
|
}, [imageObject]);
|
|
1368
1571
|
const renderMessage = (props) => {
|
|
1369
1572
|
// const {
|
|
@@ -1451,7 +1654,6 @@ const native_1 = __webpack_require__(/*! @react-navigation/native */ "@react-nav
|
|
|
1451
1654
|
const DialogsListItem_1 = __webpack_require__(/*! ../components/DialogsListItem */ "./src/screens/inbox/components/DialogsListItem.tsx");
|
|
1452
1655
|
const platform_client_1 = __webpack_require__(/*! @messenger-box/platform-client */ "@messenger-box/platform-client");
|
|
1453
1656
|
const user_auth0_client_1 = __webpack_require__(/*! @adminide-stack/user-auth0-client */ "@adminide-stack/user-auth0-client");
|
|
1454
|
-
const client_1 = __webpack_require__(/*! @admin-layout/client */ "@admin-layout/client");
|
|
1455
1657
|
const config_1 = __webpack_require__(/*! ../config */ "./src/screens/inbox/config/index.ts");
|
|
1456
1658
|
const DialogsComponent = (props) => {
|
|
1457
1659
|
const { channelFilters, channelRole } = props;
|
|
@@ -1460,48 +1662,66 @@ const DialogsComponent = (props) => {
|
|
|
1460
1662
|
const dispatch = (0, react_redux_1.useDispatch)();
|
|
1461
1663
|
const navigation = (0, native_1.useNavigation)();
|
|
1462
1664
|
const isFocused = (0, native_1.useIsFocused)();
|
|
1463
|
-
const [
|
|
1665
|
+
const [refreshing, setRefresh] = (0, react_1.useState)(false);
|
|
1666
|
+
// const [userDirectChannel, setUserDirectChannel] = useState<any>([]);
|
|
1464
1667
|
const { data: userChannels, loading: userChannelsLoading, refetch: getChannelsRefetch, } = (0, platform_client_1.useGetChannelsByUserQuery)({
|
|
1465
1668
|
variables: {
|
|
1466
1669
|
role: channelRole,
|
|
1467
1670
|
criteria: channelFilters,
|
|
1468
1671
|
},
|
|
1672
|
+
onCompleted: (data) => {
|
|
1673
|
+
setRefresh(false);
|
|
1674
|
+
}
|
|
1469
1675
|
});
|
|
1470
1676
|
(0, native_1.useFocusEffect)(react_1.default.useCallback(() => {
|
|
1471
1677
|
// Do something when the screen is focused
|
|
1678
|
+
setRefresh(false);
|
|
1472
1679
|
getChannelsRefetch({ role: channelRole, criteria: channelFilters });
|
|
1473
1680
|
return () => {
|
|
1474
1681
|
// Do something when the screen is unfocused
|
|
1475
1682
|
// Useful for cleanup functions
|
|
1476
1683
|
};
|
|
1477
1684
|
}, [channelFilters]));
|
|
1478
|
-
|
|
1479
|
-
setTimeout(() => {
|
|
1480
|
-
dispatch({
|
|
1481
|
-
type: client_1.CHANGE_SETTINGS_ACTION,
|
|
1482
|
-
payload: {
|
|
1483
|
-
footerRender: false,
|
|
1484
|
-
},
|
|
1485
|
-
});
|
|
1486
|
-
}, 0);
|
|
1487
|
-
return () => {
|
|
1488
|
-
dispatch({
|
|
1489
|
-
type: client_1.CHANGE_SETTINGS_ACTION,
|
|
1490
|
-
payload: {
|
|
1491
|
-
footerRender: true,
|
|
1492
|
-
},
|
|
1493
|
-
});
|
|
1494
|
-
};
|
|
1495
|
-
}, []);
|
|
1496
|
-
(0, react_1.useEffect)(() => {
|
|
1685
|
+
const channels = react_1.default.useMemo(() => {
|
|
1497
1686
|
var _a, _b, _c;
|
|
1498
|
-
if (userChannels === null || userChannels === void 0 ? void 0 : userChannels.channelsByUser)
|
|
1499
|
-
|
|
1500
|
-
|
|
1501
|
-
|
|
1502
|
-
|
|
1503
|
-
|
|
1504
|
-
|
|
1687
|
+
if (!((_a = userChannels === null || userChannels === void 0 ? void 0 : userChannels.channelsByUser) === null || _a === void 0 ? void 0 : _a.length))
|
|
1688
|
+
return null;
|
|
1689
|
+
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 : [];
|
|
1690
|
+
return uChannels || [];
|
|
1691
|
+
}, [userChannels]);
|
|
1692
|
+
// useEffect(() => {
|
|
1693
|
+
// setTimeout(() => {
|
|
1694
|
+
// dispatch({
|
|
1695
|
+
// type: CHANGE_SETTINGS_ACTION,
|
|
1696
|
+
// payload: {
|
|
1697
|
+
// footerRender: false,
|
|
1698
|
+
// },
|
|
1699
|
+
// } as any);
|
|
1700
|
+
// }, 0);
|
|
1701
|
+
// return () => {
|
|
1702
|
+
// dispatch({
|
|
1703
|
+
// type: CHANGE_SETTINGS_ACTION,
|
|
1704
|
+
// payload: {
|
|
1705
|
+
// footerRender: true,
|
|
1706
|
+
// },
|
|
1707
|
+
// } as any);
|
|
1708
|
+
// };
|
|
1709
|
+
// }, []);
|
|
1710
|
+
// useEffect(() => {
|
|
1711
|
+
// if (userChannels?.channelsByUser) {
|
|
1712
|
+
// if (userChannels?.channelsByUser?.length == 0) {
|
|
1713
|
+
// setUserDirectChannel([]);
|
|
1714
|
+
// }
|
|
1715
|
+
// //Direct channel
|
|
1716
|
+
// let userDirectChannels: any =
|
|
1717
|
+
// userChannels?.channelsByUser
|
|
1718
|
+
// ?.filter((i: any) => i.type == 'DIRECT')
|
|
1719
|
+
// ?.filter((c: any) =>
|
|
1720
|
+
// c.members.some((u: any) => u?.user?.id != auth?.id && u.user.__typename == 'UserAccount'),
|
|
1721
|
+
// ) ?? [];
|
|
1722
|
+
// if (userDirectChannels?.length > 0) setUserDirectChannel(userDirectChannels);
|
|
1723
|
+
// }
|
|
1724
|
+
// }, [userChannels?.channelsByUser]);
|
|
1505
1725
|
const handleSelectChannel = (0, react_1.useCallback)((id, title) => {
|
|
1506
1726
|
var _a;
|
|
1507
1727
|
if (params === null || params === void 0 ? void 0 : params.channelId) {
|
|
@@ -1519,13 +1739,17 @@ const DialogsComponent = (props) => {
|
|
|
1519
1739
|
});
|
|
1520
1740
|
}
|
|
1521
1741
|
}, []);
|
|
1742
|
+
const handleRefresh = (0, react_1.useCallback)(() => {
|
|
1743
|
+
//if(userChannels?.channelsByUser?.length != channels?.length)setRefresh(true);
|
|
1744
|
+
getChannelsRefetch({ role: channelRole, criteria: channelFilters });
|
|
1745
|
+
}, []);
|
|
1522
1746
|
return (react_1.default.createElement(native_base_1.Box, { p: 2 },
|
|
1523
|
-
react_1.default.createElement(native_base_1.FlatList, { data: (
|
|
1747
|
+
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 },
|
|
1524
1748
|
react_1.default.createElement(native_base_1.Heading, null, "Chat"),
|
|
1525
1749
|
react_1.default.createElement(native_base_1.Input, { height: 50, mt: 3, placeholder: "Search", borderRadius: 50, borderColor: 'gray.200', borderWidth: 2 }),
|
|
1526
1750
|
react_1.default.createElement(native_base_1.Center, { mt: 6 },
|
|
1527
1751
|
react_1.default.createElement(native_base_1.Icon, { as: vector_icons_1.Ionicons, name: "chatbubbles", size: 'xl' }),
|
|
1528
|
-
react_1.default.createElement(native_base_1.Text, null, "You don't have any messages yet!")))), keyExtractor: (item, index) => 'key' + index })));
|
|
1752
|
+
react_1.default.createElement(native_base_1.Text, null, "You don't have any messages yet!")))))), keyExtractor: (item, index) => 'key' + index })));
|
|
1529
1753
|
};
|
|
1530
1754
|
exports.Dialogs = react_1.default.memo(DialogsComponent);
|
|
1531
1755
|
|
|
@@ -1558,16 +1782,6 @@ __exportStar(__webpack_require__(/*! ./inbox/Inbox */ "./src/screens/inbox/Inbox
|
|
|
1558
1782
|
__exportStar(__webpack_require__(/*! ./inbox/DialogMessages */ "./src/screens/inbox/DialogMessages.tsx"), exports);
|
|
1559
1783
|
|
|
1560
1784
|
|
|
1561
|
-
/***/ }),
|
|
1562
|
-
|
|
1563
|
-
/***/ "@admin-layout/client":
|
|
1564
|
-
/*!***************************************!*\
|
|
1565
|
-
!*** external "@admin-layout/client" ***!
|
|
1566
|
-
\***************************************/
|
|
1567
|
-
/***/ ((module) => {
|
|
1568
|
-
|
|
1569
|
-
module.exports = require("@admin-layout/client");
|
|
1570
|
-
|
|
1571
1785
|
/***/ }),
|
|
1572
1786
|
|
|
1573
1787
|
/***/ "@adminide-stack/user-auth0-client":
|
|
@@ -1650,6 +1864,16 @@ module.exports = require("envalid");
|
|
|
1650
1864
|
|
|
1651
1865
|
/***/ }),
|
|
1652
1866
|
|
|
1867
|
+
/***/ "expo-file-system":
|
|
1868
|
+
/*!***********************************!*\
|
|
1869
|
+
!*** external "expo-file-system" ***!
|
|
1870
|
+
\***********************************/
|
|
1871
|
+
/***/ ((module) => {
|
|
1872
|
+
|
|
1873
|
+
module.exports = require("expo-file-system");
|
|
1874
|
+
|
|
1875
|
+
/***/ }),
|
|
1876
|
+
|
|
1653
1877
|
/***/ "expo-image-picker":
|
|
1654
1878
|
/*!************************************!*\
|
|
1655
1879
|
!*** external "expo-image-picker" ***!
|