@amityco/ts-sdk-react-native 6.32.4-a4e315c.0 → 6.32.5-4306d45.0
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/dist/@types/core/events.d.ts +1 -1
- package/dist/@types/core/events.d.ts.map +1 -1
- package/dist/@types/core/model.d.ts +1 -1
- package/dist/@types/core/model.d.ts.map +1 -1
- package/dist/@types/core/payload.d.ts +1 -1
- package/dist/@types/core/payload.d.ts.map +1 -1
- package/dist/@types/domains/channel.d.ts +1 -0
- package/dist/@types/domains/channel.d.ts.map +1 -1
- package/dist/channelRepository/api/createChannel.d.ts.map +1 -1
- package/dist/channelRepository/api/getChannel.d.ts.map +1 -1
- package/dist/channelRepository/api/getChannelByIds.d.ts.map +1 -1
- package/dist/channelRepository/api/updateChannel.d.ts.map +1 -1
- package/dist/channelRepository/channelMembership/observers/getMembers/ChannelMemberQueryStreamController.d.ts +2 -2
- package/dist/channelRepository/channelMembership/observers/getMembers/ChannelMemberQueryStreamController.d.ts.map +1 -1
- package/dist/channelRepository/events/onChannelCreated.d.ts +1 -1
- package/dist/channelRepository/events/onChannelCreated.d.ts.map +1 -1
- package/dist/channelRepository/events/onChannelDeleted.d.ts +1 -1
- package/dist/channelRepository/events/onChannelDeleted.d.ts.map +1 -1
- package/dist/channelRepository/events/onChannelFetched.d.ts +1 -1
- package/dist/channelRepository/events/onChannelFetched.d.ts.map +1 -1
- package/dist/channelRepository/events/onChannelJoined.d.ts +1 -1
- package/dist/channelRepository/events/onChannelJoined.d.ts.map +1 -1
- package/dist/channelRepository/events/onChannelLeft.d.ts +1 -1
- package/dist/channelRepository/events/onChannelLeft.d.ts.map +1 -1
- package/dist/channelRepository/events/onChannelMemberAdded.d.ts +1 -1
- package/dist/channelRepository/events/onChannelMemberAdded.d.ts.map +1 -1
- package/dist/channelRepository/events/onChannelMemberBanned.d.ts +1 -1
- package/dist/channelRepository/events/onChannelMemberBanned.d.ts.map +1 -1
- package/dist/channelRepository/events/onChannelMemberRemoved.d.ts +1 -1
- package/dist/channelRepository/events/onChannelMemberRemoved.d.ts.map +1 -1
- package/dist/channelRepository/events/onChannelMemberRoleAdded.d.ts +1 -1
- package/dist/channelRepository/events/onChannelMemberRoleAdded.d.ts.map +1 -1
- package/dist/channelRepository/events/onChannelMemberRoleRemoved.d.ts +1 -1
- package/dist/channelRepository/events/onChannelMemberRoleRemoved.d.ts.map +1 -1
- package/dist/channelRepository/events/onChannelMemberUnbanned.d.ts +1 -1
- package/dist/channelRepository/events/onChannelMemberUnbanned.d.ts.map +1 -1
- package/dist/channelRepository/events/onChannelMuted.d.ts +1 -1
- package/dist/channelRepository/events/onChannelMuted.d.ts.map +1 -1
- package/dist/channelRepository/events/onChannelResolved.d.ts +1 -1
- package/dist/channelRepository/events/onChannelResolved.d.ts.map +1 -1
- package/dist/channelRepository/events/onChannelUpdated.d.ts +1 -1
- package/dist/channelRepository/events/onChannelUpdated.d.ts.map +1 -1
- package/dist/channelRepository/events/onUserDeleted.d.ts +1 -1
- package/dist/channelRepository/events/onUserDeleted.d.ts.map +1 -1
- package/dist/channelRepository/observers/getChannel.d.ts.map +1 -1
- package/dist/channelRepository/observers/getChannels/ChannelLiveCollectionController.d.ts.map +1 -1
- package/dist/channelRepository/observers/getChannels/ChannelQueryStreamController.d.ts +2 -2
- package/dist/channelRepository/observers/getChannels/ChannelQueryStreamController.d.ts.map +1 -1
- package/dist/channelRepository/observers/observeChannel.d.ts.map +1 -1
- package/dist/channelRepository/observers/observeChannels.d.ts.map +1 -1
- package/dist/channelRepository/utils/constructChannelDynamicValue.d.ts +2 -0
- package/dist/channelRepository/utils/constructChannelDynamicValue.d.ts.map +1 -0
- package/dist/channelRepository/utils/prepareChannelPayload.d.ts +1 -1
- package/dist/channelRepository/utils/prepareChannelPayload.d.ts.map +1 -1
- package/dist/channelRepository/utils/resolveUnreadInfoOnChannelEvent.d.ts +1 -1
- package/dist/channelRepository/utils/resolveUnreadInfoOnChannelEvent.d.ts.map +1 -1
- package/dist/client/utils/removeChannelMarkerCache.d.ts +1 -1
- package/dist/client/utils/removeChannelMarkerCache.d.ts.map +1 -1
- package/dist/index.cjs.js +136 -126
- package/dist/index.esm.js +136 -126
- package/dist/index.umd.js +2 -2
- package/dist/marker/events/onMessageMarked.d.ts.map +1 -1
- package/dist/utils/linkedObject/channelLinkedObject.d.ts.map +1 -1
- package/dist/utils/shallowClone.d.ts +1 -1
- package/dist/utils/shallowClone.d.ts.map +1 -1
- package/dist/utils/tests/dummy/comment.d.ts +1 -1
- package/dist/utils/tests/dummy/post.d.ts +3 -3
- package/package.json +1 -1
- package/src/@types/core/events.ts +1 -1
- package/src/@types/core/model.ts +1 -1
- package/src/@types/core/payload.ts +1 -1
- package/src/@types/domains/channel.ts +5 -0
- package/src/channelRepository/api/createChannel.ts +2 -1
- package/src/channelRepository/api/getChannel.ts +4 -3
- package/src/channelRepository/api/getChannelByIds.ts +2 -1
- package/src/channelRepository/api/updateChannel.ts +2 -1
- package/src/channelRepository/channelMembership/observers/getMembers/ChannelMemberQueryStreamController.ts +2 -2
- package/src/channelRepository/events/onChannelCreated.ts +2 -2
- package/src/channelRepository/events/onChannelDeleted.ts +2 -2
- package/src/channelRepository/events/onChannelFetched.ts +3 -3
- package/src/channelRepository/events/onChannelJoined.ts +5 -2
- package/src/channelRepository/events/onChannelLeft.ts +5 -2
- package/src/channelRepository/events/onChannelMemberAdded.ts +5 -2
- package/src/channelRepository/events/onChannelMemberBanned.ts +5 -2
- package/src/channelRepository/events/onChannelMemberRemoved.ts +5 -2
- package/src/channelRepository/events/onChannelMemberRoleAdded.ts +5 -2
- package/src/channelRepository/events/onChannelMemberRoleRemoved.ts +5 -2
- package/src/channelRepository/events/onChannelMemberUnbanned.ts +5 -2
- package/src/channelRepository/events/onChannelMuted.ts +3 -2
- package/src/channelRepository/events/onChannelResolved.ts +2 -2
- package/src/channelRepository/events/onChannelUpdated.ts +2 -2
- package/src/channelRepository/events/onUserDeleted.ts +8 -2
- package/src/channelRepository/observers/getChannel.ts +4 -1
- package/src/channelRepository/observers/getChannels/ChannelLiveCollectionController.ts +9 -7
- package/src/channelRepository/observers/getChannels/ChannelQueryStreamController.ts +2 -2
- package/src/channelRepository/observers/observeChannel.ts +5 -4
- package/src/channelRepository/observers/observeChannels.ts +6 -4
- package/src/channelRepository/utils/constructChannelDynamicValue.ts +22 -0
- package/src/channelRepository/utils/prepareChannelPayload.ts +1 -13
- package/src/channelRepository/utils/resolveUnreadInfoOnChannelEvent.ts +2 -2
- package/src/channelRepository/utils/updateChannelCache.ts +1 -1
- package/src/client/utils/removeChannelMarkerCache.ts +1 -1
- package/src/marker/events/onMessageMarked.ts +0 -2
- package/src/subChannelRepository/utils/updateSubChannelCache.ts +1 -1
- package/src/utils/linkedObject/channelLinkedObject.ts +3 -3
- package/src/utils/shallowClone.ts +8 -5
package/dist/index.cjs.js
CHANGED
|
@@ -123,8 +123,8 @@ const PostContentType = Object.freeze({
|
|
|
123
123
|
|
|
124
124
|
function getVersion() {
|
|
125
125
|
try {
|
|
126
|
-
// the string ''v6.32.
|
|
127
|
-
return 'v6.32.
|
|
126
|
+
// the string ''v6.32.4-cjs'' should be replaced by actual value by @rollup/plugin-replace
|
|
127
|
+
return 'v6.32.4-cjs';
|
|
128
128
|
}
|
|
129
129
|
catch (error) {
|
|
130
130
|
return '__dev__';
|
|
@@ -5943,8 +5943,28 @@ const markAsRead = async (channelId) => {
|
|
|
5943
5943
|
return true;
|
|
5944
5944
|
};
|
|
5945
5945
|
|
|
5946
|
+
/**
|
|
5947
|
+
* ```js
|
|
5948
|
+
* import { shallowClone } from '~/utils/shallowClone'
|
|
5949
|
+
* const newObj = shallowClone(obj)
|
|
5950
|
+
* ```
|
|
5951
|
+
*
|
|
5952
|
+
* Clone an object with same prototype and properties
|
|
5953
|
+
*
|
|
5954
|
+
* @param obj the object to clone
|
|
5955
|
+
* @returns new object with same prototype and properties
|
|
5956
|
+
*
|
|
5957
|
+
* @category utility
|
|
5958
|
+
* @private
|
|
5959
|
+
*/
|
|
5960
|
+
function shallowClone(source, target) {
|
|
5961
|
+
return Object.create(Object.getPrototypeOf(source), Object.assign(Object.assign({}, Object.getOwnPropertyDescriptors(source)), Object.getOwnPropertyDescriptors(target)));
|
|
5962
|
+
}
|
|
5963
|
+
|
|
5946
5964
|
const channelLinkedObject = (channel) => {
|
|
5947
|
-
return
|
|
5965
|
+
return shallowClone(channel, {
|
|
5966
|
+
markAsRead: () => markAsRead(channel.channelInternalId),
|
|
5967
|
+
});
|
|
5948
5968
|
};
|
|
5949
5969
|
|
|
5950
5970
|
const adLinkedObject = (ad) => {
|
|
@@ -6115,31 +6135,10 @@ const updateSubChannelMessagePreviewCache = (rawPayload) => {
|
|
|
6115
6135
|
ingestInCache(newData);
|
|
6116
6136
|
};
|
|
6117
6137
|
|
|
6118
|
-
/**
|
|
6119
|
-
* ```js
|
|
6120
|
-
* import { shallowClone } from '~/utils/shallowClone'
|
|
6121
|
-
* const newObj = shallowClone(obj)
|
|
6122
|
-
* ```
|
|
6123
|
-
*
|
|
6124
|
-
* Clone an object with same prototype and properties
|
|
6125
|
-
*
|
|
6126
|
-
* @param obj the object to clone
|
|
6127
|
-
* @returns new object with same prototype and properties
|
|
6128
|
-
*
|
|
6129
|
-
* @category utility
|
|
6130
|
-
* @private
|
|
6131
|
-
*/
|
|
6132
|
-
function shallowClone(obj) {
|
|
6133
|
-
const clone = Object.create(Object.getPrototypeOf(obj));
|
|
6134
|
-
const descriptors = Object.getOwnPropertyDescriptors(obj);
|
|
6135
|
-
Object.defineProperties(clone, descriptors);
|
|
6136
|
-
return clone;
|
|
6137
|
-
}
|
|
6138
|
-
|
|
6139
6138
|
function updateSubChannelCache(subChannelId, subChannel, params) {
|
|
6140
6139
|
pushToCache(['subChannel', 'get', subChannelId],
|
|
6141
6140
|
// eslint-disable-next-line prefer-object-spread
|
|
6142
|
-
|
|
6141
|
+
shallowClone(subChannel, params));
|
|
6143
6142
|
}
|
|
6144
6143
|
|
|
6145
6144
|
const handleMessageCreated = async (message) => {
|
|
@@ -6318,81 +6317,6 @@ const handleSubChannelUpdated = async (subChannel) => {
|
|
|
6318
6317
|
}
|
|
6319
6318
|
};
|
|
6320
6319
|
|
|
6321
|
-
const getCachedMarker$1 = (entityId) => {
|
|
6322
|
-
var _a;
|
|
6323
|
-
const key = {
|
|
6324
|
-
entityId,
|
|
6325
|
-
userId: getActiveUser()._id,
|
|
6326
|
-
};
|
|
6327
|
-
return (_a = pullFromCache([
|
|
6328
|
-
'channelMarker',
|
|
6329
|
-
'get',
|
|
6330
|
-
getResolver('channelMarker')(key),
|
|
6331
|
-
])) === null || _a === void 0 ? void 0 : _a.data;
|
|
6332
|
-
};
|
|
6333
|
-
const getUnreadInfoCached$1 = (channelId) => {
|
|
6334
|
-
var _a;
|
|
6335
|
-
return (_a = pullFromCache(['channelUnreadInfo', 'get', channelId])) === null || _a === void 0 ? void 0 : _a.data;
|
|
6336
|
-
};
|
|
6337
|
-
/**
|
|
6338
|
-
* The function use to get value of unreadCount field.
|
|
6339
|
-
* function will get the value from marker params first, if there is no hasMentioned field, will look in to the cache.
|
|
6340
|
-
*
|
|
6341
|
-
* If consistent mode is enabled, the function will return the value from the channelUnreadCountInfo cache.
|
|
6342
|
-
* If not, the function will return the value from the channelMarker cache.
|
|
6343
|
-
* If not found in the both cache, use `0` as defaul value.
|
|
6344
|
-
*/
|
|
6345
|
-
const getSubChannelsUnreadCount = (channel, marker) => {
|
|
6346
|
-
var _a, _b, _c, _d, _e;
|
|
6347
|
-
const client = getActiveClient();
|
|
6348
|
-
if (client.isUnreadCountEnabled && client.getMarkerSyncConsistentMode()) {
|
|
6349
|
-
// Marker service API uses channelInternalId as channelId
|
|
6350
|
-
return (_b = (_a = getUnreadInfoCached$1(channel.channelInternalId)) === null || _a === void 0 ? void 0 : _a.unreadCount) !== null && _b !== void 0 ? _b : 0;
|
|
6351
|
-
}
|
|
6352
|
-
if (marker === null || marker === void 0 ? void 0 : marker.isDeleted) {
|
|
6353
|
-
// NOTE: This is a temporary solution to handle the channel marker when the user is forced to
|
|
6354
|
-
// leave the channel because currently backend can't handle this, so every time a user is banned
|
|
6355
|
-
// from a channel or the channel is deleted the channel's unread count will reset to zero
|
|
6356
|
-
return 0;
|
|
6357
|
-
}
|
|
6358
|
-
return (_e = (_c = marker === null || marker === void 0 ? void 0 : marker.unreadCount) !== null && _c !== void 0 ? _c : (_d = getCachedMarker$1(channel.channelInternalId)) === null || _d === void 0 ? void 0 : _d.unreadCount) !== null && _e !== void 0 ? _e : 0;
|
|
6359
|
-
};
|
|
6360
|
-
|
|
6361
|
-
const getCachedMarker = (entityId) => {
|
|
6362
|
-
var _a;
|
|
6363
|
-
const key = {
|
|
6364
|
-
entityId,
|
|
6365
|
-
userId: getActiveUser()._id,
|
|
6366
|
-
};
|
|
6367
|
-
return (_a = pullFromCache([
|
|
6368
|
-
'channelMarker',
|
|
6369
|
-
'get',
|
|
6370
|
-
getResolver('channelMarker')(key),
|
|
6371
|
-
])) === null || _a === void 0 ? void 0 : _a.data;
|
|
6372
|
-
};
|
|
6373
|
-
const getUnreadInfoCached = (channelId) => {
|
|
6374
|
-
var _a;
|
|
6375
|
-
return (_a = pullFromCache(['channelUnreadInfo', 'get', channelId])) === null || _a === void 0 ? void 0 : _a.data;
|
|
6376
|
-
};
|
|
6377
|
-
/**
|
|
6378
|
-
* The function use to get value of hasMentioned or isMentioned field.
|
|
6379
|
-
* function will get the value from marker params first, if there is no hasMentioned field, will look in to the cache.
|
|
6380
|
-
*
|
|
6381
|
-
* If consistent mode is enabled, the function will return the value from the channelUnreadCountInfo cache.
|
|
6382
|
-
* If not, the function will return the value from the channelMarker cache.
|
|
6383
|
-
* If not found in the both cache, use `false` as defaul value.
|
|
6384
|
-
*/
|
|
6385
|
-
const getChannelIsMentioned = (channel, marker) => {
|
|
6386
|
-
var _a, _b, _c, _d;
|
|
6387
|
-
const client = getActiveClient();
|
|
6388
|
-
if (client.isUnreadCountEnabled && client.getMarkerSyncConsistentMode()) {
|
|
6389
|
-
return (_b = (_a = getUnreadInfoCached(channel.channelPublicId)) === null || _a === void 0 ? void 0 : _a.isMentioned) !== null && _b !== void 0 ? _b : false;
|
|
6390
|
-
}
|
|
6391
|
-
return (marker === null || marker === void 0 ? void 0 : marker.hasMentioned) !== undefined
|
|
6392
|
-
? marker === null || marker === void 0 ? void 0 : marker.hasMentioned
|
|
6393
|
-
: (_d = (_c = getCachedMarker(channel.channelPublicId)) === null || _c === void 0 ? void 0 : _c.hasMentioned) !== null && _d !== void 0 ? _d : false;
|
|
6394
|
-
};
|
|
6395
|
-
|
|
6396
6320
|
function convertRawUserToInternalUser(rawUser) {
|
|
6397
6321
|
return Object.assign(Object.assign({}, rawUser), { isGlobalBanned: (rawUser === null || rawUser === void 0 ? void 0 : rawUser.isGlobalBan) || false });
|
|
6398
6322
|
}
|
|
@@ -6410,18 +6334,7 @@ function convertFromRaw$2(channel, options = { isMessagePreviewUpdated: true })
|
|
|
6410
6334
|
if ((messagePreviewChannelCache === null || messagePreviewChannelCache === void 0 ? void 0 : messagePreviewChannelCache.messagePreviewId) && !options.isMessagePreviewUpdated) {
|
|
6411
6335
|
messagePreviewId = messagePreviewChannelCache.messagePreviewId;
|
|
6412
6336
|
}
|
|
6413
|
-
return Object.assign(Object.assign({
|
|
6414
|
-
return getSubChannelsUnreadCount(channel);
|
|
6415
|
-
},
|
|
6416
|
-
get hasMentioned() {
|
|
6417
|
-
return getChannelIsMentioned(channel);
|
|
6418
|
-
},
|
|
6419
|
-
get isMentioned() {
|
|
6420
|
-
return getChannelIsMentioned(channel);
|
|
6421
|
-
},
|
|
6422
|
-
get subChannelsUnreadCount() {
|
|
6423
|
-
return getSubChannelsUnreadCount(channel);
|
|
6424
|
-
} }, channel), { defaultSubChannelId: channel.channelInternalId, isUnreadCountSupport: isUnreadCountSupport$2(channel), messagePreviewId });
|
|
6337
|
+
return Object.assign(Object.assign({}, channel), { defaultSubChannelId: channel.channelInternalId, isUnreadCountSupport: isUnreadCountSupport$2(channel), messagePreviewId });
|
|
6425
6338
|
}
|
|
6426
6339
|
const preUpdateChannelCache = (rawPayload, options = { isMessagePreviewUpdated: true }) => {
|
|
6427
6340
|
ingestInCache({
|
|
@@ -6543,6 +6456,98 @@ const prepareUnreadCountInfo = async (rawPayload) => {
|
|
|
6543
6456
|
client.log('channel/prepareUnreadCountInfo', rawPayload.channels);
|
|
6544
6457
|
};
|
|
6545
6458
|
|
|
6459
|
+
const getCachedMarker$1 = (entityId) => {
|
|
6460
|
+
var _a;
|
|
6461
|
+
const key = {
|
|
6462
|
+
entityId,
|
|
6463
|
+
userId: getActiveUser()._id,
|
|
6464
|
+
};
|
|
6465
|
+
return (_a = pullFromCache([
|
|
6466
|
+
'channelMarker',
|
|
6467
|
+
'get',
|
|
6468
|
+
getResolver('channelMarker')(key),
|
|
6469
|
+
])) === null || _a === void 0 ? void 0 : _a.data;
|
|
6470
|
+
};
|
|
6471
|
+
const getUnreadInfoCached$1 = (channelId) => {
|
|
6472
|
+
var _a;
|
|
6473
|
+
return (_a = pullFromCache(['channelUnreadInfo', 'get', channelId])) === null || _a === void 0 ? void 0 : _a.data;
|
|
6474
|
+
};
|
|
6475
|
+
/**
|
|
6476
|
+
* The function use to get value of hasMentioned or isMentioned field.
|
|
6477
|
+
* function will get the value from marker params first, if there is no hasMentioned field, will look in to the cache.
|
|
6478
|
+
*
|
|
6479
|
+
* If consistent mode is enabled, the function will return the value from the channelUnreadCountInfo cache.
|
|
6480
|
+
* If not, the function will return the value from the channelMarker cache.
|
|
6481
|
+
* If not found in the both cache, use `false` as defaul value.
|
|
6482
|
+
*/
|
|
6483
|
+
const getChannelIsMentioned = (channel, marker) => {
|
|
6484
|
+
var _a, _b, _c, _d;
|
|
6485
|
+
const client = getActiveClient();
|
|
6486
|
+
if (client.isUnreadCountEnabled && client.getMarkerSyncConsistentMode()) {
|
|
6487
|
+
return (_b = (_a = getUnreadInfoCached$1(channel.channelPublicId)) === null || _a === void 0 ? void 0 : _a.isMentioned) !== null && _b !== void 0 ? _b : false;
|
|
6488
|
+
}
|
|
6489
|
+
return (marker === null || marker === void 0 ? void 0 : marker.hasMentioned) !== undefined
|
|
6490
|
+
? marker === null || marker === void 0 ? void 0 : marker.hasMentioned
|
|
6491
|
+
: (_d = (_c = getCachedMarker$1(channel.channelPublicId)) === null || _c === void 0 ? void 0 : _c.hasMentioned) !== null && _d !== void 0 ? _d : false;
|
|
6492
|
+
};
|
|
6493
|
+
|
|
6494
|
+
const getCachedMarker = (entityId) => {
|
|
6495
|
+
var _a;
|
|
6496
|
+
const key = {
|
|
6497
|
+
entityId,
|
|
6498
|
+
userId: getActiveUser()._id,
|
|
6499
|
+
};
|
|
6500
|
+
return (_a = pullFromCache([
|
|
6501
|
+
'channelMarker',
|
|
6502
|
+
'get',
|
|
6503
|
+
getResolver('channelMarker')(key),
|
|
6504
|
+
])) === null || _a === void 0 ? void 0 : _a.data;
|
|
6505
|
+
};
|
|
6506
|
+
const getUnreadInfoCached = (channelId) => {
|
|
6507
|
+
var _a;
|
|
6508
|
+
return (_a = pullFromCache(['channelUnreadInfo', 'get', channelId])) === null || _a === void 0 ? void 0 : _a.data;
|
|
6509
|
+
};
|
|
6510
|
+
/**
|
|
6511
|
+
* The function use to get value of unreadCount field.
|
|
6512
|
+
* function will get the value from marker params first, if there is no hasMentioned field, will look in to the cache.
|
|
6513
|
+
*
|
|
6514
|
+
* If consistent mode is enabled, the function will return the value from the channelUnreadCountInfo cache.
|
|
6515
|
+
* If not, the function will return the value from the channelMarker cache.
|
|
6516
|
+
* If not found in the both cache, use `0` as defaul value.
|
|
6517
|
+
*/
|
|
6518
|
+
const getSubChannelsUnreadCount = (channel, marker) => {
|
|
6519
|
+
var _a, _b, _c, _d, _e;
|
|
6520
|
+
const client = getActiveClient();
|
|
6521
|
+
if (client.isUnreadCountEnabled && client.getMarkerSyncConsistentMode()) {
|
|
6522
|
+
// Marker service API uses channelInternalId as channelId
|
|
6523
|
+
return (_b = (_a = getUnreadInfoCached(channel.channelInternalId)) === null || _a === void 0 ? void 0 : _a.unreadCount) !== null && _b !== void 0 ? _b : 0;
|
|
6524
|
+
}
|
|
6525
|
+
if (marker === null || marker === void 0 ? void 0 : marker.isDeleted) {
|
|
6526
|
+
// NOTE: This is a temporary solution to handle the channel marker when the user is forced to
|
|
6527
|
+
// leave the channel because currently backend can't handle this, so every time a user is banned
|
|
6528
|
+
// from a channel or the channel is deleted the channel's unread count will reset to zero
|
|
6529
|
+
return 0;
|
|
6530
|
+
}
|
|
6531
|
+
return (_e = (_c = marker === null || marker === void 0 ? void 0 : marker.unreadCount) !== null && _c !== void 0 ? _c : (_d = getCachedMarker(channel.channelInternalId)) === null || _d === void 0 ? void 0 : _d.unreadCount) !== null && _e !== void 0 ? _e : 0;
|
|
6532
|
+
};
|
|
6533
|
+
|
|
6534
|
+
const constructChannelDynamicValue = (channel) => {
|
|
6535
|
+
return shallowClone(channel, {
|
|
6536
|
+
get unreadCount() {
|
|
6537
|
+
return getSubChannelsUnreadCount(channel);
|
|
6538
|
+
},
|
|
6539
|
+
get hasMentioned() {
|
|
6540
|
+
return getChannelIsMentioned(channel);
|
|
6541
|
+
},
|
|
6542
|
+
get isMentioned() {
|
|
6543
|
+
return getChannelIsMentioned(channel);
|
|
6544
|
+
},
|
|
6545
|
+
get subChannelsUnreadCount() {
|
|
6546
|
+
return getSubChannelsUnreadCount(channel);
|
|
6547
|
+
},
|
|
6548
|
+
});
|
|
6549
|
+
};
|
|
6550
|
+
|
|
6546
6551
|
/**
|
|
6547
6552
|
* ```js
|
|
6548
6553
|
* import { getChannelByIds } from '@amityco/ts-sdk-react-native'
|
|
@@ -6587,7 +6592,7 @@ const getChannelByIds = async (channelIds) => {
|
|
|
6587
6592
|
ingestInCache(data, { cachedAt });
|
|
6588
6593
|
fireEvent('local.channel.fetched', data.channels);
|
|
6589
6594
|
return {
|
|
6590
|
-
data: data.channels.map(channel => LinkedObject.channel(channel)),
|
|
6595
|
+
data: data.channels.map(channel => LinkedObject.channel(constructChannelDynamicValue(channel))),
|
|
6591
6596
|
cachedAt,
|
|
6592
6597
|
};
|
|
6593
6598
|
};
|
|
@@ -14856,7 +14861,7 @@ const createChannel = async (bundle) => {
|
|
|
14856
14861
|
ingestInCache(data, { cachedAt });
|
|
14857
14862
|
const { channels } = data;
|
|
14858
14863
|
return {
|
|
14859
|
-
data: channels[0],
|
|
14864
|
+
data: constructChannelDynamicValue(channels[0]),
|
|
14860
14865
|
cachedAt,
|
|
14861
14866
|
};
|
|
14862
14867
|
};
|
|
@@ -14890,7 +14895,7 @@ const updateChannel = async (channelId, patch) => {
|
|
|
14890
14895
|
ingestInCache(data, { cachedAt });
|
|
14891
14896
|
const { channels } = data;
|
|
14892
14897
|
return {
|
|
14893
|
-
data: channels.find(channel => channel.channelId === channelId),
|
|
14898
|
+
data: constructChannelDynamicValue(channels.find(channel => channel.channelId === channelId)),
|
|
14894
14899
|
cachedAt,
|
|
14895
14900
|
};
|
|
14896
14901
|
};
|
|
@@ -14934,7 +14939,7 @@ const getChannel$1 = async (channelId) => {
|
|
|
14934
14939
|
ingestInCache(data, { cachedAt });
|
|
14935
14940
|
const { channels } = data;
|
|
14936
14941
|
return {
|
|
14937
|
-
data: channels.find(channel => channel.channelId === channelId),
|
|
14942
|
+
data: constructChannelDynamicValue(channels.find(channel => channel.channelId === channelId)),
|
|
14938
14943
|
cachedAt,
|
|
14939
14944
|
};
|
|
14940
14945
|
};
|
|
@@ -14964,7 +14969,7 @@ getChannel$1.locally = (channelId) => {
|
|
|
14964
14969
|
if (!cached || (cached === null || cached === void 0 ? void 0 : cached.length) === 0)
|
|
14965
14970
|
return;
|
|
14966
14971
|
return {
|
|
14967
|
-
data: cached[0].data,
|
|
14972
|
+
data: constructChannelDynamicValue(cached[0].data),
|
|
14968
14973
|
cachedAt: cached[0].cachedAt,
|
|
14969
14974
|
};
|
|
14970
14975
|
};
|
|
@@ -15162,10 +15167,10 @@ const observeChannel = (channelId, callback) => {
|
|
|
15162
15167
|
if (((_a = result.data) === null || _a === void 0 ? void 0 : _a.channelId) !== channelId)
|
|
15163
15168
|
return;
|
|
15164
15169
|
if (callback instanceof Function)
|
|
15165
|
-
return callback(Object.assign(Object.assign({}, result), { data: LinkedObject.channel(result.data) }));
|
|
15170
|
+
return callback(Object.assign(Object.assign({}, result), { data: LinkedObject.channel(constructChannelDynamicValue(result.data)) }));
|
|
15166
15171
|
if (action !== 'onFetch')
|
|
15167
|
-
(_b = callback.onEvent) === null || _b === void 0 ? void 0 : _b.call(callback, action, Object.assign(Object.assign({}, result), { data: LinkedObject.channel(result.data) }));
|
|
15168
|
-
(_c = callback[action]) === null || _c === void 0 ? void 0 : _c.call(callback, Object.assign(Object.assign({}, result), { data: LinkedObject.channel(result.data) }));
|
|
15172
|
+
(_b = callback.onEvent) === null || _b === void 0 ? void 0 : _b.call(callback, action, Object.assign(Object.assign({}, result), { data: LinkedObject.channel(constructChannelDynamicValue(result.data)) }));
|
|
15173
|
+
(_c = callback[action]) === null || _c === void 0 ? void 0 : _c.call(callback, Object.assign(Object.assign({}, result), { data: LinkedObject.channel(constructChannelDynamicValue(result.data)) }));
|
|
15169
15174
|
};
|
|
15170
15175
|
const disposers = [];
|
|
15171
15176
|
disposers.push(onChannelUpdated(data => router({ data, loading: false, origin: 'event' }, "onUpdate" /* Amity.ChannelActionType.OnUpdate */)), onChannelDeleted(data => router({ data, loading: false, origin: 'event' }, "onDelete" /* Amity.ChannelActionType.OnDelete */)), onChannelJoined(data => router({ data, loading: false, origin: 'event' }, "onJoin" /* Amity.ChannelActionType.OnJoin */)), onChannelLeft(data => router({ data, loading: false, origin: 'event' }, "onLeft" /* Amity.ChannelActionType.OnLeft */)), onChannelMuted(data => router({ data, loading: false, origin: 'event' }, "onMute" /* Amity.ChannelActionType.OnMute */)), onChannelMemberAdded(data => router({ data, loading: false, origin: 'event' }, "onMemberAdded" /* Amity.ChannelActionType.OnMemberAdded */)), onChannelMemberRemoved(data => router({ data, loading: false, origin: 'event' }, "onMemberRemoved" /* Amity.ChannelActionType.OnMemberRemoved */)), convertEventPayload(onChannelMarkerFetched, 'entityId', 'channel')(data => router({ data, loading: false, origin: 'event' }, "onUpdate" /* Amity.ChannelActionType.OnUpdate */)));
|
|
@@ -15199,9 +15204,9 @@ const observeChannels = (callback) => {
|
|
|
15199
15204
|
const router = (channel, action) => {
|
|
15200
15205
|
var _a, _b;
|
|
15201
15206
|
if (callback instanceof Function)
|
|
15202
|
-
return callback(LinkedObject.channel(channel));
|
|
15203
|
-
(_a = callback.onEvent) === null || _a === void 0 ? void 0 : _a.call(callback, action, LinkedObject.channel(channel));
|
|
15204
|
-
(_b = callback[action]) === null || _b === void 0 ? void 0 : _b.call(callback, LinkedObject.channel(channel));
|
|
15207
|
+
return callback(LinkedObject.channel(constructChannelDynamicValue(channel)));
|
|
15208
|
+
(_a = callback.onEvent) === null || _a === void 0 ? void 0 : _a.call(callback, action, LinkedObject.channel(constructChannelDynamicValue(channel)));
|
|
15209
|
+
(_b = callback[action]) === null || _b === void 0 ? void 0 : _b.call(callback, LinkedObject.channel(constructChannelDynamicValue(channel)));
|
|
15205
15210
|
};
|
|
15206
15211
|
disposers.push(onChannelCreated(data => router(data, "onCreate" /* Amity.ChannelActionType.OnCreate */)), onChannelUpdated(data => router(data, "onUpdate" /* Amity.ChannelActionType.OnUpdate */)), onChannelDeleted(data => router(data, "onDelete" /* Amity.ChannelActionType.OnDelete */)), onChannelJoined(data => router(data, "onJoin" /* Amity.ChannelActionType.OnJoin */)), onChannelLeft(data => router(data, "onLeft" /* Amity.ChannelActionType.OnLeft */)), onChannelMuted(data => router(data, "onMute" /* Amity.ChannelActionType.OnMute */)), onChannelMemberAdded(data => router(data, "onMemberAdded" /* Amity.ChannelActionType.OnMemberAdded */)), onChannelMemberRemoved(data => router(data, "onMemberRemoved" /* Amity.ChannelActionType.OnMemberRemoved */)), convertEventPayload(onChannelMarkerFetched, 'entityId', 'channel')(data => router(data, "onUpdate" /* Amity.ChannelActionType.OnUpdate */)));
|
|
15207
15212
|
return () => {
|
|
@@ -15306,7 +15311,7 @@ const onSubChannelUpdated = (callback) => {
|
|
|
15306
15311
|
function updateChannelCache(channel, params) {
|
|
15307
15312
|
pushToCache(['channel', 'get', channel.channelId],
|
|
15308
15313
|
// eslint-disable-next-line prefer-object-spread
|
|
15309
|
-
|
|
15314
|
+
shallowClone(channel, params));
|
|
15310
15315
|
}
|
|
15311
15316
|
|
|
15312
15317
|
/**
|
|
@@ -17450,7 +17455,7 @@ const getChannel = (channelId, callback) => {
|
|
|
17450
17455
|
const reactor = async (response) => {
|
|
17451
17456
|
if (!response.data)
|
|
17452
17457
|
return callback(response);
|
|
17453
|
-
const data = Object.assign(Object.assign({}, response), { data: LinkedObject.channel(getChannelMessagePreviewWithUser(response.data)) });
|
|
17458
|
+
const data = Object.assign(Object.assign({}, response), { data: LinkedObject.channel(constructChannelDynamicValue(getChannelMessagePreviewWithUser(response.data))) });
|
|
17454
17459
|
const newSnapshot = __rest(data, ["origin"]);
|
|
17455
17460
|
/**
|
|
17456
17461
|
* check equality of previous data and current data to avoid redundancy
|
|
@@ -17788,6 +17793,7 @@ class ChannelLiveCollectionController extends LiveCollectionController {
|
|
|
17788
17793
|
.filter(Boolean)
|
|
17789
17794
|
.map(({ data }) => data)
|
|
17790
17795
|
.map(getChannelMessagePreviewWithUser)
|
|
17796
|
+
.map(constructChannelDynamicValue)
|
|
17791
17797
|
.map(LinkedObject.channel)) !== null && _b !== void 0 ? _b : [];
|
|
17792
17798
|
if (this.paginationController instanceof ChannelPaginationController) {
|
|
17793
17799
|
data = this.applyFilter(data);
|
|
@@ -18330,7 +18336,11 @@ const onUserDeleted$1 = (channelId) => (callback) => {
|
|
|
18330
18336
|
channelUserCacheKey,
|
|
18331
18337
|
])) === null || _a === void 0 ? void 0 : _a.data;
|
|
18332
18338
|
upsertInCache(['channelUsers', 'get', channelUserCacheKey], Object.assign(Object.assign({}, cacheData), { user }));
|
|
18333
|
-
const channel = (_b = pullFromCache([
|
|
18339
|
+
const channel = (_b = pullFromCache([
|
|
18340
|
+
'channel',
|
|
18341
|
+
'get',
|
|
18342
|
+
channelId,
|
|
18343
|
+
])) === null || _b === void 0 ? void 0 : _b.data;
|
|
18334
18344
|
if (!channel)
|
|
18335
18345
|
return;
|
|
18336
18346
|
callback(channel, cacheData);
|