@amityco/ts-sdk 7.1.1-61f30ce0.0 → 7.1.1-67cf0d9.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 +2 -5
- package/dist/@types/core/events.d.ts.map +1 -1
- package/dist/@types/core/model.d.ts +2 -4
- package/dist/@types/core/model.d.ts.map +1 -1
- package/dist/@types/core/payload.d.ts +0 -18
- package/dist/@types/core/payload.d.ts.map +1 -1
- package/dist/@types/core/readReceipt.d.ts +12 -1
- package/dist/@types/core/readReceipt.d.ts.map +1 -1
- package/dist/@types/domains/channel.d.ts +10 -0
- package/dist/@types/domains/channel.d.ts.map +1 -1
- package/dist/@types/domains/client.d.ts +2 -0
- package/dist/@types/domains/client.d.ts.map +1 -1
- package/dist/channelRepository/api/markChannelsAsReadBySegment.d.ts +16 -0
- package/dist/channelRepository/api/markChannelsAsReadBySegment.d.ts.map +1 -0
- package/dist/channelRepository/events/onChannelDeleted.d.ts.map +1 -1
- package/dist/channelRepository/events/onChannelLeft.d.ts.map +1 -1
- package/dist/{marker → channelRepository}/events/onChannelUnreadUpdatedLocal.d.ts +2 -2
- package/dist/channelRepository/events/onChannelUnreadUpdatedLocal.d.ts.map +1 -0
- package/dist/channelRepository/internalApi/getTotalChannelsUnread.d.ts +11 -0
- package/dist/channelRepository/internalApi/getTotalChannelsUnread.d.ts.map +1 -0
- 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/getTotalChannelsUnread.d.ts +20 -0
- package/dist/channelRepository/observers/getTotalChannelsUnread.d.ts.map +1 -0
- package/dist/channelRepository/observers/index.d.ts +1 -0
- package/dist/channelRepository/observers/index.d.ts.map +1 -1
- package/dist/channelRepository/utils/constructChannelDynamicValue.d.ts.map +1 -1
- package/dist/channelRepository/utils/getLegacyChannelUnread.d.ts +2 -0
- package/dist/channelRepository/utils/getLegacyChannelUnread.d.ts.map +1 -0
- package/dist/channelRepository/utils/prepareChannelPayload.d.ts.map +1 -1
- package/dist/client/api/createClient.d.ts +1 -0
- package/dist/client/api/createClient.d.ts.map +1 -1
- package/dist/client/api/enableUnreadCount.d.ts.map +1 -1
- package/dist/client/api/login.d.ts.map +1 -1
- package/dist/client/utils/ReadReceiptSync/legacyReadReceiptSyncEngine.d.ts +33 -0
- package/dist/client/utils/ReadReceiptSync/legacyReadReceiptSyncEngine.d.ts.map +1 -0
- package/dist/client/utils/ReadReceiptSync/legacyReadReceiptSyncEngineOnLoginHandler.d.ts +3 -0
- package/dist/client/utils/ReadReceiptSync/legacyReadReceiptSyncEngineOnLoginHandler.d.ts.map +1 -0
- package/dist/client/utils/ReadReceiptSync/readReceiptSyncEngine.d.ts +2 -4
- package/dist/client/utils/ReadReceiptSync/readReceiptSyncEngine.d.ts.map +1 -1
- package/dist/client/utils/endpoints.d.ts +1 -0
- package/dist/client/utils/endpoints.d.ts.map +1 -1
- package/dist/client/utils/setClientToken.d.ts.map +1 -1
- package/dist/core/events.d.ts +3 -3
- package/dist/core/events.d.ts.map +1 -1
- package/dist/core/model/idResolvers.d.ts.map +1 -1
- package/dist/core/model/index.d.ts.map +1 -1
- package/dist/index.cjs.js +599 -477
- package/dist/index.d.ts +0 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.esm.js +580 -457
- package/dist/index.umd.js +4 -4
- package/dist/marker/events/onChannelUnreadInfoUpdatedLocal.d.ts +12 -0
- package/dist/marker/events/onChannelUnreadInfoUpdatedLocal.d.ts.map +1 -0
- package/dist/messageRepository/events/onMessageCreated.d.ts.map +1 -1
- package/dist/messageRepository/observers/getMessage.d.ts.map +1 -1
- package/dist/messageRepository/utils/markReadMessage.d.ts.map +1 -1
- package/dist/utils/linkedObject/index.d.ts +0 -1
- package/dist/utils/linkedObject/index.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/@types/core/events.ts +2 -6
- package/src/@types/core/model.ts +4 -6
- package/src/@types/core/payload.ts +0 -25
- package/src/@types/core/readReceipt.ts +14 -1
- package/src/@types/domains/channel.ts +13 -0
- package/src/@types/domains/client.ts +3 -0
- package/src/channelRepository/api/markChannelsAsReadBySegment.ts +29 -0
- package/src/channelRepository/events/onChannelDeleted.ts +17 -4
- package/src/channelRepository/events/onChannelLeft.ts +11 -3
- package/src/{marker → channelRepository}/events/onChannelUnreadUpdatedLocal.ts +3 -3
- package/src/channelRepository/internalApi/getTotalChannelsUnread.ts +38 -0
- package/src/channelRepository/observers/getChannel.ts +3 -1
- package/src/channelRepository/observers/getChannels/ChannelLiveCollectionController.ts +6 -1
- package/src/channelRepository/observers/getTotalChannelsUnread.ts +129 -0
- package/src/channelRepository/observers/index.ts +1 -0
- package/src/channelRepository/utils/constructChannelDynamicValue.ts +12 -2
- package/src/channelRepository/utils/getLegacyChannelUnread.ts +5 -0
- package/src/channelRepository/utils/prepareChannelPayload.ts +68 -17
- package/src/client/api/createClient.ts +7 -1
- package/src/client/api/enableUnreadCount.ts +1 -0
- package/src/client/api/login.ts +5 -1
- package/src/client/utils/ReadReceiptSync/legacyReadReceiptSyncEngine.ts +267 -0
- package/src/client/utils/ReadReceiptSync/legacyReadReceiptSyncEngineOnLoginHandler.ts +21 -0
- package/src/client/utils/ReadReceiptSync/readReceiptSyncEngine.ts +74 -99
- package/src/client/utils/endpoints.ts +1 -0
- package/src/client/utils/setClientToken.ts +8 -0
- package/src/core/model/idResolvers.ts +2 -3
- package/src/core/model/index.ts +0 -2
- package/src/fileRepository/api/uploadFile.ts +1 -1
- package/src/fileRepository/api/uploadImage.ts +1 -1
- package/src/fileRepository/api/uploadVideo.ts +1 -1
- package/src/index.ts +0 -2
- package/src/marker/events/onChannelUnreadInfoUpdatedLocal.ts +29 -0
- package/src/messageRepository/events/onMessageCreated.ts +45 -1
- package/src/messageRepository/observers/getMessage.ts +0 -1
- package/src/messageRepository/utils/markReadMessage.ts +10 -3
- package/src/utils/linkedObject/index.ts +0 -2
- package/dist/@types/domains/notification.d.ts +0 -81
- package/dist/@types/domains/notification.d.ts.map +0 -1
- package/dist/marker/events/onChannelUnreadUpdatedLocal.d.ts.map +0 -1
- package/dist/notificationTrayRepository/api/index.d.ts +0 -3
- package/dist/notificationTrayRepository/api/index.d.ts.map +0 -1
- package/dist/notificationTrayRepository/api/markNotificationItemsSeen.d.ts +0 -16
- package/dist/notificationTrayRepository/api/markNotificationItemsSeen.d.ts.map +0 -1
- package/dist/notificationTrayRepository/api/markNotificationTraySeen.d.ts +0 -19
- package/dist/notificationTrayRepository/api/markNotificationTraySeen.d.ts.map +0 -1
- package/dist/notificationTrayRepository/events/index.d.ts +0 -2
- package/dist/notificationTrayRepository/events/index.d.ts.map +0 -1
- package/dist/notificationTrayRepository/events/onNotificationTraySeenUpdated.d.ts +0 -17
- package/dist/notificationTrayRepository/events/onNotificationTraySeenUpdated.d.ts.map +0 -1
- package/dist/notificationTrayRepository/index.d.ts +0 -4
- package/dist/notificationTrayRepository/index.d.ts.map +0 -1
- package/dist/notificationTrayRepository/internalApi/getNotificationTraySeen.d.ts +0 -30
- package/dist/notificationTrayRepository/internalApi/getNotificationTraySeen.d.ts.map +0 -1
- package/dist/notificationTrayRepository/observers/getNotificationTrayItems/NotificationTrayItemsLiveCollectionController.d.ts +0 -13
- package/dist/notificationTrayRepository/observers/getNotificationTrayItems/NotificationTrayItemsLiveCollectionController.d.ts.map +0 -1
- package/dist/notificationTrayRepository/observers/getNotificationTrayItems/NotificationTrayItemsPaginationController.d.ts +0 -9
- package/dist/notificationTrayRepository/observers/getNotificationTrayItems/NotificationTrayItemsPaginationController.d.ts.map +0 -1
- package/dist/notificationTrayRepository/observers/getNotificationTrayItems/NotificationTrayItemsQuerystreamController.d.ts +0 -9
- package/dist/notificationTrayRepository/observers/getNotificationTrayItems/NotificationTrayItemsQuerystreamController.d.ts.map +0 -1
- package/dist/notificationTrayRepository/observers/getNotificationTrayItems.d.ts +0 -12
- package/dist/notificationTrayRepository/observers/getNotificationTrayItems.d.ts.map +0 -1
- package/dist/notificationTrayRepository/observers/getNotificationTraySeen.d.ts +0 -21
- package/dist/notificationTrayRepository/observers/getNotificationTraySeen.d.ts.map +0 -1
- package/dist/notificationTrayRepository/observers/index.d.ts +0 -3
- package/dist/notificationTrayRepository/observers/index.d.ts.map +0 -1
- package/dist/notificationTrayRepository/utils/prepareNotificationTrayItemsPayload.d.ts +0 -2
- package/dist/notificationTrayRepository/utils/prepareNotificationTrayItemsPayload.d.ts.map +0 -1
- package/dist/utils/linkedObject/notificationTrayLinkedObject.d.ts +0 -2
- package/dist/utils/linkedObject/notificationTrayLinkedObject.d.ts.map +0 -1
- package/src/@types/domains/notification.ts +0 -90
- package/src/notificationTrayRepository/api/index.ts +0 -2
- package/src/notificationTrayRepository/api/markNotificationItemsSeen.ts +0 -59
- package/src/notificationTrayRepository/api/markNotificationTraySeen.ts +0 -65
- package/src/notificationTrayRepository/events/index.ts +0 -1
- package/src/notificationTrayRepository/events/onNotificationTraySeenUpdated.ts +0 -36
- package/src/notificationTrayRepository/index.ts +0 -3
- package/src/notificationTrayRepository/internalApi/getNotificationTraySeen.ts +0 -81
- package/src/notificationTrayRepository/observers/getNotificationTrayItems/NotificationTrayItemsLiveCollectionController.ts +0 -96
- package/src/notificationTrayRepository/observers/getNotificationTrayItems/NotificationTrayItemsPaginationController.ts +0 -31
- package/src/notificationTrayRepository/observers/getNotificationTrayItems/NotificationTrayItemsQuerystreamController.ts +0 -68
- package/src/notificationTrayRepository/observers/getNotificationTrayItems.ts +0 -44
- package/src/notificationTrayRepository/observers/getNotificationTraySeen.ts +0 -43
- package/src/notificationTrayRepository/observers/index.ts +0 -2
- package/src/notificationTrayRepository/utils/prepareNotificationTrayItemsPayload.ts +0 -12
- package/src/utils/linkedObject/notificationTrayLinkedObject.ts +0 -28
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* ```js
|
|
3
|
-
* import { onNotificationTraySeenUpdated } from '@amityco/ts-sdk'
|
|
4
|
-
* const dispose = onNotificationTraySeenUpdated(data => {
|
|
5
|
-
* // ...
|
|
6
|
-
* })
|
|
7
|
-
* ```
|
|
8
|
-
*
|
|
9
|
-
* Fired when an {@link Amity.NotificationTraySeen} has been updated
|
|
10
|
-
*
|
|
11
|
-
* @param callback The function to call when the event was fired
|
|
12
|
-
* @returns an {@link Amity.Unsubscriber} function to stop listening
|
|
13
|
-
*
|
|
14
|
-
* @category NotificationTraySeen Events
|
|
15
|
-
*/
|
|
16
|
-
export declare const onNotificationTraySeenUpdated: (callback: Amity.Listener<Amity.InternalNotificationTraySeen>) => Amity.Unsubscriber;
|
|
17
|
-
//# sourceMappingURL=onNotificationTraySeenUpdated.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"onNotificationTraySeenUpdated.d.ts","sourceRoot":"","sources":["../../../src/notificationTrayRepository/events/onNotificationTraySeenUpdated.ts"],"names":[],"mappings":"AAGA;;;;;;;;;;;;;;GAcG;AACH,eAAO,MAAM,6BAA6B,aAC9B,MAAM,QAAQ,CAAC,MAAM,4BAA4B,CAAC,KAC3D,MAAM,YAeR,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/notificationTrayRepository/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC;AAC5B,cAAc,OAAO,CAAC;AACtB,cAAc,UAAU,CAAC"}
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* ```js
|
|
3
|
-
* import { NotificationTrayRepository } from '@amityco/ts-sdk'
|
|
4
|
-
* const notificationTraySeen = await NotificationTrayRepository.getNotificationTraySeen()
|
|
5
|
-
* ```
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
* @returns A page of {@link Amity.NotificationTraySeen} objects
|
|
9
|
-
*
|
|
10
|
-
* @category NotificationTray API
|
|
11
|
-
* @async
|
|
12
|
-
* */
|
|
13
|
-
export declare const getNotificationTraySeen: {
|
|
14
|
-
(): Promise<Amity.Cached<Amity.NotificationTraySeen>>;
|
|
15
|
-
/**
|
|
16
|
-
* ```js
|
|
17
|
-
* import { NotificationTrayRepository } from '@amityco/ts-sdk'
|
|
18
|
-
* const notificationTraySeen = await NotificationTrayRepository.getNotificationTraySeen.locally()
|
|
19
|
-
* ```
|
|
20
|
-
*
|
|
21
|
-
* Queries a paginable list of {@link Amity.NotificationTraySeen} objects from cache
|
|
22
|
-
*
|
|
23
|
-
* @returns A page of {@link Amity.NotificationTraySeen} objects
|
|
24
|
-
*
|
|
25
|
-
* @category NotificationTray API
|
|
26
|
-
* @async
|
|
27
|
-
* */
|
|
28
|
-
locally(): Amity.Cached<Amity.NotificationTraySeenPayload> | undefined;
|
|
29
|
-
};
|
|
30
|
-
//# sourceMappingURL=getNotificationTraySeen.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"getNotificationTraySeen.d.ts","sourceRoot":"","sources":["../../../src/notificationTrayRepository/internalApi/getNotificationTraySeen.ts"],"names":[],"mappings":"AAMA;;;;;;;;;;;KAWK;AACL,eAAO,MAAM,uBAAuB;QAAa,QAC/C,MAAM,MAAM,CAAC,MAAM,oBAAoB,CAAC,CACzC;IA+BD;;;;;;;;;;;;SAYK;eAED,MAAM,MAAM,CAAC,MAAM,2BAA2B,CAAC,GAC/C,SAAS;CAlBZ,CAAC"}
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { NotificationTrayItemsPaginationController } from './NotificationTrayItemsPaginationController';
|
|
2
|
-
import { LiveCollectionController } from '~/core/liveCollection/LiveCollectionController';
|
|
3
|
-
export declare class NotificationTrayItemsLiveCollectionController extends LiveCollectionController<'notificationTrayItem', Amity.NotificationTrayItemLiveCollection, Amity.RawNotificationTrayItem, NotificationTrayItemsPaginationController> {
|
|
4
|
-
private queryStreamController;
|
|
5
|
-
private query;
|
|
6
|
-
constructor(query: Amity.NotificationTrayItemLiveCollection, callback: Amity.LiveCollectionCallback<Amity.RawNotificationTrayItem>);
|
|
7
|
-
protected setup(): void;
|
|
8
|
-
protected persistModel(queryPayload: Amity.NotificationTrayPayload & Amity.Pagination): Promise<void>;
|
|
9
|
-
protected persistQueryStream({ response, direction, refresh, }: Amity.LiveCollectionPersistQueryStreamParams<'notificationTrayItem'>): void;
|
|
10
|
-
startSubscription(): Amity.Unsubscriber[];
|
|
11
|
-
notifyChange({ origin, loading, error }: Amity.LiveCollectionNotifyParams): void;
|
|
12
|
-
}
|
|
13
|
-
//# sourceMappingURL=NotificationTrayItemsLiveCollectionController.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"NotificationTrayItemsLiveCollectionController.d.ts","sourceRoot":"","sources":["../../../../src/notificationTrayRepository/observers/getNotificationTrayItems/NotificationTrayItemsLiveCollectionController.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,yCAAyC,EAAE,MAAM,6CAA6C,CAAC;AAExG,OAAO,EAAE,wBAAwB,EAAE,MAAM,gDAAgD,CAAC;AAK1F,qBAAa,6CAA8C,SAAQ,wBAAwB,CACzF,sBAAsB,EACtB,KAAK,CAAC,kCAAkC,EACxC,KAAK,CAAC,uBAAuB,EAC7B,yCAAyC,CAC1C;IACC,OAAO,CAAC,qBAAqB,CAA6C;IAE1E,OAAO,CAAC,KAAK,CAA2C;gBAGtD,KAAK,EAAE,KAAK,CAAC,kCAAkC,EAC/C,QAAQ,EAAE,KAAK,CAAC,sBAAsB,CAAC,KAAK,CAAC,uBAAuB,CAAC;IAoBvE,SAAS,CAAC,KAAK;cAYC,YAAY,CAAC,YAAY,EAAE,KAAK,CAAC,uBAAuB,GAAG,KAAK,CAAC,UAAU;IAI3F,SAAS,CAAC,kBAAkB,CAAC,EAC3B,QAAQ,EACR,SAAS,EACT,OAAO,GACR,EAAE,KAAK,CAAC,sCAAsC,CAAC,sBAAsB,CAAC;IAKvE,iBAAiB;IAIjB,YAAY,CAAC,EAAE,MAAM,EAAE,OAAO,EAAE,KAAK,EAAE,EAAE,KAAK,CAAC,0BAA0B;CAyB1E"}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { PaginationController } from '~/core/liveCollection/PaginationController';
|
|
2
|
-
/**
|
|
3
|
-
* TODO: handle cache receive cache option, and cache policy
|
|
4
|
-
* TODO: check if querybyIds is supported
|
|
5
|
-
*/
|
|
6
|
-
export declare class NotificationTrayItemsPaginationController extends PaginationController<'notificationTrayItem', Amity.NotificationTrayItemLiveCollection> {
|
|
7
|
-
getRequest(queryParams: Amity.NotificationTrayItemLiveCollection, token: string | undefined): Promise<Amity.NotificationTrayPayload & Amity.Pagination>;
|
|
8
|
-
}
|
|
9
|
-
//# sourceMappingURL=NotificationTrayItemsPaginationController.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"NotificationTrayItemsPaginationController.d.ts","sourceRoot":"","sources":["../../../../src/notificationTrayRepository/observers/getNotificationTrayItems/NotificationTrayItemsPaginationController.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,4CAA4C,CAAC;AAGlF;;;GAGG;AACH,qBAAa,yCAA0C,SAAQ,oBAAoB,CACjF,sBAAsB,EACtB,KAAK,CAAC,kCAAkC,CACzC;IACO,UAAU,CACd,WAAW,EAAE,KAAK,CAAC,kCAAkC,EACrD,KAAK,EAAE,MAAM,GAAG,SAAS;CAiB5B"}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { QueryStreamController } from '~/core/liveCollection/QueryStreamController';
|
|
2
|
-
export declare class NotificationTrayItemsQuerystreamController extends QueryStreamController<Amity.NotificationTrayPayload, Amity.NotificationTrayItemLiveCollection> {
|
|
3
|
-
private notifyChange;
|
|
4
|
-
private preparePayload;
|
|
5
|
-
constructor(query: Amity.NotificationTrayItemLiveCollection, cacheKey: string[], notifyChange: (params: Amity.LiveCollectionNotifyParams) => void, preparePayload: (response: Amity.NotificationTrayPayload) => Amity.ProcessedNotificationTrayPayload);
|
|
6
|
-
saveToMainDB(response: Amity.NotificationTrayPayload): Promise<void>;
|
|
7
|
-
appendToQueryStream(response: Amity.NotificationTrayPayload & Partial<Amity.Pagination>, direction: Amity.LiveCollectionPageDirection, refresh?: boolean): void;
|
|
8
|
-
}
|
|
9
|
-
//# sourceMappingURL=NotificationTrayItemsQuerystreamController.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"NotificationTrayItemsQuerystreamController.d.ts","sourceRoot":"","sources":["../../../../src/notificationTrayRepository/observers/getNotificationTrayItems/NotificationTrayItemsQuerystreamController.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,qBAAqB,EAAE,MAAM,6CAA6C,CAAC;AAMpF,qBAAa,0CAA2C,SAAQ,qBAAqB,CACnF,KAAK,CAAC,uBAAuB,EAC7B,KAAK,CAAC,kCAAkC,CACzC;IACC,OAAO,CAAC,YAAY,CAAqD;IAEzE,OAAO,CAAC,cAAc,CAEsB;gBAG1C,KAAK,EAAE,KAAK,CAAC,kCAAkC,EAC/C,QAAQ,EAAE,MAAM,EAAE,EAClB,YAAY,EAAE,CAAC,MAAM,EAAE,KAAK,CAAC,0BAA0B,KAAK,IAAI,EAChE,cAAc,EAAE,CACd,QAAQ,EAAE,KAAK,CAAC,uBAAuB,KACpC,KAAK,CAAC,gCAAgC;IAOvC,YAAY,CAAC,QAAQ,EAAE,KAAK,CAAC,uBAAuB;IAW1D,mBAAmB,CACjB,QAAQ,EAAE,KAAK,CAAC,uBAAuB,GAAG,OAAO,CAAC,KAAK,CAAC,UAAU,CAAC,EACnE,SAAS,EAAE,KAAK,CAAC,2BAA2B,EAC5C,OAAO,UAAQ;CAwBlB"}
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Get notification tray items for a notification tray page
|
|
3
|
-
*
|
|
4
|
-
* @param params the limit query parameters
|
|
5
|
-
* @param callback the callback to be called when the notification tray items are updated
|
|
6
|
-
* @returns items in the notification tray
|
|
7
|
-
*
|
|
8
|
-
* @category Notification tray items Live Collection
|
|
9
|
-
*
|
|
10
|
-
*/
|
|
11
|
-
export declare const getNotificationTrayItems: (params: Amity.LiveCollectionParams<Amity.NotificationTrayItemLiveCollection>, callback: Amity.LiveCollectionCallback<Amity.RawNotificationTrayItem>, config?: Amity.LiveCollectionConfig) => () => void;
|
|
12
|
-
//# sourceMappingURL=getNotificationTrayItems.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"getNotificationTrayItems.d.ts","sourceRoot":"","sources":["../../../src/notificationTrayRepository/observers/getNotificationTrayItems.ts"],"names":[],"mappings":"AAKA;;;;;;;;;GASG;AACH,eAAO,MAAM,wBAAwB,WAC3B,MAAM,oBAAoB,CAAC,MAAM,kCAAkC,CAAC,YAClE,MAAM,sBAAsB,CAAC,MAAM,uBAAuB,CAAC,WAC5D,MAAM,oBAAoB,eAyBpC,CAAC"}
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* ```js
|
|
3
|
-
* import { getNotificationTraySeen } from '@amityco/ts-sdk';
|
|
4
|
-
*
|
|
5
|
-
* let notificationTraySeen;
|
|
6
|
-
*
|
|
7
|
-
* const unsubscribe = getNotificationTraySeen(userId, response => {
|
|
8
|
-
* notificationTraySeen = response.data;
|
|
9
|
-
* });
|
|
10
|
-
* ```
|
|
11
|
-
*
|
|
12
|
-
* Observe all mutation on a given {@link Amity.NotificationTraySeen}
|
|
13
|
-
*
|
|
14
|
-
* @param userId the ID of the user to observe
|
|
15
|
-
* @param callback the function to call when new data are available
|
|
16
|
-
* @returns An {@link Amity.Unsubscriber} function to run when willing to stop observing the message
|
|
17
|
-
*
|
|
18
|
-
* @category NotificationTraySeen Live Object
|
|
19
|
-
*/
|
|
20
|
-
export declare const getNotificationTraySeen: (callback: Amity.LiveObjectCallback<Amity.NotificationTraySeenPayload>) => Amity.Unsubscriber;
|
|
21
|
-
//# sourceMappingURL=getNotificationTraySeen.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"getNotificationTraySeen.d.ts","sourceRoot":"","sources":["../../../src/notificationTrayRepository/observers/getNotificationTraySeen.ts"],"names":[],"mappings":"AAQA;;;;;;;;;;;;;;;;;;GAkBG;AACH,eAAO,MAAM,uBAAuB,aACxB,MAAM,kBAAkB,CAAC,MAAM,2BAA2B,CAAC,KACpE,MAAM,YAYR,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/notificationTrayRepository/observers/index.ts"],"names":[],"mappings":"AAAA,cAAc,2BAA2B,CAAC;AAC1C,cAAc,4BAA4B,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"prepareNotificationTrayItemsPayload.d.ts","sourceRoot":"","sources":["../../../src/notificationTrayRepository/utils/prepareNotificationTrayItemsPayload.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,mCAAmC,eAClC,MAAM,uBAAuB,KACxC,MAAM,gCAOR,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"notificationTrayLinkedObject.d.ts","sourceRoot":"","sources":["../../../src/utils/linkedObject/notificationTrayLinkedObject.ts"],"names":[],"mappings":"AAMA,eAAO,MAAM,4BAA4B,SACjC,MAAM,4BAA4B,KACvC,MAAM,oBAmBR,CAAC"}
|
|
@@ -1,90 +0,0 @@
|
|
|
1
|
-
export {};
|
|
2
|
-
|
|
3
|
-
declare global {
|
|
4
|
-
namespace Amity {
|
|
5
|
-
const enum TrayItemCategoryType {
|
|
6
|
-
POST_MENTION = 'mention_in_post',
|
|
7
|
-
COMMENT_MENTION = 'mention_in_comment',
|
|
8
|
-
POST_REACT = 'react_to_post',
|
|
9
|
-
COMMENT_REACT = 'react_to_comment',
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
const enum TrayAction {
|
|
13
|
-
POST = 'post',
|
|
14
|
-
POLL = 'poll',
|
|
15
|
-
COMMENT = 'comment',
|
|
16
|
-
REACTION = 'reaction',
|
|
17
|
-
MENTION = 'mention',
|
|
18
|
-
REPLY = 'reply',
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
type RawNotificationTrayItem = {
|
|
22
|
-
_id: string;
|
|
23
|
-
lastSeenAt: Amity.timestamp;
|
|
24
|
-
lastOccuredAt: Amity.timestamp;
|
|
25
|
-
actorIds: {
|
|
26
|
-
_id: string;
|
|
27
|
-
lastActedAt: Amity.timestamp;
|
|
28
|
-
}[];
|
|
29
|
-
actorsCount: number;
|
|
30
|
-
action: TrayAction;
|
|
31
|
-
trayItemCategory?: TrayItemCategoryType;
|
|
32
|
-
targetId: string;
|
|
33
|
-
targetType: string;
|
|
34
|
-
referenceId?: string;
|
|
35
|
-
referenceType?: string;
|
|
36
|
-
actionReferenceId?: string;
|
|
37
|
-
parentId?: string;
|
|
38
|
-
data: { communityName: string } | { reactionName: string[] };
|
|
39
|
-
text: string;
|
|
40
|
-
templatedText: string;
|
|
41
|
-
};
|
|
42
|
-
|
|
43
|
-
type InternalNotificationTrayItem = RawNotificationTrayItem;
|
|
44
|
-
|
|
45
|
-
type QueryNotificationTrayItem = {
|
|
46
|
-
token?: Amity.Token;
|
|
47
|
-
limit?: Amity.PageLimit['limit'];
|
|
48
|
-
};
|
|
49
|
-
|
|
50
|
-
type NotificationTrayItemLiveCollection = Amity.LiveCollectionParams<
|
|
51
|
-
Omit<QueryNotificationTrayItem, 'limit'>
|
|
52
|
-
>;
|
|
53
|
-
|
|
54
|
-
type NotificationTrayItemLiveCollectionCache = Amity.LiveCollectionCache<
|
|
55
|
-
Amity.InternalNotificationTrayItem['_id'],
|
|
56
|
-
Pick<QueryNotificationTrayItem, 'limit'>
|
|
57
|
-
>;
|
|
58
|
-
|
|
59
|
-
type NotificationTrayItem = Amity.InternalNotificationTrayItem & {
|
|
60
|
-
markRead: () => void;
|
|
61
|
-
isSeen: boolean;
|
|
62
|
-
isRecent: boolean;
|
|
63
|
-
users: Amity.User[];
|
|
64
|
-
};
|
|
65
|
-
|
|
66
|
-
type RawNotificationTraySeen = {
|
|
67
|
-
lastTraySeenAt: Amity.timestamp;
|
|
68
|
-
lastTrayOccuredAt: Amity.timestamp;
|
|
69
|
-
};
|
|
70
|
-
|
|
71
|
-
type RawNotificationTraySeenUpdated = {
|
|
72
|
-
lastTraySeenAt: Amity.timestamp;
|
|
73
|
-
};
|
|
74
|
-
|
|
75
|
-
type InternalNotificationTraySeen = RawNotificationTraySeen & { userId: string };
|
|
76
|
-
|
|
77
|
-
type NotificationTraySeen = RawNotificationTraySeen & { userId: string; isSeen: boolean };
|
|
78
|
-
|
|
79
|
-
type RawNotificationItemSeen = {
|
|
80
|
-
lastSeenAt: Amity.timestamp;
|
|
81
|
-
};
|
|
82
|
-
|
|
83
|
-
type QueryNotificationItemSeen = {
|
|
84
|
-
trayItems: {
|
|
85
|
-
id: string;
|
|
86
|
-
lastSeenAt: Amity.timestamp;
|
|
87
|
-
}[];
|
|
88
|
-
};
|
|
89
|
-
}
|
|
90
|
-
}
|
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
import { getActiveClient } from '~/client/api/activeClient';
|
|
2
|
-
import { fireEvent } from '~/core/events';
|
|
3
|
-
import { pullFromCache, pushToCache } from '~/cache/api';
|
|
4
|
-
|
|
5
|
-
/* begin_public_function
|
|
6
|
-
id: notificationTrayItem.markSeen
|
|
7
|
-
*/
|
|
8
|
-
/**
|
|
9
|
-
* ```js
|
|
10
|
-
* import { NotificationTrayRepository } from '@amityco/ts-sdk'
|
|
11
|
-
* const updated = await NotificationTrayRepository.markNotificationItemsSeen()
|
|
12
|
-
* ```
|
|
13
|
-
*
|
|
14
|
-
* Updates an {@link Amity.NotificationItemSeen}
|
|
15
|
-
*
|
|
16
|
-
* @param trayItems[] that include id and lastTraySeenAt, The ID of the {@link Amity.NotificationItemSeen} to edit
|
|
17
|
-
* @returns the updated {@link Amity.NotificationItemSeen} object
|
|
18
|
-
*
|
|
19
|
-
* @category NotificationItemSeen API
|
|
20
|
-
* @async
|
|
21
|
-
*/
|
|
22
|
-
export const markNotificationItemsSeen = async (patch: Amity.QueryNotificationItemSeen) => {
|
|
23
|
-
const client = getActiveClient();
|
|
24
|
-
client.log('notificationTray/markNotificationItemsSeen', {});
|
|
25
|
-
|
|
26
|
-
const { data: payload } = await client.http.put<Amity.RawNotificationTraySeenUpdated>(
|
|
27
|
-
`api/v1/notification-tray/items/seen`,
|
|
28
|
-
{
|
|
29
|
-
patch,
|
|
30
|
-
},
|
|
31
|
-
);
|
|
32
|
-
|
|
33
|
-
const updatedData = patch.trayItems
|
|
34
|
-
.map(patchItem => {
|
|
35
|
-
const cacheData = pullFromCache<Amity.InternalNotificationTrayItem>([
|
|
36
|
-
'notificationTraySeen',
|
|
37
|
-
'get',
|
|
38
|
-
patchItem.id,
|
|
39
|
-
])?.data;
|
|
40
|
-
|
|
41
|
-
if (!cacheData) return;
|
|
42
|
-
|
|
43
|
-
const data = {
|
|
44
|
-
...cacheData,
|
|
45
|
-
...payload,
|
|
46
|
-
};
|
|
47
|
-
|
|
48
|
-
if (client.cache) {
|
|
49
|
-
const cachedAt = Date.now();
|
|
50
|
-
pushToCache(['notificationTrayItem', 'get'], data, { cachedAt });
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
return data;
|
|
54
|
-
})
|
|
55
|
-
.filter(Boolean) as Amity.InternalNotificationTrayItem[];
|
|
56
|
-
|
|
57
|
-
fireEvent('local.notificationTrayItem.updated', { notificationTrayItems: updatedData });
|
|
58
|
-
};
|
|
59
|
-
/* end_public_function */
|
|
@@ -1,65 +0,0 @@
|
|
|
1
|
-
import { getActiveClient } from '~/client/api';
|
|
2
|
-
import { fireEvent } from '~/core/events';
|
|
3
|
-
import { pullFromCache, pushToCache } from '~/cache/api';
|
|
4
|
-
|
|
5
|
-
/* begin_public_function
|
|
6
|
-
id: notificationTray.markSeen
|
|
7
|
-
*/
|
|
8
|
-
/**
|
|
9
|
-
* ```js
|
|
10
|
-
* import { NotificationTrayRepository } from '@amityco/ts-sdk'
|
|
11
|
-
* const updated = await NotificationTrayRepository.markNotificationTraySeen({
|
|
12
|
-
* lastSeenAt: Amity.timestamp,
|
|
13
|
-
* })
|
|
14
|
-
* ```
|
|
15
|
-
*
|
|
16
|
-
* Updates an {@link Amity.NotificationTraySeen}
|
|
17
|
-
*
|
|
18
|
-
* @param userId The ID of the {@link Amity.NotificationTraySeen} to edit
|
|
19
|
-
* @param lastSeenAt The patch data to apply
|
|
20
|
-
* @returns the updated {@link Amity.NotificationTraySeen} object
|
|
21
|
-
*
|
|
22
|
-
* @category Post API
|
|
23
|
-
* @async
|
|
24
|
-
*/
|
|
25
|
-
export const markNotificationTraySeen = async (
|
|
26
|
-
lastSeenAt: Amity.timestamp,
|
|
27
|
-
): Promise<Amity.Cached<Amity.NotificationTraySeenUpdatedPayload>> => {
|
|
28
|
-
const client = getActiveClient();
|
|
29
|
-
client.log('notificationTray/markNotificationTraySeen', {});
|
|
30
|
-
|
|
31
|
-
const { data: payload } = await client.http.put<Amity.NotificationTraySeenUpdatedPayload>(
|
|
32
|
-
`api/v1/notification-tray/tray/seen`,
|
|
33
|
-
{
|
|
34
|
-
lastSeenAt,
|
|
35
|
-
},
|
|
36
|
-
);
|
|
37
|
-
|
|
38
|
-
const cacheData = pullFromCache<Amity.InternalNotificationTraySeen>([
|
|
39
|
-
'notificationTraySeen',
|
|
40
|
-
'get',
|
|
41
|
-
])?.data;
|
|
42
|
-
|
|
43
|
-
const data = {
|
|
44
|
-
userId: client.userId!,
|
|
45
|
-
...payload,
|
|
46
|
-
} as Amity.InternalNotificationTraySeen;
|
|
47
|
-
|
|
48
|
-
const updateCacheData = {
|
|
49
|
-
...cacheData,
|
|
50
|
-
...data,
|
|
51
|
-
};
|
|
52
|
-
|
|
53
|
-
const cachedAt = client.cache && Date.now();
|
|
54
|
-
|
|
55
|
-
if (client.cache)
|
|
56
|
-
pushToCache(['notificationTraySeen', 'get', client.userId!], updateCacheData, { cachedAt });
|
|
57
|
-
|
|
58
|
-
fireEvent('local.notificationTraySeen.updated', data);
|
|
59
|
-
|
|
60
|
-
return {
|
|
61
|
-
data: payload,
|
|
62
|
-
cachedAt,
|
|
63
|
-
};
|
|
64
|
-
};
|
|
65
|
-
/* end_public_function */
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './onNotificationTraySeenUpdated';
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
import { getActiveClient } from '~/client/api/activeClient';
|
|
2
|
-
import { createEventSubscriber } from '~/core/events';
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* ```js
|
|
6
|
-
* import { onNotificationTraySeenUpdated } from '@amityco/ts-sdk'
|
|
7
|
-
* const dispose = onNotificationTraySeenUpdated(data => {
|
|
8
|
-
* // ...
|
|
9
|
-
* })
|
|
10
|
-
* ```
|
|
11
|
-
*
|
|
12
|
-
* Fired when an {@link Amity.NotificationTraySeen} has been updated
|
|
13
|
-
*
|
|
14
|
-
* @param callback The function to call when the event was fired
|
|
15
|
-
* @returns an {@link Amity.Unsubscriber} function to stop listening
|
|
16
|
-
*
|
|
17
|
-
* @category NotificationTraySeen Events
|
|
18
|
-
*/
|
|
19
|
-
export const onNotificationTraySeenUpdated = (
|
|
20
|
-
callback: Amity.Listener<Amity.InternalNotificationTraySeen>,
|
|
21
|
-
): Amity.Unsubscriber => {
|
|
22
|
-
const client = getActiveClient();
|
|
23
|
-
|
|
24
|
-
const disposers = [
|
|
25
|
-
createEventSubscriber(
|
|
26
|
-
client,
|
|
27
|
-
'onNotificationTraySeenUpdated',
|
|
28
|
-
'local.notificationTraySeen.updated',
|
|
29
|
-
payload => callback(payload),
|
|
30
|
-
),
|
|
31
|
-
];
|
|
32
|
-
|
|
33
|
-
return () => {
|
|
34
|
-
disposers.forEach(fn => fn());
|
|
35
|
-
};
|
|
36
|
-
};
|
|
@@ -1,81 +0,0 @@
|
|
|
1
|
-
import { getActiveClient } from '~/client/api/activeClient';
|
|
2
|
-
import { pullFromCache, pushToCache } from '~/cache/api';
|
|
3
|
-
|
|
4
|
-
/* begin_public_function
|
|
5
|
-
id: notificationTray.getNotificationTraySeen
|
|
6
|
-
*/
|
|
7
|
-
/**
|
|
8
|
-
* ```js
|
|
9
|
-
* import { NotificationTrayRepository } from '@amityco/ts-sdk'
|
|
10
|
-
* const notificationTraySeen = await NotificationTrayRepository.getNotificationTraySeen()
|
|
11
|
-
* ```
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
* @returns A page of {@link Amity.NotificationTraySeen} objects
|
|
15
|
-
*
|
|
16
|
-
* @category NotificationTray API
|
|
17
|
-
* @async
|
|
18
|
-
* */
|
|
19
|
-
export const getNotificationTraySeen = async (): Promise<
|
|
20
|
-
Amity.Cached<Amity.NotificationTraySeen>
|
|
21
|
-
> => {
|
|
22
|
-
const client = getActiveClient();
|
|
23
|
-
client.log('notificationTray/getNotificationTraySeen', {});
|
|
24
|
-
|
|
25
|
-
const { data: payload } = await client.http.get<Amity.NotificationTraySeenPayload>(
|
|
26
|
-
`api/v1/notification-tray/tray/seen`,
|
|
27
|
-
);
|
|
28
|
-
|
|
29
|
-
const cachedAt = client.cache && Date.now();
|
|
30
|
-
|
|
31
|
-
if (client.cache) {
|
|
32
|
-
const cacheKey = ['notificationTraySeen', 'get', client.userId];
|
|
33
|
-
pushToCache(cacheKey, {
|
|
34
|
-
userId: client.userId,
|
|
35
|
-
lastTraySeenAt: payload.lastTraySeenAt,
|
|
36
|
-
lastTrayOccuredAt: payload.lastTrayOccuredAt,
|
|
37
|
-
});
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
return {
|
|
41
|
-
data: {
|
|
42
|
-
userId: client.userId!,
|
|
43
|
-
lastTraySeenAt: payload.lastTraySeenAt,
|
|
44
|
-
lastTrayOccuredAt: payload.lastTrayOccuredAt,
|
|
45
|
-
isSeen: payload.lastTraySeenAt > payload.lastTrayOccuredAt,
|
|
46
|
-
},
|
|
47
|
-
cachedAt,
|
|
48
|
-
};
|
|
49
|
-
};
|
|
50
|
-
/* end_public_function */
|
|
51
|
-
|
|
52
|
-
/**
|
|
53
|
-
* ```js
|
|
54
|
-
* import { NotificationTrayRepository } from '@amityco/ts-sdk'
|
|
55
|
-
* const notificationTraySeen = await NotificationTrayRepository.getNotificationTraySeen.locally()
|
|
56
|
-
* ```
|
|
57
|
-
*
|
|
58
|
-
* Queries a paginable list of {@link Amity.NotificationTraySeen} objects from cache
|
|
59
|
-
*
|
|
60
|
-
* @returns A page of {@link Amity.NotificationTraySeen} objects
|
|
61
|
-
*
|
|
62
|
-
* @category NotificationTray API
|
|
63
|
-
* @async
|
|
64
|
-
* */
|
|
65
|
-
getNotificationTraySeen.locally = ():
|
|
66
|
-
| Amity.Cached<Amity.NotificationTraySeenPayload>
|
|
67
|
-
| undefined => {
|
|
68
|
-
const client = getActiveClient();
|
|
69
|
-
client.log('notificationTray/getNotificationTraySeen.locally', {});
|
|
70
|
-
|
|
71
|
-
if (!client.cache) return;
|
|
72
|
-
|
|
73
|
-
const queryKey = ['notificationTraySeen', 'get'];
|
|
74
|
-
|
|
75
|
-
const { data, cachedAt } =
|
|
76
|
-
pullFromCache<{ notificationTraySeen: Amity.NotificationTraySeenPayload }>(queryKey) ?? {};
|
|
77
|
-
|
|
78
|
-
if (!data?.notificationTraySeen) return;
|
|
79
|
-
|
|
80
|
-
return { data: data.notificationTraySeen, cachedAt };
|
|
81
|
-
};
|
|
@@ -1,96 +0,0 @@
|
|
|
1
|
-
import hash from 'object-hash';
|
|
2
|
-
import { pullFromCache, pushToCache } from '~/cache/api';
|
|
3
|
-
import { NotificationTrayItemsPaginationController } from './NotificationTrayItemsPaginationController';
|
|
4
|
-
import { NotificationTrayItemsQuerystreamController } from './NotificationTrayItemsQuerystreamController';
|
|
5
|
-
import { LiveCollectionController } from '~/core/liveCollection/LiveCollectionController';
|
|
6
|
-
import { prepareNotificationTrayItemsPayload } from '~/notificationTrayRepository/utils/prepareNotificationTrayItemsPayload';
|
|
7
|
-
import { isNonNullable } from '~/utils';
|
|
8
|
-
import { LinkedObject } from '~/utils/linkedObject';
|
|
9
|
-
|
|
10
|
-
export class NotificationTrayItemsLiveCollectionController extends LiveCollectionController<
|
|
11
|
-
'notificationTrayItem',
|
|
12
|
-
Amity.NotificationTrayItemLiveCollection,
|
|
13
|
-
Amity.RawNotificationTrayItem,
|
|
14
|
-
NotificationTrayItemsPaginationController
|
|
15
|
-
> {
|
|
16
|
-
private queryStreamController: NotificationTrayItemsQuerystreamController;
|
|
17
|
-
|
|
18
|
-
private query: Amity.NotificationTrayItemLiveCollection;
|
|
19
|
-
|
|
20
|
-
constructor(
|
|
21
|
-
query: Amity.NotificationTrayItemLiveCollection,
|
|
22
|
-
callback: Amity.LiveCollectionCallback<Amity.RawNotificationTrayItem>,
|
|
23
|
-
) {
|
|
24
|
-
const queryStreamId = hash(query);
|
|
25
|
-
const cacheKey = ['notificationTrayItem', 'collection', queryStreamId];
|
|
26
|
-
const paginationController = new NotificationTrayItemsPaginationController(query);
|
|
27
|
-
|
|
28
|
-
super(paginationController, queryStreamId, cacheKey, callback);
|
|
29
|
-
|
|
30
|
-
this.query = query;
|
|
31
|
-
this.queryStreamController = new NotificationTrayItemsQuerystreamController(
|
|
32
|
-
this.query,
|
|
33
|
-
this.cacheKey,
|
|
34
|
-
this.notifyChange.bind(this),
|
|
35
|
-
prepareNotificationTrayItemsPayload,
|
|
36
|
-
);
|
|
37
|
-
|
|
38
|
-
this.callback = callback.bind(this);
|
|
39
|
-
this.loadPage({ initial: true });
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
protected setup() {
|
|
43
|
-
const collection = pullFromCache<Amity.NotificationTrayItemLiveCollectionCache>(
|
|
44
|
-
this.cacheKey,
|
|
45
|
-
)?.data;
|
|
46
|
-
if (!collection) {
|
|
47
|
-
pushToCache(this.cacheKey, {
|
|
48
|
-
data: [],
|
|
49
|
-
params: {},
|
|
50
|
-
});
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
protected async persistModel(queryPayload: Amity.NotificationTrayPayload & Amity.Pagination) {
|
|
55
|
-
await this.queryStreamController.saveToMainDB(queryPayload);
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
protected persistQueryStream({
|
|
59
|
-
response,
|
|
60
|
-
direction,
|
|
61
|
-
refresh,
|
|
62
|
-
}: Amity.LiveCollectionPersistQueryStreamParams<'notificationTrayItem'>) {
|
|
63
|
-
this.queryStreamController.appendToQueryStream(response, direction, refresh);
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
// eslint-disable-next-line class-methods-use-this
|
|
67
|
-
startSubscription() {
|
|
68
|
-
return [] as Amity.Unsubscriber[];
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
notifyChange({ origin, loading, error }: Amity.LiveCollectionNotifyParams) {
|
|
72
|
-
const collection = pullFromCache<Amity.NotificationTrayItemLiveCollectionCache>(
|
|
73
|
-
this.cacheKey,
|
|
74
|
-
)?.data;
|
|
75
|
-
if (!collection) return;
|
|
76
|
-
|
|
77
|
-
const data = (
|
|
78
|
-
collection.data
|
|
79
|
-
.map(id =>
|
|
80
|
-
pullFromCache<Amity.InternalNotificationTrayItem>(['notificationTrayItem', 'get', id]),
|
|
81
|
-
)
|
|
82
|
-
.filter(isNonNullable)
|
|
83
|
-
.map(({ data }) => data) ?? []
|
|
84
|
-
).map(LinkedObject.notificationTray);
|
|
85
|
-
|
|
86
|
-
if (!this.shouldNotify(data) && origin === 'event') return;
|
|
87
|
-
|
|
88
|
-
this.callback({
|
|
89
|
-
onNextPage: () => this.loadPage({ direction: Amity.LiveCollectionPageDirection.NEXT }),
|
|
90
|
-
data,
|
|
91
|
-
hasNextPage: !!this.paginationController.getNextToken(),
|
|
92
|
-
loading,
|
|
93
|
-
error,
|
|
94
|
-
});
|
|
95
|
-
}
|
|
96
|
-
}
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import { PaginationController } from '~/core/liveCollection/PaginationController';
|
|
2
|
-
import { COLLECTION_DEFAULT_PAGINATION_LIMIT } from '~/utils/constants';
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* TODO: handle cache receive cache option, and cache policy
|
|
6
|
-
* TODO: check if querybyIds is supported
|
|
7
|
-
*/
|
|
8
|
-
export class NotificationTrayItemsPaginationController extends PaginationController<
|
|
9
|
-
'notificationTrayItem',
|
|
10
|
-
Amity.NotificationTrayItemLiveCollection
|
|
11
|
-
> {
|
|
12
|
-
async getRequest(
|
|
13
|
-
queryParams: Amity.NotificationTrayItemLiveCollection,
|
|
14
|
-
token: string | undefined,
|
|
15
|
-
) {
|
|
16
|
-
const { limit = COLLECTION_DEFAULT_PAGINATION_LIMIT, ...params } = queryParams;
|
|
17
|
-
|
|
18
|
-
const options = token ? { token } : { limit };
|
|
19
|
-
|
|
20
|
-
const { data: queryResponse } = await this.http.get<
|
|
21
|
-
Amity.NotificationTrayPayload & Amity.Pagination
|
|
22
|
-
>(`/api/v1/notification-tray`, {
|
|
23
|
-
params: {
|
|
24
|
-
...params,
|
|
25
|
-
options,
|
|
26
|
-
},
|
|
27
|
-
});
|
|
28
|
-
|
|
29
|
-
return queryResponse;
|
|
30
|
-
}
|
|
31
|
-
}
|