@amityco/ts-sdk 6.4.1 → 6.4.2-045209e.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/live.d.ts +5 -0
- package/dist/@types/core/live.d.ts.map +1 -1
- package/dist/cache/api/mergeInCache.d.ts.map +1 -1
- package/dist/client/observers/getTotalUnreadCount.d.ts.map +1 -1
- package/dist/core/model/index.d.ts +1 -1
- package/dist/core/model/index.d.ts.map +1 -1
- package/dist/index.cjs.js +25 -28
- package/dist/index.esm.js +25 -28
- package/dist/index.umd.js +4 -4
- package/dist/userRepository/relationship/follow/observers/getFollowInfo.d.ts.map +1 -1
- package/dist/utils/index.d.ts +1 -1
- package/dist/utils/index.d.ts.map +1 -1
- package/dist/utils/liveObject.d.ts +1 -1
- package/dist/utils/liveObject.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/@types/core/live.ts +6 -0
- package/src/cache/api/mergeInCache.ts +5 -0
- package/src/client/observers/getTotalUnreadCount.ts +4 -9
- package/src/core/model/index.ts +6 -2
- package/src/subChannelRepository/observers/getSubChannels.ts +2 -2
- package/src/userRepository/relationship/follow/observers/getFollowInfo.ts +3 -1
- package/src/userRepository/relationship/follow/observers/tests/getFollowInfo.test.ts +5 -6
- package/src/utils/index.ts +4 -3
- package/src/utils/liveObject.ts +13 -22
- package/src/utils/tests/liveObject.test.ts +0 -17
|
@@ -8,6 +8,11 @@ declare global {
|
|
|
8
8
|
origin?: 'local' | 'server' | 'event';
|
|
9
9
|
};
|
|
10
10
|
type LiveObjectCallback<T extends any> = Amity.Listener<LiveObject<T>>;
|
|
11
|
+
type LiveObjectOptions<T extends Amity.Models[Amity.Domain], CallbackData extends any = any> = {
|
|
12
|
+
forceDispatch?: boolean;
|
|
13
|
+
callbackDataSelector?: (data: T) => CallbackData;
|
|
14
|
+
callbackFilter?: (currentModel: T, previousModel: T) => boolean;
|
|
15
|
+
};
|
|
11
16
|
type LiveCollection<T extends any> = LiveObject<T[]> & {
|
|
12
17
|
onNextPage: () => void;
|
|
13
18
|
hasNextPage: boolean;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"live.d.ts","sourceRoot":"","sources":["../../../src/@types/core/live.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC;AAEV,OAAO,CAAC,MAAM,CAAC;IACb,UAAU,KAAK,CAAC;QACd,KAAK,UAAU,CAAC,CAAC,SAAS,GAAG,IAAI;YAC/B,IAAI,EAAE,CAAC,CAAC;YACR,KAAK,CAAC,EAAE,GAAG,CAAC;YACZ,OAAO,EAAE,OAAO,CAAC;YACjB,MAAM,CAAC,EAAE,OAAO,GAAG,QAAQ,GAAG,OAAO,CAAC;SACvC,CAAC;QAEF,KAAK,kBAAkB,CAAC,CAAC,SAAS,GAAG,IAAI,KAAK,CAAC,QAAQ,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,CAAC;QAEvE,KAAK,cAAc,CAAC,CAAC,SAAS,GAAG,IAAI,UAAU,CAAC,CAAC,EAAE,CAAC,GAAG;YACrD,UAAU,EAAE,MAAM,IAAI,CAAC;YACvB,WAAW,EAAE,OAAO,CAAC;SACtB,CAAC;QAEF,KAAK,sBAAsB,CAAC,CAAC,SAAS,GAAG,IAAI,KAAK,CAAC,QAAQ,CAAC,cAAc,CAAC,CAAC,CAAC,CAAC,CAAC;QAE/E,KAAK,oBAAoB,GAAG;YAC1B,MAAM,CAAC,EAAE,OAAO,CAAC,KAAK,CAAC,WAAW,EAAE,UAAU,CAAC,CAAC;SACjD,CAAC;QAEF,KAAK,oBAAoB,CAAC,CAAC,SAAS,GAAG,IAAI,CAAC,GAAG;YAC7C,KAAK,CAAC,EAAE,MAAM,CAAC;SAChB,CAAC;QAEF,KAAK,mBAAmB,CAAC,CAAC,SAAS,GAAG,EAAE,CAAC,SAAS,GAAG,IAAI,IAAI,CAC3D,cAAc,CAAC,CAAC,CAAC,EACjB,MAAM,GAAG,OAAO,GAAG,SAAS,CAC7B,GAAG;YAAE,MAAM,EAAE,CAAC,CAAA;SAAE,CAAC;KACnB;CACF"}
|
|
1
|
+
{"version":3,"file":"live.d.ts","sourceRoot":"","sources":["../../../src/@types/core/live.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC;AAEV,OAAO,CAAC,MAAM,CAAC;IACb,UAAU,KAAK,CAAC;QACd,KAAK,UAAU,CAAC,CAAC,SAAS,GAAG,IAAI;YAC/B,IAAI,EAAE,CAAC,CAAC;YACR,KAAK,CAAC,EAAE,GAAG,CAAC;YACZ,OAAO,EAAE,OAAO,CAAC;YACjB,MAAM,CAAC,EAAE,OAAO,GAAG,QAAQ,GAAG,OAAO,CAAC;SACvC,CAAC;QAEF,KAAK,kBAAkB,CAAC,CAAC,SAAS,GAAG,IAAI,KAAK,CAAC,QAAQ,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,CAAC;QAEvE,KAAK,iBAAiB,CAAC,CAAC,SAAS,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,EAAE,YAAY,SAAS,GAAG,GAAG,GAAG,IAAI;YAC7F,aAAa,CAAC,EAAE,OAAO,CAAC;YACxB,oBAAoB,CAAC,EAAE,CAAC,IAAI,EAAE,CAAC,KAAK,YAAY,CAAC;YACjD,cAAc,CAAC,EAAE,CAAC,YAAY,EAAE,CAAC,EAAE,aAAa,EAAE,CAAC,KAAK,OAAO,CAAC;SACjE,CAAC;QAEF,KAAK,cAAc,CAAC,CAAC,SAAS,GAAG,IAAI,UAAU,CAAC,CAAC,EAAE,CAAC,GAAG;YACrD,UAAU,EAAE,MAAM,IAAI,CAAC;YACvB,WAAW,EAAE,OAAO,CAAC;SACtB,CAAC;QAEF,KAAK,sBAAsB,CAAC,CAAC,SAAS,GAAG,IAAI,KAAK,CAAC,QAAQ,CAAC,cAAc,CAAC,CAAC,CAAC,CAAC,CAAC;QAE/E,KAAK,oBAAoB,GAAG;YAC1B,MAAM,CAAC,EAAE,OAAO,CAAC,KAAK,CAAC,WAAW,EAAE,UAAU,CAAC,CAAC;SACjD,CAAC;QAEF,KAAK,oBAAoB,CAAC,CAAC,SAAS,GAAG,IAAI,CAAC,GAAG;YAC7C,KAAK,CAAC,EAAE,MAAM,CAAC;SAChB,CAAC;QAEF,KAAK,mBAAmB,CAAC,CAAC,SAAS,GAAG,EAAE,CAAC,SAAS,GAAG,IAAI,IAAI,CAC3D,cAAc,CAAC,CAAC,CAAC,EACjB,MAAM,GAAG,OAAO,GAAG,SAAS,CAC7B,GAAG;YAAE,MAAM,EAAE,CAAC,CAAA;SAAE,CAAC;KACnB;CACF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mergeInCache.d.ts","sourceRoot":"","sources":["../../../src/cache/api/mergeInCache.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"mergeInCache.d.ts","sourceRoot":"","sources":["../../../src/cache/api/mergeInCache.ts"],"names":[],"mappings":"AAMA;;;;;;;;;;;;;;;;;GAiBG;AACH,eAAO,MAAM,YAAY,gHAGb,MAAM,YAAY,KAC3B,OAmBF,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getTotalUnreadCount.d.ts","sourceRoot":"","sources":["../../../src/client/observers/getTotalUnreadCount.ts"],"names":[],"mappings":"AAOA;;;;;;;;;;;;;;;GAeG;AACH,eAAO,MAAM,mBAAmB,aACpB,MAAM,kBAAkB,CAAC,MAAM,CAAC,KACzC,MAAM,
|
|
1
|
+
{"version":3,"file":"getTotalUnreadCount.d.ts","sourceRoot":"","sources":["../../../src/client/observers/getTotalUnreadCount.ts"],"names":[],"mappings":"AAOA;;;;;;;;;;;;;;;GAeG;AACH,eAAO,MAAM,mBAAmB,aACpB,MAAM,kBAAkB,CAAC,MAAM,CAAC,KACzC,MAAM,YAqBR,CAAC"}
|
|
@@ -6,7 +6,7 @@ export * from './identifyModel';
|
|
|
6
6
|
*/
|
|
7
7
|
export declare const PAYLOAD2MODEL: Record<string, Amity.Domain>;
|
|
8
8
|
/** hidden */
|
|
9
|
-
export declare const
|
|
9
|
+
export declare const isOutdated: <T extends Amity.UpdatedAt>(prevData: T, nextData: T) => boolean;
|
|
10
10
|
/** hidden */
|
|
11
11
|
export declare function getFutureDate(date?: string | undefined): string;
|
|
12
12
|
/** hidden */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/core/model/index.ts"],"names":[],"mappings":"AAAA,cAAc,eAAe,CAAC;AAC9B,cAAc,iBAAiB,CAAC;AAEhC;;;GAGG;AACH,eAAO,MAAM,aAAa,EAAE,MAAM,CAAC,MAAM,EAAE,KAAK,CAAC,MAAM,CA+BtD,CAAC;AAEF,aAAa;AACb,eAAO,MAAM,UAAU,2DAA0D,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/core/model/index.ts"],"names":[],"mappings":"AAAA,cAAc,eAAe,CAAC;AAC9B,cAAc,iBAAiB,CAAC;AAEhC;;;GAGG;AACH,eAAO,MAAM,aAAa,EAAE,MAAM,CAAC,MAAM,EAAE,KAAK,CAAC,MAAM,CA+BtD,CAAC;AAEF,aAAa;AACb,eAAO,MAAM,UAAU,2DAA0D,OAMhF,CAAC;AAEF,aAAa;AACb,wBAAgB,aAAa,CAAC,IAAI,GAAE,MAAM,GAAG,SAAoC,GAAG,MAAM,CAEzF;AAED,aAAa;AACb,wBAAgB,WAAW,CAAC,IAAI,GAAE,MAAM,GAAG,SAAoC,GAAG,MAAM,CAEvF"}
|
package/dist/index.cjs.js
CHANGED
|
@@ -637,8 +637,11 @@ const PAYLOAD2MODEL = {
|
|
|
637
637
|
feeds: 'feed',
|
|
638
638
|
};
|
|
639
639
|
/** hidden */
|
|
640
|
-
const
|
|
641
|
-
|
|
640
|
+
const isOutdated = (prevData, nextData) => {
|
|
641
|
+
if ('updatedAt' in nextData && 'updatedAt' in nextData) {
|
|
642
|
+
return new Date(nextData.updatedAt) < new Date(prevData.updatedAt);
|
|
643
|
+
}
|
|
644
|
+
return false;
|
|
642
645
|
};
|
|
643
646
|
/** hidden */
|
|
644
647
|
function getFutureDate(date = new Date().toISOString()) {
|
|
@@ -995,6 +998,9 @@ const mergeInCache = (key, mutation, options) => {
|
|
|
995
998
|
if (!oldVal)
|
|
996
999
|
return false;
|
|
997
1000
|
const newVal = typeof mutation === 'function' ? mutation(oldVal.data) : Object.assign(Object.assign({}, oldVal.data), mutation);
|
|
1001
|
+
if (isOutdated(oldVal.data, newVal)) {
|
|
1002
|
+
return false;
|
|
1003
|
+
}
|
|
998
1004
|
pushToCache(key, newVal, options);
|
|
999
1005
|
return true;
|
|
1000
1006
|
};
|
|
@@ -22399,7 +22405,8 @@ function isEqual(x, y) {
|
|
|
22399
22405
|
}));
|
|
22400
22406
|
}
|
|
22401
22407
|
|
|
22402
|
-
const liveObject = (id, callback, key, fetcher, eventHandlers,
|
|
22408
|
+
const liveObject = (id, callback, key, fetcher, eventHandlers, options) => {
|
|
22409
|
+
const { forceDispatch, callbackDataSelector, callbackFilter } = Object.assign({ forceDispatch: false, callbackDataSelector: (data) => data }, options);
|
|
22403
22410
|
const { cache } = getActiveClient();
|
|
22404
22411
|
if (!cache) {
|
|
22405
22412
|
console.log(LIVE_OBJECT_ENABLE_CACHE_MESSAGE);
|
|
@@ -22414,28 +22421,13 @@ const liveObject = (id, callback, key, fetcher, eventHandlers, callbackDataSelec
|
|
|
22414
22421
|
}
|
|
22415
22422
|
model = newModel;
|
|
22416
22423
|
};
|
|
22417
|
-
const realtimeRouter = (eventModel) => {
|
|
22424
|
+
const realtimeRouter = (eventModel, forceDispatch = false) => {
|
|
22418
22425
|
if (id !== eventModel[key]) {
|
|
22419
22426
|
return;
|
|
22420
22427
|
}
|
|
22421
22428
|
if (model) {
|
|
22422
|
-
|
|
22423
|
-
|
|
22424
|
-
* Also, follow can have an event where the paylod is not updated i.e.
|
|
22425
|
-
* when a request is declined
|
|
22426
|
-
*/
|
|
22427
|
-
if ('updatedAt' in model && 'updatedAt' in eventModel) {
|
|
22428
|
-
/*
|
|
22429
|
-
* NOTE: the isEqual is added as a fail safe as the server does not update
|
|
22430
|
-
* the updatedAt when the model updates rather when the data in the data of
|
|
22431
|
-
* the model (if any) updates.
|
|
22432
|
-
*
|
|
22433
|
-
* Ex: post.addReaction | post.removeReaction does not update the updatedAt
|
|
22434
|
-
* of the post
|
|
22435
|
-
*/
|
|
22436
|
-
if (!hasUpdates(model, eventModel) || isEqual(model, eventModel)) {
|
|
22437
|
-
return;
|
|
22438
|
-
}
|
|
22429
|
+
if (!forceDispatch && isEqual(model, eventModel)) {
|
|
22430
|
+
return;
|
|
22439
22431
|
}
|
|
22440
22432
|
}
|
|
22441
22433
|
dispatcher({ loading: false, data: eventModel, origin: 'event' });
|
|
@@ -22464,7 +22456,7 @@ const liveObject = (id, callback, key, fetcher, eventHandlers, callbackDataSelec
|
|
|
22464
22456
|
}
|
|
22465
22457
|
});
|
|
22466
22458
|
};
|
|
22467
|
-
disposers.push(...eventHandlers.map(fn => fn(realtimeRouter)));
|
|
22459
|
+
disposers.push(...eventHandlers.map(fn => fn(eventModel => realtimeRouter(eventModel, forceDispatch))));
|
|
22468
22460
|
onFetch();
|
|
22469
22461
|
return () => {
|
|
22470
22462
|
disposers.forEach(fn => fn());
|
|
@@ -22491,11 +22483,14 @@ const getTotalUnreadCount = (callback) => {
|
|
|
22491
22483
|
const { _id: userId } = getActiveUser();
|
|
22492
22484
|
if (!userId)
|
|
22493
22485
|
throw new ASCError('The _id has not been defined in ActiveUser', 800000 /* Amity.ClientError.UNKNOWN_ERROR */, "error" /* Amity.ErrorLevel.ERROR */);
|
|
22494
|
-
const
|
|
22486
|
+
const callbackDataSelector = (data) => { var _a; return (_a = data === null || data === void 0 ? void 0 : data.unreadCount) !== null && _a !== void 0 ? _a : 0; };
|
|
22495
22487
|
// based on the mobile specs, unreadCount will not trigger observer when userMarker
|
|
22496
22488
|
// is re-fetched, so apply this filter to ensure the behavior is the same.
|
|
22497
22489
|
const callbackFilter = (newModel, oldModel) => (newModel === null || newModel === void 0 ? void 0 : newModel.unreadCount) !== (oldModel === null || oldModel === void 0 ? void 0 : oldModel.unreadCount);
|
|
22498
|
-
return liveObject(userId, callback, 'userId', getUserMarker, [onUserMarkerFetched],
|
|
22490
|
+
return liveObject(userId, callback, 'userId', getUserMarker, [onUserMarkerFetched], {
|
|
22491
|
+
callbackDataSelector,
|
|
22492
|
+
callbackFilter,
|
|
22493
|
+
});
|
|
22499
22494
|
};
|
|
22500
22495
|
|
|
22501
22496
|
/**
|
|
@@ -25478,7 +25473,9 @@ const getFollowings = (params, callback, config) => {
|
|
|
25478
25473
|
* @category FollowInfo Live Object
|
|
25479
25474
|
*/
|
|
25480
25475
|
const getFollowInfo = (userId, callback) => {
|
|
25481
|
-
return liveObject(userId, callback, 'userId', getFollowInfo$1, [onFollowInfoUpdated]
|
|
25476
|
+
return liveObject(userId, callback, 'userId', getFollowInfo$1, [onFollowInfoUpdated], {
|
|
25477
|
+
forceDispatch: true,
|
|
25478
|
+
});
|
|
25482
25479
|
};
|
|
25483
25480
|
/* end_public_function */
|
|
25484
25481
|
|
|
@@ -29218,12 +29215,12 @@ const getSubChannel = (subChannelId, callback) => {
|
|
|
29218
29215
|
};
|
|
29219
29216
|
/* end_public_function */
|
|
29220
29217
|
|
|
29221
|
-
function
|
|
29218
|
+
function shouldDispatchCollection(collection, newItem, action) {
|
|
29222
29219
|
const key = identifyModelKey(newItem);
|
|
29223
29220
|
// @ts-ignore
|
|
29224
29221
|
const item = collection.find(x => x[key] === newItem[key]);
|
|
29225
29222
|
if (item) {
|
|
29226
|
-
return
|
|
29223
|
+
return !isEqual(item, newItem);
|
|
29227
29224
|
}
|
|
29228
29225
|
return action === 'onCreate';
|
|
29229
29226
|
}
|
|
@@ -29370,7 +29367,7 @@ const getSubChannels = (params, callback, config) => {
|
|
|
29370
29367
|
const realtimeRouter = (action) => (subChannel) => {
|
|
29371
29368
|
if (params.channelId !== subChannel.channelId ||
|
|
29372
29369
|
!snapshot ||
|
|
29373
|
-
!
|
|
29370
|
+
!shouldDispatchCollection(snapshot.data, subChannel, action)) {
|
|
29374
29371
|
return;
|
|
29375
29372
|
}
|
|
29376
29373
|
if (action === 'onCreate') {
|
package/dist/index.esm.js
CHANGED
|
@@ -623,8 +623,11 @@ const PAYLOAD2MODEL = {
|
|
|
623
623
|
feeds: 'feed',
|
|
624
624
|
};
|
|
625
625
|
/** hidden */
|
|
626
|
-
const
|
|
627
|
-
|
|
626
|
+
const isOutdated = (prevData, nextData) => {
|
|
627
|
+
if ('updatedAt' in nextData && 'updatedAt' in nextData) {
|
|
628
|
+
return new Date(nextData.updatedAt) < new Date(prevData.updatedAt);
|
|
629
|
+
}
|
|
630
|
+
return false;
|
|
628
631
|
};
|
|
629
632
|
/** hidden */
|
|
630
633
|
function getFutureDate(date = new Date().toISOString()) {
|
|
@@ -981,6 +984,9 @@ const mergeInCache = (key, mutation, options) => {
|
|
|
981
984
|
if (!oldVal)
|
|
982
985
|
return false;
|
|
983
986
|
const newVal = typeof mutation === 'function' ? mutation(oldVal.data) : Object.assign(Object.assign({}, oldVal.data), mutation);
|
|
987
|
+
if (isOutdated(oldVal.data, newVal)) {
|
|
988
|
+
return false;
|
|
989
|
+
}
|
|
984
990
|
pushToCache(key, newVal, options);
|
|
985
991
|
return true;
|
|
986
992
|
};
|
|
@@ -22385,7 +22391,8 @@ function isEqual(x, y) {
|
|
|
22385
22391
|
}));
|
|
22386
22392
|
}
|
|
22387
22393
|
|
|
22388
|
-
const liveObject = (id, callback, key, fetcher, eventHandlers,
|
|
22394
|
+
const liveObject = (id, callback, key, fetcher, eventHandlers, options) => {
|
|
22395
|
+
const { forceDispatch, callbackDataSelector, callbackFilter } = Object.assign({ forceDispatch: false, callbackDataSelector: (data) => data }, options);
|
|
22389
22396
|
const { cache } = getActiveClient();
|
|
22390
22397
|
if (!cache) {
|
|
22391
22398
|
console.log(LIVE_OBJECT_ENABLE_CACHE_MESSAGE);
|
|
@@ -22400,28 +22407,13 @@ const liveObject = (id, callback, key, fetcher, eventHandlers, callbackDataSelec
|
|
|
22400
22407
|
}
|
|
22401
22408
|
model = newModel;
|
|
22402
22409
|
};
|
|
22403
|
-
const realtimeRouter = (eventModel) => {
|
|
22410
|
+
const realtimeRouter = (eventModel, forceDispatch = false) => {
|
|
22404
22411
|
if (id !== eventModel[key]) {
|
|
22405
22412
|
return;
|
|
22406
22413
|
}
|
|
22407
22414
|
if (model) {
|
|
22408
|
-
|
|
22409
|
-
|
|
22410
|
-
* Also, follow can have an event where the paylod is not updated i.e.
|
|
22411
|
-
* when a request is declined
|
|
22412
|
-
*/
|
|
22413
|
-
if ('updatedAt' in model && 'updatedAt' in eventModel) {
|
|
22414
|
-
/*
|
|
22415
|
-
* NOTE: the isEqual is added as a fail safe as the server does not update
|
|
22416
|
-
* the updatedAt when the model updates rather when the data in the data of
|
|
22417
|
-
* the model (if any) updates.
|
|
22418
|
-
*
|
|
22419
|
-
* Ex: post.addReaction | post.removeReaction does not update the updatedAt
|
|
22420
|
-
* of the post
|
|
22421
|
-
*/
|
|
22422
|
-
if (!hasUpdates(model, eventModel) || isEqual(model, eventModel)) {
|
|
22423
|
-
return;
|
|
22424
|
-
}
|
|
22415
|
+
if (!forceDispatch && isEqual(model, eventModel)) {
|
|
22416
|
+
return;
|
|
22425
22417
|
}
|
|
22426
22418
|
}
|
|
22427
22419
|
dispatcher({ loading: false, data: eventModel, origin: 'event' });
|
|
@@ -22450,7 +22442,7 @@ const liveObject = (id, callback, key, fetcher, eventHandlers, callbackDataSelec
|
|
|
22450
22442
|
}
|
|
22451
22443
|
});
|
|
22452
22444
|
};
|
|
22453
|
-
disposers.push(...eventHandlers.map(fn => fn(realtimeRouter)));
|
|
22445
|
+
disposers.push(...eventHandlers.map(fn => fn(eventModel => realtimeRouter(eventModel, forceDispatch))));
|
|
22454
22446
|
onFetch();
|
|
22455
22447
|
return () => {
|
|
22456
22448
|
disposers.forEach(fn => fn());
|
|
@@ -22477,11 +22469,14 @@ const getTotalUnreadCount = (callback) => {
|
|
|
22477
22469
|
const { _id: userId } = getActiveUser();
|
|
22478
22470
|
if (!userId)
|
|
22479
22471
|
throw new ASCError('The _id has not been defined in ActiveUser', 800000 /* Amity.ClientError.UNKNOWN_ERROR */, "error" /* Amity.ErrorLevel.ERROR */);
|
|
22480
|
-
const
|
|
22472
|
+
const callbackDataSelector = (data) => { var _a; return (_a = data === null || data === void 0 ? void 0 : data.unreadCount) !== null && _a !== void 0 ? _a : 0; };
|
|
22481
22473
|
// based on the mobile specs, unreadCount will not trigger observer when userMarker
|
|
22482
22474
|
// is re-fetched, so apply this filter to ensure the behavior is the same.
|
|
22483
22475
|
const callbackFilter = (newModel, oldModel) => (newModel === null || newModel === void 0 ? void 0 : newModel.unreadCount) !== (oldModel === null || oldModel === void 0 ? void 0 : oldModel.unreadCount);
|
|
22484
|
-
return liveObject(userId, callback, 'userId', getUserMarker, [onUserMarkerFetched],
|
|
22476
|
+
return liveObject(userId, callback, 'userId', getUserMarker, [onUserMarkerFetched], {
|
|
22477
|
+
callbackDataSelector,
|
|
22478
|
+
callbackFilter,
|
|
22479
|
+
});
|
|
22485
22480
|
};
|
|
22486
22481
|
|
|
22487
22482
|
/**
|
|
@@ -25464,7 +25459,9 @@ const getFollowings = (params, callback, config) => {
|
|
|
25464
25459
|
* @category FollowInfo Live Object
|
|
25465
25460
|
*/
|
|
25466
25461
|
const getFollowInfo = (userId, callback) => {
|
|
25467
|
-
return liveObject(userId, callback, 'userId', getFollowInfo$1, [onFollowInfoUpdated]
|
|
25462
|
+
return liveObject(userId, callback, 'userId', getFollowInfo$1, [onFollowInfoUpdated], {
|
|
25463
|
+
forceDispatch: true,
|
|
25464
|
+
});
|
|
25468
25465
|
};
|
|
25469
25466
|
/* end_public_function */
|
|
25470
25467
|
|
|
@@ -29204,12 +29201,12 @@ const getSubChannel = (subChannelId, callback) => {
|
|
|
29204
29201
|
};
|
|
29205
29202
|
/* end_public_function */
|
|
29206
29203
|
|
|
29207
|
-
function
|
|
29204
|
+
function shouldDispatchCollection(collection, newItem, action) {
|
|
29208
29205
|
const key = identifyModelKey(newItem);
|
|
29209
29206
|
// @ts-ignore
|
|
29210
29207
|
const item = collection.find(x => x[key] === newItem[key]);
|
|
29211
29208
|
if (item) {
|
|
29212
|
-
return
|
|
29209
|
+
return !isEqual(item, newItem);
|
|
29213
29210
|
}
|
|
29214
29211
|
return action === 'onCreate';
|
|
29215
29212
|
}
|
|
@@ -29356,7 +29353,7 @@ const getSubChannels = (params, callback, config) => {
|
|
|
29356
29353
|
const realtimeRouter = (action) => (subChannel) => {
|
|
29357
29354
|
if (params.channelId !== subChannel.channelId ||
|
|
29358
29355
|
!snapshot ||
|
|
29359
|
-
!
|
|
29356
|
+
!shouldDispatchCollection(snapshot.data, subChannel, action)) {
|
|
29360
29357
|
return;
|
|
29361
29358
|
}
|
|
29362
29359
|
if (action === 'onCreate') {
|