@amityco/ts-sdk 6.7.2 → 6.7.3-cbeeb97.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 +9 -3
- package/dist/@types/core/events.d.ts.map +1 -1
- package/dist/@types/core/marker.d.ts +3 -0
- package/dist/@types/core/marker.d.ts.map +1 -1
- package/dist/@types/core/model.d.ts +2 -2
- package/dist/@types/core/model.d.ts.map +1 -1
- package/dist/@types/core/payload.d.ts +40 -36
- 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/@types/domains/client.d.ts +1 -0
- package/dist/@types/domains/client.d.ts.map +1 -1
- package/dist/@types/domains/comment.d.ts +20 -8
- package/dist/@types/domains/comment.d.ts.map +1 -1
- package/dist/@types/domains/partials.d.ts +3 -0
- package/dist/@types/domains/partials.d.ts.map +1 -1
- package/dist/@types/domains/post.d.ts +1 -1
- package/dist/@types/domains/post.d.ts.map +1 -1
- package/dist/@types/domains/subChannel.d.ts +1 -0
- package/dist/@types/domains/subChannel.d.ts.map +1 -1
- package/dist/channelRepsitory/api/markAsRead.d.ts.map +1 -1
- package/dist/channelRepsitory/observers/getChannels.d.ts.map +1 -1
- package/dist/channelRepsitory/utils/getChannelHasMentioned.d.ts +7 -0
- package/dist/channelRepsitory/utils/getChannelHasMentioned.d.ts.map +1 -0
- package/dist/channelRepsitory/utils/prepareChannelPayload.d.ts.map +1 -1
- package/dist/client/api/markerSync.d.ts.map +1 -1
- package/dist/client/observers/getTotalUnreadCount.d.ts +2 -0
- package/dist/client/observers/getTotalUnreadCount.d.ts.map +1 -1
- package/dist/client/observers/getUserUnread.d.ts +19 -0
- package/dist/client/observers/getUserUnread.d.ts.map +1 -0
- package/dist/client/observers/index.d.ts +1 -0
- package/dist/client/observers/index.d.ts.map +1 -1
- package/dist/client/utils/markerSyncEngine.d.ts.map +1 -1
- package/dist/client/utils/onOnline.d.ts +2 -0
- package/dist/client/utils/onOnline.d.ts.map +1 -0
- package/dist/commentRepository/api/createComment.d.ts +4 -4
- package/dist/commentRepository/api/createComment.d.ts.map +1 -1
- package/dist/commentRepository/api/deleteComment.d.ts +4 -4
- package/dist/commentRepository/api/deleteComment.d.ts.map +1 -1
- package/dist/commentRepository/api/flagComment.d.ts +1 -1
- package/dist/commentRepository/api/flagComment.d.ts.map +1 -1
- package/dist/commentRepository/api/getComment.d.ts +8 -8
- package/dist/commentRepository/api/getComment.d.ts.map +1 -1
- package/dist/commentRepository/api/getCommentByIds.d.ts +8 -8
- package/dist/commentRepository/api/getCommentByIds.d.ts.map +1 -1
- package/dist/commentRepository/api/hardDeleteComment.d.ts +4 -4
- package/dist/commentRepository/api/hardDeleteComment.d.ts.map +1 -1
- package/dist/commentRepository/api/isCommentFlaggedByMe.d.ts +1 -1
- package/dist/commentRepository/api/isCommentFlaggedByMe.d.ts.map +1 -1
- package/dist/commentRepository/api/queryComments.d.ts +3 -3
- package/dist/commentRepository/api/queryComments.d.ts.map +1 -1
- package/dist/commentRepository/api/softDeleteComment.d.ts +4 -4
- package/dist/commentRepository/api/softDeleteComment.d.ts.map +1 -1
- package/dist/commentRepository/api/unflagComment.d.ts +1 -1
- package/dist/commentRepository/api/unflagComment.d.ts.map +1 -1
- package/dist/commentRepository/api/updateComment.d.ts +4 -4
- package/dist/commentRepository/api/updateComment.d.ts.map +1 -1
- package/dist/commentRepository/events/onCommentCreated.d.ts +3 -3
- package/dist/commentRepository/events/onCommentCreated.d.ts.map +1 -1
- package/dist/commentRepository/events/onCommentDeleted.d.ts +3 -3
- package/dist/commentRepository/events/onCommentDeleted.d.ts.map +1 -1
- package/dist/commentRepository/events/onCommentFlagged.d.ts +3 -3
- package/dist/commentRepository/events/onCommentFlagged.d.ts.map +1 -1
- package/dist/commentRepository/events/onCommentReactionAdded.d.ts +3 -3
- package/dist/commentRepository/events/onCommentReactionAdded.d.ts.map +1 -1
- package/dist/commentRepository/events/onCommentReactionRemoved.d.ts +3 -3
- package/dist/commentRepository/events/onCommentReactionRemoved.d.ts.map +1 -1
- package/dist/commentRepository/events/onCommentUnflagged.d.ts +3 -3
- package/dist/commentRepository/events/onCommentUnflagged.d.ts.map +1 -1
- package/dist/commentRepository/events/onCommentUpdated.d.ts +3 -3
- package/dist/commentRepository/events/onCommentUpdated.d.ts.map +1 -1
- package/dist/commentRepository/events/utils.d.ts +1 -1
- package/dist/commentRepository/events/utils.d.ts.map +1 -1
- package/dist/commentRepository/observers/getComment.d.ts +3 -3
- package/dist/commentRepository/observers/getComment.d.ts.map +1 -1
- package/dist/commentRepository/observers/getComments.d.ts +4 -4
- package/dist/commentRepository/observers/getComments.d.ts.map +1 -1
- package/dist/commentRepository/observers/observeComment.d.ts +3 -3
- package/dist/commentRepository/observers/observeComment.d.ts.map +1 -1
- package/dist/commentRepository/observers/observeComments.d.ts +3 -3
- package/dist/commentRepository/observers/observeComments.d.ts.map +1 -1
- package/dist/index.cjs.js +2253 -18192
- package/dist/index.esm.js +273 -107
- package/dist/index.umd.js +4 -4
- package/dist/marker/api/getChannelMarkers.d.ts.map +1 -1
- package/dist/marker/api/getMessageMarkers.d.ts.map +1 -1
- package/dist/marker/api/getSubChannelMarkers.d.ts.map +1 -1
- package/dist/marker/api/getUserMarker.d.ts.map +1 -1
- package/dist/marker/events/onUserMarkerSync.d.ts.map +1 -1
- package/dist/messageRepository/api/getDeliveredUsers.d.ts.map +1 -1
- package/dist/messageRepository/api/getReadUsers.d.ts.map +1 -1
- package/dist/messageRepository/api/markAsDelivered.d.ts.map +1 -1
- package/dist/reactionRepository/events/onReactionAdded.d.ts +1 -1
- package/dist/reactionRepository/events/onReactionAdded.d.ts.map +1 -1
- package/dist/reactionRepository/events/onReactionRemoved.d.ts +1 -1
- package/dist/reactionRepository/events/onReactionRemoved.d.ts.map +1 -1
- package/dist/reactionRepository/utils/fetchReference.d.ts +1 -1
- package/dist/reactionRepository/utils/fetchReference.d.ts.map +1 -1
- package/dist/subChannelRepository/api/readingAPI.d.ts.map +1 -1
- package/dist/subChannelRepository/api/startReadingAPI.d.ts.map +1 -1
- package/dist/subChannelRepository/api/stopReadingAPI.d.ts.map +1 -1
- package/dist/subChannelRepository/utils/getSubChannelHasMentioned.d.ts +2 -0
- package/dist/subChannelRepository/utils/getSubChannelHasMentioned.d.ts.map +1 -0
- package/dist/subChannelRepository/utils/markReadEngine.d.ts.map +1 -1
- package/dist/subChannelRepository/utils/prepareSubChannelPayload.d.ts.map +1 -1
- package/dist/utils/linkedObject/commentLinkedObject.d.ts +2 -0
- package/dist/utils/linkedObject/commentLinkedObject.d.ts.map +1 -0
- package/dist/utils/linkedObject/index.d.ts +4 -0
- package/dist/utils/linkedObject/index.d.ts.map +1 -0
- package/dist/utils/marker.d.ts +4 -0
- package/dist/utils/marker.d.ts.map +1 -0
- package/dist/utils/tests/dummy/channel.d.ts.map +1 -1
- package/dist/utils/tests/dummy/comment.d.ts +20 -14
- package/dist/utils/tests/dummy/comment.d.ts.map +1 -1
- package/dist/utils/tests/dummy/marker.d.ts +3 -0
- package/dist/utils/tests/dummy/marker.d.ts.map +1 -1
- package/package.json +3 -1
- package/rollup.config.js +2 -0
- package/src/@types/core/events.ts +3 -9
- package/src/@types/core/marker.ts +3 -0
- package/src/@types/core/model.ts +2 -2
- package/src/@types/core/payload.ts +41 -36
- package/src/@types/domains/channel.ts +1 -0
- package/src/@types/domains/client.ts +2 -0
- package/src/@types/domains/comment.ts +20 -8
- package/src/@types/domains/partials.ts +4 -0
- package/src/@types/domains/post.ts +1 -1
- package/src/@types/domains/subChannel.ts +1 -0
- package/src/channelRepsitory/api/markAsRead.ts +22 -1
- package/src/channelRepsitory/observers/getChannels.ts +3 -2
- package/src/channelRepsitory/observers/tests/getChannels.test.ts +6 -2
- package/src/channelRepsitory/utils/getChannelHasMentioned.ts +28 -0
- package/src/channelRepsitory/utils/prepareChannelPayload.ts +4 -0
- package/src/channelRepsitory/utils/tests/prepareChannelPayload.test.ts +3 -0
- package/src/client/api/markerSync.ts +17 -2
- package/src/client/observers/getTotalUnreadCount.ts +2 -0
- package/src/client/observers/getUserUnread.ts +47 -0
- package/src/client/observers/index.ts +1 -0
- package/src/client/utils/markerSyncEngine.ts +5 -13
- package/src/client/utils/onOnline.ts +15 -0
- package/src/commentRepository/api/createComment.ts +5 -5
- package/src/commentRepository/api/deleteComment.ts +6 -5
- package/src/commentRepository/api/flagComment.ts +3 -1
- package/src/commentRepository/api/getComment.ts +13 -12
- package/src/commentRepository/api/getCommentByIds.ts +11 -11
- package/src/commentRepository/api/hardDeleteComment.ts +5 -5
- package/src/commentRepository/api/isCommentFlaggedByMe.ts +1 -1
- package/src/commentRepository/api/queryComments.ts +4 -4
- package/src/commentRepository/api/softDeleteComment.ts +5 -5
- package/src/commentRepository/api/tests/queryComments.test.ts +9 -9
- package/src/commentRepository/api/unflagComment.ts +3 -1
- package/src/commentRepository/api/updateComment.ts +6 -6
- package/src/commentRepository/events/onCommentCreated.ts +5 -4
- package/src/commentRepository/events/onCommentDeleted.ts +5 -4
- package/src/commentRepository/events/onCommentFlagged.ts +5 -4
- package/src/commentRepository/events/onCommentReactionAdded.ts +4 -4
- package/src/commentRepository/events/onCommentReactionRemoved.ts +4 -4
- package/src/commentRepository/events/onCommentUnflagged.ts +5 -4
- package/src/commentRepository/events/onCommentUpdated.ts +5 -4
- package/src/commentRepository/events/utils.ts +3 -3
- package/src/commentRepository/observers/getComment.ts +4 -4
- package/src/commentRepository/observers/getComments.ts +9 -8
- package/src/commentRepository/observers/observeComment.ts +14 -8
- package/src/commentRepository/observers/observeComments.ts +9 -6
- package/src/commentRepository/observers/tests/getComment.test.ts +3 -1
- package/src/marker/api/getChannelMarkers.ts +9 -3
- package/src/marker/api/getMessageMarkers.ts +5 -2
- package/src/marker/api/getSubChannelMarkers.ts +16 -2
- package/src/marker/api/getUserMarker.ts +9 -2
- package/src/marker/api/tests/getMessageMarkers.test.ts +3 -1
- package/src/marker/api/tests/getSubChannelMarkers.test.ts +16 -8
- package/src/marker/events/onUserMarkerSync.ts +18 -2
- package/src/messageRepository/api/getDeliveredUsers.ts +9 -2
- package/src/messageRepository/api/getReadUsers.ts +6 -2
- package/src/messageRepository/api/markAsDelivered.ts +17 -1
- package/src/messageRepository/api/tests/markAsDelivered.test.ts +11 -4
- package/src/reactionRepository/utils/prepareReactionPayloadFormEvent.ts +1 -1
- package/src/subChannelRepository/api/readingAPI.ts +17 -2
- package/src/subChannelRepository/api/startReadingAPI.ts +17 -2
- package/src/subChannelRepository/api/stopReadingAPI.ts +17 -2
- package/src/subChannelRepository/utils/getSubChannelHasMentioned.ts +34 -0
- package/src/subChannelRepository/utils/markReadEngine.ts +7 -15
- package/src/subChannelRepository/utils/prepareSubChannelPayload.ts +4 -0
- package/src/utils/linkedObject/commentLinkedObject.ts +44 -0
- package/src/utils/linkedObject/index.ts +5 -0
- package/src/utils/marker.ts +29 -0
- package/src/utils/tests/dummy/channel.ts +2 -0
- package/src/utils/tests/dummy/comment.ts +25 -8
- package/src/utils/tests/dummy/marker.ts +46 -0
package/dist/index.esm.js
CHANGED
|
@@ -20816,6 +20816,22 @@ const prepareMembershipPayload = (payload, memberProp, userIdProp = 'userId', us
|
|
|
20816
20816
|
return Object.assign(Object.assign({}, rest), { [memberProp]: members });
|
|
20817
20817
|
};
|
|
20818
20818
|
|
|
20819
|
+
function doConvert(markerResponses) {
|
|
20820
|
+
return markerResponses.map((_a) => {
|
|
20821
|
+
var { isMentioned } = _a, rest = __rest(_a, ["isMentioned"]);
|
|
20822
|
+
return (Object.assign({ hasMentioned: isMentioned }, rest));
|
|
20823
|
+
});
|
|
20824
|
+
}
|
|
20825
|
+
function convertUserMarkerResponse(userMarkerResponse) {
|
|
20826
|
+
return doConvert(userMarkerResponse);
|
|
20827
|
+
}
|
|
20828
|
+
function convertChannelMarkerResponse(channelMarkerResponse) {
|
|
20829
|
+
return doConvert(channelMarkerResponse);
|
|
20830
|
+
}
|
|
20831
|
+
function convertSubChannelMarkerResponse(subChannelMarkerResponse) {
|
|
20832
|
+
return doConvert(subChannelMarkerResponse);
|
|
20833
|
+
}
|
|
20834
|
+
|
|
20819
20835
|
/**
|
|
20820
20836
|
* ```js
|
|
20821
20837
|
* import { getChannelMarker } from '@amityco/ts-sdk'
|
|
@@ -20844,18 +20860,22 @@ const getChannelMarkers = async (channelIds, page = { limit: 100 }) => {
|
|
|
20844
20860
|
},
|
|
20845
20861
|
});
|
|
20846
20862
|
const { paging } = queryPayload, payload = __rest(queryPayload, ["paging"]);
|
|
20847
|
-
const { userEntityMarkers, userMarkers } = payload;
|
|
20863
|
+
const { userEntityMarkers: userEntityMarkersPayload, userMarkers: userMarkersPayload } = payload;
|
|
20864
|
+
const userMarkers = convertUserMarkerResponse(userMarkersPayload);
|
|
20865
|
+
const userEntityMarkers = convertChannelMarkerResponse(userEntityMarkersPayload);
|
|
20848
20866
|
const cachedAt = client.cache && Date.now();
|
|
20849
20867
|
if (client.cache)
|
|
20850
|
-
ingestInCache(
|
|
20851
|
-
fireEvent('local.channelMarker.fetched', {
|
|
20868
|
+
ingestInCache({ userEntityMarkers, userMarkers }, { cachedAt });
|
|
20869
|
+
fireEvent('local.channelMarker.fetched', {
|
|
20870
|
+
userEntityMarkers,
|
|
20871
|
+
});
|
|
20852
20872
|
fireEvent('local.userMarker.fetched', { userMarkers });
|
|
20853
20873
|
const nextPage = toPage(paging.next);
|
|
20854
20874
|
const prevPage = toPage(paging.previous);
|
|
20855
20875
|
return { data: userEntityMarkers, cachedAt, prevPage, nextPage };
|
|
20856
20876
|
};
|
|
20857
20877
|
|
|
20858
|
-
const getCachedMarker$
|
|
20878
|
+
const getCachedMarker$2 = (entityId) => {
|
|
20859
20879
|
var _a;
|
|
20860
20880
|
const key = {
|
|
20861
20881
|
entityId,
|
|
@@ -20875,7 +20895,31 @@ const getChannelUnreadCount = (channel, marker) => {
|
|
|
20875
20895
|
// from a channel or the channel is deleted the channel's unread count will reset to zero
|
|
20876
20896
|
return 0;
|
|
20877
20897
|
}
|
|
20878
|
-
return (_c = (_a = marker === null || marker === void 0 ? void 0 : marker.unreadCount) !== null && _a !== void 0 ? _a : (_b = getCachedMarker$
|
|
20898
|
+
return (_c = (_a = marker === null || marker === void 0 ? void 0 : marker.unreadCount) !== null && _a !== void 0 ? _a : (_b = getCachedMarker$2(channel.channelId)) === null || _b === void 0 ? void 0 : _b.unreadCount) !== null && _c !== void 0 ? _c : 0;
|
|
20899
|
+
};
|
|
20900
|
+
|
|
20901
|
+
const getCachedMarker$1 = (entityId) => {
|
|
20902
|
+
var _a;
|
|
20903
|
+
const key = {
|
|
20904
|
+
entityId,
|
|
20905
|
+
userId: getActiveUser()._id,
|
|
20906
|
+
};
|
|
20907
|
+
return (_a = pullFromCache([
|
|
20908
|
+
'channelMarker',
|
|
20909
|
+
'get',
|
|
20910
|
+
getResolver('channelMarker')(key),
|
|
20911
|
+
])) === null || _a === void 0 ? void 0 : _a.data;
|
|
20912
|
+
};
|
|
20913
|
+
/**
|
|
20914
|
+
* The function use to get value of hasMentioned field.
|
|
20915
|
+
* function will get the value from marker params first, if there is no hasMentioned field, will look in to the cache.
|
|
20916
|
+
* If not found in the cache, use `false` as defaul value.
|
|
20917
|
+
*/
|
|
20918
|
+
const getChannelHasMentioned = (channel, marker) => {
|
|
20919
|
+
var _a, _b;
|
|
20920
|
+
return (marker === null || marker === void 0 ? void 0 : marker.hasMentioned) !== undefined
|
|
20921
|
+
? marker === null || marker === void 0 ? void 0 : marker.hasMentioned
|
|
20922
|
+
: (_b = (_a = getCachedMarker$1(channel.channelId)) === null || _a === void 0 ? void 0 : _a.hasMentioned) !== null && _b !== void 0 ? _b : false;
|
|
20879
20923
|
};
|
|
20880
20924
|
|
|
20881
20925
|
const MARKER_INCLUDED_CHANNEL_TYPE = ['broadcast', 'conversation', 'community'];
|
|
@@ -20883,6 +20927,9 @@ const isUnreadCountSupport$1 = ({ type }) => MARKER_INCLUDED_CHANNEL_TYPE.includ
|
|
|
20883
20927
|
function convertFromRaw$2(channel) {
|
|
20884
20928
|
return Object.assign(Object.assign({ get unreadCount() {
|
|
20885
20929
|
return getChannelUnreadCount(channel);
|
|
20930
|
+
},
|
|
20931
|
+
get hasMentioned() {
|
|
20932
|
+
return getChannelHasMentioned(channel);
|
|
20886
20933
|
} }, channel), { defaultSubChannelId: channel._id, isUnreadCountSupport: isUnreadCountSupport$1(channel) });
|
|
20887
20934
|
}
|
|
20888
20935
|
const preUpdateChannelCache = (rawPayload) => {
|
|
@@ -20987,6 +21034,20 @@ const setIntervalTask = (handler, timeout) => {
|
|
|
20987
21034
|
return () => clearInterval(timer);
|
|
20988
21035
|
};
|
|
20989
21036
|
|
|
21037
|
+
const onOnline = (callback) => {
|
|
21038
|
+
if (typeof window !== 'undefined' && window.addEventListener) {
|
|
21039
|
+
window.addEventListener('online', callback);
|
|
21040
|
+
return () => window.removeEventListener('online', callback);
|
|
21041
|
+
}
|
|
21042
|
+
if (typeof document !== 'undefined' && document.addEventListener) {
|
|
21043
|
+
document.addEventListener('online', callback);
|
|
21044
|
+
return () => document.removeEventListener('online', callback);
|
|
21045
|
+
}
|
|
21046
|
+
// Handle unsupported environment
|
|
21047
|
+
console.error('Unsupported environment');
|
|
21048
|
+
return () => console.error('Unsupported environment');
|
|
21049
|
+
};
|
|
21050
|
+
|
|
20990
21051
|
/**
|
|
20991
21052
|
* ```js
|
|
20992
21053
|
* import { isInTombstone } from '@amityco/ts-sdk'
|
|
@@ -21070,10 +21131,11 @@ const getMessageMarkers = async (messageIds, page = { limit: 100 }) => {
|
|
|
21070
21131
|
},
|
|
21071
21132
|
});
|
|
21072
21133
|
const { paging } = queryPayload, payload = __rest(queryPayload, ["paging"]);
|
|
21073
|
-
const { contentMarkers, feedMarkers, userMarkers } = payload;
|
|
21134
|
+
const { contentMarkers, feedMarkers, userMarkers: userMarkersPayload } = payload;
|
|
21135
|
+
const userMarkers = convertUserMarkerResponse(userMarkersPayload);
|
|
21074
21136
|
const cachedAt = client.cache && Date.now();
|
|
21075
21137
|
if (client.cache)
|
|
21076
|
-
ingestInCache(
|
|
21138
|
+
ingestInCache({ contentMarkers, feedMarkers, userMarkers }, { cachedAt });
|
|
21077
21139
|
fireEvent('local.feedMarker.fetched', { feedMarkers });
|
|
21078
21140
|
fireEvent('local.messageMarker.fetched', { contentMarkers });
|
|
21079
21141
|
fireEvent('local.userMarker.fetched', { userMarkers });
|
|
@@ -21110,10 +21172,13 @@ const getSubChannelMarkers = async (messageFeedIds, page = { limit: 100 }) => {
|
|
|
21110
21172
|
},
|
|
21111
21173
|
});
|
|
21112
21174
|
const { paging } = queryPayload, payload = __rest(queryPayload, ["paging"]);
|
|
21113
|
-
const { userEntityMarkers, userFeedMarkers, userMarkers } = payload;
|
|
21175
|
+
const { userEntityMarkers: userEntityMarkersPayload, userFeedMarkers: userFeedMarkersPayload, userMarkers: userMarkersPayload, } = payload;
|
|
21176
|
+
const userMarkers = convertUserMarkerResponse(userMarkersPayload);
|
|
21177
|
+
const userEntityMarkers = convertChannelMarkerResponse(userEntityMarkersPayload);
|
|
21178
|
+
const userFeedMarkers = convertSubChannelMarkerResponse(userFeedMarkersPayload);
|
|
21114
21179
|
const cachedAt = client.cache && Date.now();
|
|
21115
21180
|
if (client.cache)
|
|
21116
|
-
ingestInCache(
|
|
21181
|
+
ingestInCache({ userEntityMarkers, userFeedMarkers, userMarkers }, { cachedAt });
|
|
21117
21182
|
fireEvent('local.channelMarker.fetched', { userEntityMarkers });
|
|
21118
21183
|
fireEvent('local.subChannelMarker.fetched', { userFeedMarkers });
|
|
21119
21184
|
fireEvent('local.userMarker.fetched', { userMarkers });
|
|
@@ -21126,10 +21191,14 @@ const getUserMarker = async () => {
|
|
|
21126
21191
|
const client = getActiveClient();
|
|
21127
21192
|
client.log('channel/getUserMarker');
|
|
21128
21193
|
const { data: payload } = await client.http.get(`/api/v1/markers/userMarker`);
|
|
21129
|
-
const { userMarkers } = payload;
|
|
21194
|
+
const { userMarkers: UserMarkersPayload } = payload;
|
|
21195
|
+
/*
|
|
21196
|
+
change field isMentioned from backend to be hasMentioned
|
|
21197
|
+
*/
|
|
21198
|
+
const userMarkers = convertUserMarkerResponse(UserMarkersPayload);
|
|
21130
21199
|
const cachedAt = client.cache && Date.now();
|
|
21131
21200
|
if (client.cache)
|
|
21132
|
-
ingestInCache(
|
|
21201
|
+
ingestInCache({ userMarkers }, { cachedAt });
|
|
21133
21202
|
fireEvent('local.userMarker.fetched', { userMarkers });
|
|
21134
21203
|
return { data: userMarkers[0], cachedAt };
|
|
21135
21204
|
};
|
|
@@ -21299,6 +21368,30 @@ function getSubChannelUnreadCount(channelId, subChannelId, marker) {
|
|
|
21299
21368
|
return 0;
|
|
21300
21369
|
}
|
|
21301
21370
|
|
|
21371
|
+
function getSubChannelHasMentioned(channelId, subChannelId, marker) {
|
|
21372
|
+
var _a;
|
|
21373
|
+
// Look for `unreadCount` in the marker param first
|
|
21374
|
+
if (marker) {
|
|
21375
|
+
return marker.hasMentioned;
|
|
21376
|
+
}
|
|
21377
|
+
const key = {
|
|
21378
|
+
entityId: channelId,
|
|
21379
|
+
feedId: subChannelId,
|
|
21380
|
+
userId: getActiveUser()._id,
|
|
21381
|
+
};
|
|
21382
|
+
// If the marker param is not set, look in the cache
|
|
21383
|
+
const cachedMarker = (_a = pullFromCache([
|
|
21384
|
+
'subChannelMarker',
|
|
21385
|
+
'get',
|
|
21386
|
+
getResolver('subChannelMarker')(key),
|
|
21387
|
+
])) === null || _a === void 0 ? void 0 : _a.data;
|
|
21388
|
+
if (cachedMarker) {
|
|
21389
|
+
return cachedMarker.hasMentioned;
|
|
21390
|
+
}
|
|
21391
|
+
// and if not found in cache use default value `false`
|
|
21392
|
+
return false;
|
|
21393
|
+
}
|
|
21394
|
+
|
|
21302
21395
|
const MARKER_INCLUDED_SUB_CHANNEL_TYPE = ['broadcast', 'conversation', 'community'];
|
|
21303
21396
|
/**
|
|
21304
21397
|
* Filter sub channel by type. Only conversation, community and broadcast type are included.
|
|
@@ -21308,6 +21401,9 @@ function convertFromRaw(_a) {
|
|
|
21308
21401
|
var { channelId, channelPublicId, channelType, childCount, creatorId, creatorPublicId, lastMessageId, lastMessageTimestamp, messageFeedId, name } = _a, rest = __rest(_a, ["channelId", "channelPublicId", "channelType", "childCount", "creatorId", "creatorPublicId", "lastMessageId", "lastMessageTimestamp", "messageFeedId", "name"]);
|
|
21309
21402
|
return Object.assign(Object.assign({ get unreadCount() {
|
|
21310
21403
|
return getSubChannelUnreadCount(channelId, messageFeedId);
|
|
21404
|
+
},
|
|
21405
|
+
get hasMentioned() {
|
|
21406
|
+
return getSubChannelHasMentioned(channelId, messageFeedId);
|
|
21311
21407
|
} }, rest), { channelId: channelPublicId, creatorId: creatorPublicId, displayName: name, lastActivity: lastMessageTimestamp, latestMessageId: lastMessageId, messageCount: childCount, subChannelId: messageFeedId, isUnreadCountSupport: isUnreadCountSupport({ channelType }) });
|
|
21312
21408
|
}
|
|
21313
21409
|
const preUpdateSubChannelCache = (rawPayload) => {
|
|
@@ -21427,10 +21523,13 @@ const readingAPI = async (messageFeedIds) => {
|
|
|
21427
21523
|
const client = getActiveClient();
|
|
21428
21524
|
client.log('subChannel/readingAPI', messageFeedIds);
|
|
21429
21525
|
const { data: payload } = await client.http.post(`/api/v1/markers/message-feeds/reading`, { messageFeedIds });
|
|
21430
|
-
const { userEntityMarkers, userFeedMarkers, feedMarkers, userMarkers } = payload;
|
|
21526
|
+
const { userEntityMarkers: userEntityMarkersPayload, userFeedMarkers: userFeedMarkersPayload, feedMarkers, userMarkers: userMarkersPayload, } = payload;
|
|
21527
|
+
const userMarkers = convertUserMarkerResponse(userMarkersPayload);
|
|
21528
|
+
const userEntityMarkers = convertChannelMarkerResponse(userEntityMarkersPayload);
|
|
21529
|
+
const userFeedMarkers = convertSubChannelMarkerResponse(userFeedMarkersPayload);
|
|
21431
21530
|
const cachedAt = client.cache && Date.now();
|
|
21432
21531
|
if (client.cache)
|
|
21433
|
-
ingestInCache(
|
|
21532
|
+
ingestInCache({ userEntityMarkers, userFeedMarkers, feedMarkers, userMarkers }, { cachedAt });
|
|
21434
21533
|
fireEvent('local.feedMarker.fetched', { feedMarkers });
|
|
21435
21534
|
fireEvent('local.channelMarker.fetched', { userEntityMarkers });
|
|
21436
21535
|
fireEvent('local.subChannelMarker.fetched', { userFeedMarkers });
|
|
@@ -21457,10 +21556,13 @@ const startReadingAPI = async (messageFeedId) => {
|
|
|
21457
21556
|
const client = getActiveClient();
|
|
21458
21557
|
client.log('subChannel/startReadingAPI', messageFeedId);
|
|
21459
21558
|
const { data: payload } = await client.http.post(`/api/v1/markers/message-feeds/${messageFeedId}/start-reading`);
|
|
21460
|
-
const { userEntityMarkers, userFeedMarkers, feedMarkers, userMarkers } = payload;
|
|
21559
|
+
const { userEntityMarkers: userEntityMarkersPayload, userFeedMarkers: userFeedMarkersPayload, feedMarkers, userMarkers: userMarkersPayload, } = payload;
|
|
21560
|
+
const userMarkers = convertUserMarkerResponse(userMarkersPayload);
|
|
21561
|
+
const userEntityMarkers = convertChannelMarkerResponse(userEntityMarkersPayload);
|
|
21562
|
+
const userFeedMarkers = convertSubChannelMarkerResponse(userFeedMarkersPayload);
|
|
21461
21563
|
const cachedAt = client.cache && Date.now();
|
|
21462
21564
|
if (client.cache)
|
|
21463
|
-
ingestInCache(
|
|
21565
|
+
ingestInCache({ userEntityMarkers, userFeedMarkers, feedMarkers, userMarkers }, { cachedAt });
|
|
21464
21566
|
fireEvent('local.feedMarker.fetched', { feedMarkers });
|
|
21465
21567
|
fireEvent('local.channelMarker.fetched', { userEntityMarkers });
|
|
21466
21568
|
fireEvent('local.subChannelMarker.fetched', { userFeedMarkers });
|
|
@@ -21487,10 +21589,13 @@ const stopReadingAPI = async (messageFeedId) => {
|
|
|
21487
21589
|
const client = getActiveClient();
|
|
21488
21590
|
client.log('channel/stopReadingAPI', messageFeedId);
|
|
21489
21591
|
const { data: payload } = await client.http.post(`/api/v1/markers/message-feeds/${messageFeedId}/stop-reading`);
|
|
21490
|
-
const { userEntityMarkers, userFeedMarkers, feedMarkers, userMarkers } = payload;
|
|
21592
|
+
const { userEntityMarkers: userEntityMarkersPayload, userFeedMarkers: userFeedMarkersPayload, feedMarkers, userMarkers: userMarkersPayload, } = payload;
|
|
21593
|
+
const userMarkers = convertUserMarkerResponse(userMarkersPayload);
|
|
21594
|
+
const userEntityMarkers = convertChannelMarkerResponse(userEntityMarkersPayload);
|
|
21595
|
+
const userFeedMarkers = convertSubChannelMarkerResponse(userFeedMarkersPayload);
|
|
21491
21596
|
const cachedAt = client.cache && Date.now();
|
|
21492
21597
|
if (client.cache)
|
|
21493
|
-
ingestInCache(
|
|
21598
|
+
ingestInCache({ userEntityMarkers, userFeedMarkers, feedMarkers, userMarkers }, { cachedAt });
|
|
21494
21599
|
fireEvent('local.feedMarker.fetched', { feedMarkers });
|
|
21495
21600
|
fireEvent('local.channelMarker.fetched', { userEntityMarkers });
|
|
21496
21601
|
fireEvent('local.subChannelMarker.fetched', { userFeedMarkers });
|
|
@@ -21547,17 +21652,6 @@ const markReadEngineOnLoginHandler = () => {
|
|
|
21547
21652
|
stopIntervalTask();
|
|
21548
21653
|
};
|
|
21549
21654
|
};
|
|
21550
|
-
/**
|
|
21551
|
-
* the event callback when app is back to online
|
|
21552
|
-
*/
|
|
21553
|
-
const onOnline$1 = () => {
|
|
21554
|
-
const callback = () => {
|
|
21555
|
-
// Start reading the reading subChannel again when resume from offline state
|
|
21556
|
-
startReadingFromReadingList();
|
|
21557
|
-
};
|
|
21558
|
-
window.addEventListener('online', callback);
|
|
21559
|
-
return () => window.removeEventListener('online', callback);
|
|
21560
|
-
};
|
|
21561
21655
|
const getParentChannelId = async (subChannelId) => {
|
|
21562
21656
|
const cached = getSubChannel$1.locally(subChannelId);
|
|
21563
21657
|
if (cached) {
|
|
@@ -21567,7 +21661,10 @@ const getParentChannelId = async (subChannelId) => {
|
|
|
21567
21661
|
return data.channelId;
|
|
21568
21662
|
};
|
|
21569
21663
|
const registerEventListeners$1 = () => {
|
|
21570
|
-
disposers$1.push(onOnline
|
|
21664
|
+
disposers$1.push(onOnline(() => {
|
|
21665
|
+
// Start reading the reading subChannel again when resume from offline state
|
|
21666
|
+
startReadingFromReadingList();
|
|
21667
|
+
}));
|
|
21571
21668
|
};
|
|
21572
21669
|
const registerTopicSubscribers = async (subChannelId) => {
|
|
21573
21670
|
const channelId = await getParentChannelId(subChannelId);
|
|
@@ -22202,10 +22299,13 @@ const markerSync = async (deviceLastSyncAt) => {
|
|
|
22202
22299
|
const client = getActiveClient();
|
|
22203
22300
|
client.log('channel/markerSync');
|
|
22204
22301
|
const { data: payload } = await client.http.post(`/api/v1/markers/sync`, { deviceLastSyncAt });
|
|
22205
|
-
const { userEntityMarkers, userFeedMarkers, feedMarkers, userMarkers } = payload;
|
|
22302
|
+
const { userEntityMarkers: userEntityMarkersPayload, userFeedMarkers: userFeedMarkersPayload, feedMarkers, userMarkers: userMarkersPayload, } = payload;
|
|
22303
|
+
const userMarkers = convertUserMarkerResponse(userMarkersPayload);
|
|
22304
|
+
const userEntityMarkers = convertChannelMarkerResponse(userEntityMarkersPayload);
|
|
22305
|
+
const userFeedMarkers = convertSubChannelMarkerResponse(userFeedMarkersPayload);
|
|
22206
22306
|
const cachedAt = client.cache && Date.now();
|
|
22207
22307
|
if (client.cache)
|
|
22208
|
-
ingestInCache(
|
|
22308
|
+
ingestInCache({ userEntityMarkers, userFeedMarkers, feedMarkers, userMarkers }, { cachedAt });
|
|
22209
22309
|
fireEvent('local.feedMarker.fetched', { feedMarkers });
|
|
22210
22310
|
fireEvent('local.channelMarker.fetched', { userEntityMarkers });
|
|
22211
22311
|
fireEvent('local.subChannelMarker.fetched', { userFeedMarkers });
|
|
@@ -22561,6 +22661,8 @@ const liveObject = (id, callback, key, fetcher, eventHandlers, options) => {
|
|
|
22561
22661
|
};
|
|
22562
22662
|
|
|
22563
22663
|
/**
|
|
22664
|
+
* @deprecated Please use unreadCount from `getUserUnread` instead.
|
|
22665
|
+
*
|
|
22564
22666
|
* ```js
|
|
22565
22667
|
* import { getTotalUnreadCount } from '@amityco/ts-sdk';
|
|
22566
22668
|
*
|
|
@@ -22586,6 +22688,39 @@ const getTotalUnreadCount = (callback) => {
|
|
|
22586
22688
|
});
|
|
22587
22689
|
};
|
|
22588
22690
|
|
|
22691
|
+
/**
|
|
22692
|
+
*
|
|
22693
|
+
* ```js
|
|
22694
|
+
* import { getUserUnread } from '@amityco/ts-sdk';
|
|
22695
|
+
*
|
|
22696
|
+
* const unsubscribe = getUserUnread(response => {
|
|
22697
|
+
* userUnread = response.data;
|
|
22698
|
+
* });
|
|
22699
|
+
* ```
|
|
22700
|
+
*
|
|
22701
|
+
* Observe current user's unread including unreadCount and hasMentioned from {@link Amity.UserMarker}
|
|
22702
|
+
*
|
|
22703
|
+
* @param callback the function to call when new data are available
|
|
22704
|
+
* @returns An {@link Amity.Unsubscriber} function to run when willing to stop observing the events
|
|
22705
|
+
*
|
|
22706
|
+
* @category Message Live Object
|
|
22707
|
+
*/
|
|
22708
|
+
const getUserUnread = (callback) => {
|
|
22709
|
+
const { _id: userId } = getActiveUser();
|
|
22710
|
+
if (!userId)
|
|
22711
|
+
throw new ASCError('The _id has not been defined in ActiveUser', 800000 /* Amity.ClientError.UNKNOWN_ERROR */, "error" /* Amity.ErrorLevel.ERROR */);
|
|
22712
|
+
const callbackDataSelector = (data) => {
|
|
22713
|
+
var _a;
|
|
22714
|
+
return {
|
|
22715
|
+
unreadCount: (_a = data === null || data === void 0 ? void 0 : data.unreadCount) !== null && _a !== void 0 ? _a : 0,
|
|
22716
|
+
hasMentioned: !!(data === null || data === void 0 ? void 0 : data.hasMentioned),
|
|
22717
|
+
};
|
|
22718
|
+
};
|
|
22719
|
+
return liveObject(userId, callback, 'userId', getUserMarker, [onUserMarkerFetched], {
|
|
22720
|
+
callbackDataSelector,
|
|
22721
|
+
});
|
|
22722
|
+
};
|
|
22723
|
+
|
|
22589
22724
|
/**
|
|
22590
22725
|
* ```js
|
|
22591
22726
|
* import { getChannelByIds } from '@amityco/ts-sdk'
|
|
@@ -22959,9 +23094,10 @@ const markAsRead = async (channelId) => {
|
|
|
22959
23094
|
const client = getActiveClient();
|
|
22960
23095
|
client.log('channel/markAsRead', channelId);
|
|
22961
23096
|
const { data } = await client.http.put(`/api/v1/markers/channels/${channelId}/mark-read`);
|
|
23097
|
+
const { userMarkers: userMarkersPayload, userEntityMarkers: userEntityMarkersPayload, userFeedMarkers: userFeedMarkersPayload } = data, rest = __rest(data, ["userMarkers", "userEntityMarkers", "userFeedMarkers"]);
|
|
22962
23098
|
const cachedAt = client.cache && Date.now();
|
|
22963
23099
|
if (client.cache)
|
|
22964
|
-
ingestInCache(
|
|
23100
|
+
ingestInCache(Object.assign({ userMarkers: convertUserMarkerResponse(userMarkersPayload), userEntityMarkers: convertChannelMarkerResponse(userEntityMarkersPayload), userFeedMarkers: convertSubChannelMarkerResponse(userFeedMarkersPayload) }, rest), { cachedAt });
|
|
22965
23101
|
return true;
|
|
22966
23102
|
};
|
|
22967
23103
|
|
|
@@ -23347,6 +23483,8 @@ const queryChannels = async (query) => {
|
|
|
23347
23483
|
return { data: channels, cachedAt, prevPage, nextPage };
|
|
23348
23484
|
};
|
|
23349
23485
|
|
|
23486
|
+
const uuid = () => nativeIdGenerator.v4().toString();
|
|
23487
|
+
|
|
23350
23488
|
/* begin_public_function
|
|
23351
23489
|
id: channel.query
|
|
23352
23490
|
*/
|
|
@@ -23379,7 +23517,7 @@ const getChannels = (params, callback, config) => {
|
|
|
23379
23517
|
const limit = queryLimit !== null && queryLimit !== void 0 ? queryLimit : COLLECTION_DEFAULT_PAGINATION_LIMIT;
|
|
23380
23518
|
const { policy = COLLECTION_DEFAULT_CACHING_POLICY } = config !== null && config !== void 0 ? config : {};
|
|
23381
23519
|
const disposers = [];
|
|
23382
|
-
const cacheKey = ['channel', 'collection',
|
|
23520
|
+
const cacheKey = ['channel', 'collection', uuid()];
|
|
23383
23521
|
const responder = (data) => {
|
|
23384
23522
|
var _a, _b;
|
|
23385
23523
|
let channels = (_a = data.data
|
|
@@ -23465,7 +23603,7 @@ const getChannels = (params, callback, config) => {
|
|
|
23465
23603
|
};
|
|
23466
23604
|
disposers.push(onChannelCreated(realtimeRouter()), onChannelDeleted(realtimeRouter()), onChannelUpdated(realtimeRouter()), onChannelMuted(realtimeRouter()), onChannelJoined(realtimeRouter()), onChannelLeft(realtimeRouter()), onChannelMemberAdded(realtimeRouter()), onChannelMemberRemoved(realtimeRouter()), convertEventPayload(onChannelMarkerFetched, 'entityId', 'channel')(realtimeRouter()));
|
|
23467
23605
|
onFetch(true);
|
|
23468
|
-
dropFromCache(cacheKey);
|
|
23606
|
+
disposers.push(() => dropFromCache(cacheKey));
|
|
23469
23607
|
return () => {
|
|
23470
23608
|
log(`getChannels(tmpid: ${timestamp}) > dispose`);
|
|
23471
23609
|
disposers.forEach(fn => fn());
|
|
@@ -23994,8 +24132,12 @@ var index$g = /*#__PURE__*/Object.freeze({
|
|
|
23994
24132
|
const onUserMarkerSync = (callback) => {
|
|
23995
24133
|
const client = getActiveClient();
|
|
23996
24134
|
const filter = (payload) => {
|
|
23997
|
-
|
|
23998
|
-
|
|
24135
|
+
const { userMarkers: userMarkersPayload, userEntityMarkers: userEntityMarkersPayload, userFeedMarkers: userFeedMarkersPayload } = payload, rest = __rest(payload, ["userMarkers", "userEntityMarkers", "userFeedMarkers"]);
|
|
24136
|
+
const userMarkers = convertUserMarkerResponse(userMarkersPayload);
|
|
24137
|
+
const userEntityMarkers = convertChannelMarkerResponse(userEntityMarkersPayload);
|
|
24138
|
+
const userFeedMarker = convertSubChannelMarkerResponse(userFeedMarkersPayload);
|
|
24139
|
+
ingestInCache(Object.assign({ userMarkers, userEntityMarkers, userFeedMarker }, rest));
|
|
24140
|
+
callback(userMarkers[0]);
|
|
23999
24141
|
};
|
|
24000
24142
|
return createEventSubscriber(client, 'UserMarker/onUserMarkerSync', 'marker.user-sync', filter);
|
|
24001
24143
|
};
|
|
@@ -24406,22 +24548,16 @@ const markerSyncTrigger = async () => {
|
|
|
24406
24548
|
// eslint-disable-next-line require-atomic-updates
|
|
24407
24549
|
isWaitingForResponse = false;
|
|
24408
24550
|
};
|
|
24409
|
-
/**
|
|
24410
|
-
* the event callback when app is back to online
|
|
24411
|
-
*/
|
|
24412
|
-
const onOnline = () => {
|
|
24413
|
-
// should add RESUME to the event to trigger marker syncing again
|
|
24414
|
-
const callback = () => events.push("resume" /* Amity.MarkerSyncEvent.RESUME */);
|
|
24415
|
-
window.addEventListener('online', callback);
|
|
24416
|
-
return () => window.removeEventListener('online', callback);
|
|
24417
|
-
};
|
|
24418
24551
|
const registerEventListeners = () => {
|
|
24419
24552
|
// based on the tech spec design, we designed a fetch marker in case of these events
|
|
24420
24553
|
// - new message
|
|
24421
24554
|
// - create channel
|
|
24422
24555
|
// - remove channel
|
|
24423
24556
|
// - app going to online again after offline
|
|
24424
|
-
disposers.push(onOnline()
|
|
24557
|
+
disposers.push(onOnline(() => {
|
|
24558
|
+
// should add RESUME to the event to trigger marker syncing again
|
|
24559
|
+
events.push("resume" /* Amity.MarkerSyncEvent.RESUME */);
|
|
24560
|
+
}), onMessageCreated(message => {
|
|
24425
24561
|
// only conversation, community and broadcast types can sync
|
|
24426
24562
|
if (isUnreadCountSupport(message))
|
|
24427
24563
|
events.push("new message" /* Amity.MarkerSyncEvent.NEW_MESSAGE */);
|
|
@@ -24508,6 +24644,7 @@ var index$f = /*#__PURE__*/Object.freeze({
|
|
|
24508
24644
|
onClientBanned: onClientBanned,
|
|
24509
24645
|
onSessionStateChange: onSessionStateChange,
|
|
24510
24646
|
getTotalUnreadCount: getTotalUnreadCount,
|
|
24647
|
+
getUserUnread: getUserUnread,
|
|
24511
24648
|
getMarkerSyncEvents: getMarkerSyncEvents,
|
|
24512
24649
|
setMarkerSyncEvents: setMarkerSyncEvents,
|
|
24513
24650
|
pushMarkerSyncEvent: pushMarkerSyncEvent,
|
|
@@ -26985,16 +27122,45 @@ getPost$1.locally = (postId) => {
|
|
|
26985
27122
|
};
|
|
26986
27123
|
};
|
|
26987
27124
|
|
|
27125
|
+
const commentLinkedObject = (comment) => {
|
|
27126
|
+
return Object.assign(Object.assign({}, comment), { get target() {
|
|
27127
|
+
const commentTypes = {
|
|
27128
|
+
type: comment.targetType,
|
|
27129
|
+
};
|
|
27130
|
+
if (comment.targetType === 'user') {
|
|
27131
|
+
return Object.assign(Object.assign({}, commentTypes), { userId: comment.targetId });
|
|
27132
|
+
}
|
|
27133
|
+
if (commentTypes.type === 'content') {
|
|
27134
|
+
return Object.assign(Object.assign({}, commentTypes), { contentId: comment.targetId });
|
|
27135
|
+
}
|
|
27136
|
+
if (commentTypes.type === 'community') {
|
|
27137
|
+
const cacheData = pullFromCache([
|
|
27138
|
+
'communityUsers',
|
|
27139
|
+
'get',
|
|
27140
|
+
`${comment.targetId}#${comment.userId}`,
|
|
27141
|
+
]);
|
|
27142
|
+
return Object.assign(Object.assign({}, commentTypes), { communityId: comment.targetId, creatorMember: cacheData === null || cacheData === void 0 ? void 0 : cacheData.data });
|
|
27143
|
+
}
|
|
27144
|
+
return {
|
|
27145
|
+
type: 'unknown',
|
|
27146
|
+
};
|
|
27147
|
+
} });
|
|
27148
|
+
};
|
|
27149
|
+
|
|
27150
|
+
const LinkedObject = {
|
|
27151
|
+
comment: commentLinkedObject,
|
|
27152
|
+
};
|
|
27153
|
+
|
|
26988
27154
|
/**
|
|
26989
27155
|
* ```js
|
|
26990
27156
|
* import { CommentRepository } from '@amityco/ts-sdk'
|
|
26991
27157
|
* const comment = await CommentRepository.getComment('foobar')
|
|
26992
27158
|
* ```
|
|
26993
27159
|
*
|
|
26994
|
-
* Fetches a {@link Amity.
|
|
27160
|
+
* Fetches a {@link Amity.InternalComment} object
|
|
26995
27161
|
*
|
|
26996
|
-
* @param commentId the ID of the {@link Amity.
|
|
26997
|
-
* @returns the associated {@link Amity.
|
|
27162
|
+
* @param commentId the ID of the {@link Amity.InternalComment} to fetch
|
|
27163
|
+
* @returns the associated {@link Amity.InternalComment} object
|
|
26998
27164
|
*
|
|
26999
27165
|
* @category Comment API
|
|
27000
27166
|
* @async
|
|
@@ -27020,7 +27186,7 @@ const getComment$1 = async (commentId) => {
|
|
|
27020
27186
|
ingestInCache(data, { cachedAt });
|
|
27021
27187
|
const { comments } = data;
|
|
27022
27188
|
return {
|
|
27023
|
-
data: comments.find(comment => comment.commentId === commentId),
|
|
27189
|
+
data: LinkedObject.comment(comments.find(comment => comment.commentId === commentId)),
|
|
27024
27190
|
cachedAt,
|
|
27025
27191
|
};
|
|
27026
27192
|
};
|
|
@@ -27030,10 +27196,10 @@ const getComment$1 = async (commentId) => {
|
|
|
27030
27196
|
* const comment = getComment.locally('foobar')
|
|
27031
27197
|
* ```
|
|
27032
27198
|
*
|
|
27033
|
-
* Fetches a {@link Amity.
|
|
27199
|
+
* Fetches a {@link Amity.InternalComment} object
|
|
27034
27200
|
*
|
|
27035
|
-
* @param commentId the ID of the {@link Amity.
|
|
27036
|
-
* @returns the associated {@link Amity.
|
|
27201
|
+
* @param commentId the ID of the {@link Amity.InternalComment} to fetch
|
|
27202
|
+
* @returns the associated {@link Amity.InternalComment} object
|
|
27037
27203
|
*
|
|
27038
27204
|
* @category Comment API
|
|
27039
27205
|
*/
|
|
@@ -27534,12 +27700,12 @@ const createCommentEventSubscriber = (event, callback) => {
|
|
|
27534
27700
|
* })
|
|
27535
27701
|
* ```
|
|
27536
27702
|
*
|
|
27537
|
-
* Fired when a {@link Amity.
|
|
27703
|
+
* Fired when a {@link Amity.InternalComment} has been created
|
|
27538
27704
|
*
|
|
27539
27705
|
* @param callback The function to call when the event was fired
|
|
27540
27706
|
* @returns an {@link Amity.Unsubscriber} function to stop listening
|
|
27541
27707
|
*
|
|
27542
|
-
* @category
|
|
27708
|
+
* @category InternalComment Events
|
|
27543
27709
|
*/
|
|
27544
27710
|
const onCommentCreated = (callback) => createCommentEventSubscriber('comment.created', callback);
|
|
27545
27711
|
|
|
@@ -27551,12 +27717,12 @@ const onCommentCreated = (callback) => createCommentEventSubscriber('comment.cre
|
|
|
27551
27717
|
* })
|
|
27552
27718
|
* ```
|
|
27553
27719
|
*
|
|
27554
|
-
* Fired when a {@link Amity.
|
|
27720
|
+
* Fired when a {@link Amity.InternalComment} has been updated
|
|
27555
27721
|
*
|
|
27556
27722
|
* @param callback The function to call when the event was fired
|
|
27557
27723
|
* @returns an {@link Amity.Unsubscriber} function to stop listening
|
|
27558
27724
|
*
|
|
27559
|
-
* @category
|
|
27725
|
+
* @category InternalComment Events
|
|
27560
27726
|
*/
|
|
27561
27727
|
const onCommentUpdated = (callback) => createCommentEventSubscriber('comment.updated', callback);
|
|
27562
27728
|
|
|
@@ -27568,12 +27734,12 @@ const onCommentUpdated = (callback) => createCommentEventSubscriber('comment.upd
|
|
|
27568
27734
|
* })
|
|
27569
27735
|
* ```
|
|
27570
27736
|
*
|
|
27571
|
-
* Fired when a {@link Amity.
|
|
27737
|
+
* Fired when a {@link Amity.InternalComment} has been deleted
|
|
27572
27738
|
*
|
|
27573
27739
|
* @param callback The function to call when the event was fired
|
|
27574
27740
|
* @returns an {@link Amity.Unsubscriber} function to stop listening
|
|
27575
27741
|
*
|
|
27576
|
-
* @category
|
|
27742
|
+
* @category InternalComment Events
|
|
27577
27743
|
*/
|
|
27578
27744
|
const onCommentDeleted = (callback) => createCommentEventSubscriber('comment.deleted', callback);
|
|
27579
27745
|
|
|
@@ -27585,12 +27751,12 @@ const onCommentDeleted = (callback) => createCommentEventSubscriber('comment.del
|
|
|
27585
27751
|
* })
|
|
27586
27752
|
* ```
|
|
27587
27753
|
*
|
|
27588
|
-
* Fired when a {@link Amity.
|
|
27754
|
+
* Fired when a {@link Amity.InternalComment} has been flagged
|
|
27589
27755
|
*
|
|
27590
27756
|
* @param callback The function to call when the event was fired
|
|
27591
27757
|
* @returns an {@link Amity.Unsubscriber} function to stop listening
|
|
27592
27758
|
*
|
|
27593
|
-
* @category
|
|
27759
|
+
* @category InternalComment Events
|
|
27594
27760
|
*/
|
|
27595
27761
|
const onCommentFlagged = (callback) => createCommentEventSubscriber('comment.flagged', callback);
|
|
27596
27762
|
|
|
@@ -27602,12 +27768,12 @@ const onCommentFlagged = (callback) => createCommentEventSubscriber('comment.fla
|
|
|
27602
27768
|
* })
|
|
27603
27769
|
* ```
|
|
27604
27770
|
*
|
|
27605
|
-
* Fired when a flag has been removed from a {@link Amity.
|
|
27771
|
+
* Fired when a flag has been removed from a {@link Amity.InternalComment}
|
|
27606
27772
|
*
|
|
27607
27773
|
* @param callback The function to call when the event was fired
|
|
27608
27774
|
* @returns an {@link Amity.Unsubscriber} function to stop listening
|
|
27609
27775
|
*
|
|
27610
|
-
* @category
|
|
27776
|
+
* @category InternalComment Events
|
|
27611
27777
|
*/
|
|
27612
27778
|
const onCommentUnflagged = (callback) => createCommentEventSubscriber('comment.unflagged', callback);
|
|
27613
27779
|
|
|
@@ -27619,12 +27785,12 @@ const onCommentUnflagged = (callback) => createCommentEventSubscriber('comment.u
|
|
|
27619
27785
|
* })
|
|
27620
27786
|
* ```
|
|
27621
27787
|
*
|
|
27622
|
-
* Fired when a {@link Amity.
|
|
27788
|
+
* Fired when a {@link Amity.InternalComment} has been reacted
|
|
27623
27789
|
*
|
|
27624
27790
|
* @param callback The function to call when the event was fired
|
|
27625
27791
|
* @returns an {@link Amity.Unsubscriber} function to stop listening
|
|
27626
27792
|
*
|
|
27627
|
-
* @category
|
|
27793
|
+
* @category InternalComment Events
|
|
27628
27794
|
*/
|
|
27629
27795
|
const onCommentReactionAdded = (callback) => {
|
|
27630
27796
|
const client = getActiveClient();
|
|
@@ -27655,12 +27821,12 @@ const onCommentReactionAdded = (callback) => {
|
|
|
27655
27821
|
* })
|
|
27656
27822
|
* ```
|
|
27657
27823
|
*
|
|
27658
|
-
* Fired when a reaction has been removed from a {@link Amity.
|
|
27824
|
+
* Fired when a reaction has been removed from a {@link Amity.InternalComment}
|
|
27659
27825
|
*
|
|
27660
27826
|
* @param callback The function to call when the event was fired
|
|
27661
27827
|
* @returns an {@link Amity.Unsubscriber} function to stop listening
|
|
27662
27828
|
*
|
|
27663
|
-
* @category
|
|
27829
|
+
* @category InternalComment Events
|
|
27664
27830
|
*/
|
|
27665
27831
|
const onCommentReactionRemoved = (callback) => {
|
|
27666
27832
|
const client = getActiveClient();
|
|
@@ -28265,8 +28431,6 @@ getMessages$1.locally = (messageIds) => {
|
|
|
28265
28431
|
};
|
|
28266
28432
|
};
|
|
28267
28433
|
|
|
28268
|
-
const uuid = () => nativeIdGenerator.v4().toString();
|
|
28269
|
-
|
|
28270
28434
|
const getLocalId = () => `LOCAL_${uuid()}`;
|
|
28271
28435
|
// FIXME: temp solution
|
|
28272
28436
|
let uniqueId;
|
|
@@ -28638,9 +28802,10 @@ const markAsDelivered = async (subChannelId, messageId) => {
|
|
|
28638
28802
|
const client = getActiveClient();
|
|
28639
28803
|
client.log('message/markAsDelivered', subChannelId, messageId);
|
|
28640
28804
|
const { data } = await client.http.put(`/api/v1/markers/message-feeds/${subChannelId}/mark-delivering`, { messageId });
|
|
28805
|
+
const { userMarkers, userEntityMarkers, userFeedMarkers } = data, rest = __rest(data, ["userMarkers", "userEntityMarkers", "userFeedMarkers"]);
|
|
28641
28806
|
const cachedAt = client.cache && Date.now();
|
|
28642
28807
|
if (client.cache)
|
|
28643
|
-
ingestInCache(
|
|
28808
|
+
ingestInCache(Object.assign({ userMarkers: convertUserMarkerResponse(userMarkers), userEntityMarkers: convertChannelMarkerResponse(userEntityMarkers), userFeedMarkers: convertSubChannelMarkerResponse(userFeedMarkers) }, rest), { cachedAt });
|
|
28644
28809
|
return true;
|
|
28645
28810
|
};
|
|
28646
28811
|
|
|
@@ -28670,10 +28835,10 @@ const getReadUsers = async (query) => {
|
|
|
28670
28835
|
token: toToken(page, 'afterbeforeraw'),
|
|
28671
28836
|
} }),
|
|
28672
28837
|
});
|
|
28673
|
-
const { paging, publicUserIds: readUsers } = data, payload = __rest(data, ["paging", "publicUserIds"]);
|
|
28838
|
+
const { paging, publicUserIds: readUsers, userFeedMarkers } = data, payload = __rest(data, ["paging", "publicUserIds", "userFeedMarkers"]);
|
|
28674
28839
|
const cachedAt = client.cache && Date.now();
|
|
28675
28840
|
if (client.cache) {
|
|
28676
|
-
ingestInCache(payload, { cachedAt });
|
|
28841
|
+
ingestInCache(Object.assign(Object.assign({}, payload), { userFeedMarkers: convertSubChannelMarkerResponse(userFeedMarkers) }), { cachedAt });
|
|
28677
28842
|
const cacheKey = [
|
|
28678
28843
|
'read-user',
|
|
28679
28844
|
'query',
|
|
@@ -28751,10 +28916,10 @@ const getDeliveredUsers = async (query) => {
|
|
|
28751
28916
|
token: toToken(page, 'afterbeforeraw'),
|
|
28752
28917
|
} }),
|
|
28753
28918
|
});
|
|
28754
|
-
const { paging, publicUserIds: deliveredUsers } = data, payload = __rest(data, ["paging", "publicUserIds"]);
|
|
28919
|
+
const { paging, publicUserIds: deliveredUsers, userFeedMarkers } = data, payload = __rest(data, ["paging", "publicUserIds", "userFeedMarkers"]);
|
|
28755
28920
|
const cachedAt = client.cache && Date.now();
|
|
28756
28921
|
if (client.cache) {
|
|
28757
|
-
ingestInCache(payload, { cachedAt });
|
|
28922
|
+
ingestInCache(Object.assign(Object.assign({}, payload), { userFeedMarkers: convertSubChannelMarkerResponse(userFeedMarkers) }), { cachedAt });
|
|
28758
28923
|
const cacheKey = [
|
|
28759
28924
|
'delivered-user',
|
|
28760
28925
|
'query',
|
|
@@ -32515,10 +32680,10 @@ var index$3 = /*#__PURE__*/Object.freeze({
|
|
|
32515
32680
|
* const comments = await CommentRepository.getCommentByIds(['foo', 'bar'])
|
|
32516
32681
|
* ```
|
|
32517
32682
|
*
|
|
32518
|
-
* Fetches a collection of {@link Amity.
|
|
32683
|
+
* Fetches a collection of {@link Amity.InternalComment} objects
|
|
32519
32684
|
*
|
|
32520
|
-
* @param commentIds the IDs of the {@link Amity.
|
|
32521
|
-
* @returns the associated collection of {@link Amity.
|
|
32685
|
+
* @param commentIds the IDs of the {@link Amity.InternalComment} to fetch
|
|
32686
|
+
* @returns the associated collection of {@link Amity.InternalComment} objects
|
|
32522
32687
|
*
|
|
32523
32688
|
* @category Comment API
|
|
32524
32689
|
* @async
|
|
@@ -32558,10 +32723,10 @@ const getCommentByIds = async (commentIds) => {
|
|
|
32558
32723
|
* const comments = getCommentByIds.locally(['foo', 'bar'])
|
|
32559
32724
|
* ```
|
|
32560
32725
|
*
|
|
32561
|
-
* Fetches a collection of {@link Amity.
|
|
32726
|
+
* Fetches a collection of {@link Amity.InternalComment} objects from cache
|
|
32562
32727
|
*
|
|
32563
|
-
* @param commentIds the IDs of the {@link Amity.
|
|
32564
|
-
* @returns the associated collection of {@link Amity.
|
|
32728
|
+
* @param commentIds the IDs of the {@link Amity.InternalComment} to fetch
|
|
32729
|
+
* @returns the associated collection of {@link Amity.InternalComment} objects
|
|
32565
32730
|
*
|
|
32566
32731
|
* @category Comment API
|
|
32567
32732
|
*/
|
|
@@ -32593,10 +32758,10 @@ getCommentByIds.locally = (commentIds) => {
|
|
|
32593
32758
|
* const newComment = await CommentRepository.createComment(bundle)
|
|
32594
32759
|
* ```
|
|
32595
32760
|
*
|
|
32596
|
-
* Creates an {@link Amity.
|
|
32761
|
+
* Creates an {@link Amity.InternalComment}
|
|
32597
32762
|
*
|
|
32598
|
-
* @param bundle The data necessary to create a new {@link Amity.
|
|
32599
|
-
* @returns The newly created {@link Amity.
|
|
32763
|
+
* @param bundle The data necessary to create a new {@link Amity.InternalComment}
|
|
32764
|
+
* @returns The newly created {@link Amity.InternalComment}
|
|
32600
32765
|
*
|
|
32601
32766
|
* @category Comment API
|
|
32602
32767
|
* @async
|
|
@@ -32640,11 +32805,11 @@ const createComment = async (bundle) => {
|
|
|
32640
32805
|
* })
|
|
32641
32806
|
* ```
|
|
32642
32807
|
*
|
|
32643
|
-
* Updates an {@link Amity.
|
|
32808
|
+
* Updates an {@link Amity.InternalComment}
|
|
32644
32809
|
*
|
|
32645
|
-
* @param commentId The ID of the {@link Amity.
|
|
32810
|
+
* @param commentId The ID of the {@link Amity.InternalComment} to edit
|
|
32646
32811
|
* @param patch The patch data to apply
|
|
32647
|
-
* @returns the updated {@link Amity.
|
|
32812
|
+
* @returns the updated {@link Amity.InternalComment} object
|
|
32648
32813
|
*
|
|
32649
32814
|
* @category Comment API
|
|
32650
32815
|
* @async
|
|
@@ -32674,10 +32839,10 @@ const updateComment = async (commentId, patch) => {
|
|
|
32674
32839
|
* const success = await CommentRepository.deleteComment('foobar')
|
|
32675
32840
|
* ```
|
|
32676
32841
|
*
|
|
32677
|
-
* Deletes a {@link Amity.
|
|
32842
|
+
* Deletes a {@link Amity.InternalComment}
|
|
32678
32843
|
*
|
|
32679
|
-
* @param commentId The {@link Amity.
|
|
32680
|
-
* @return A success boolean if the {@link Amity.
|
|
32844
|
+
* @param commentId The {@link Amity.InternalComment} ID to delete
|
|
32845
|
+
* @return A success boolean if the {@link Amity.InternalComment} was deleted
|
|
32681
32846
|
*
|
|
32682
32847
|
* @category Comment API
|
|
32683
32848
|
* @async
|
|
@@ -32711,6 +32876,7 @@ const deleteComment = async (commentId, permanent = false) => {
|
|
|
32711
32876
|
commentChildren: [],
|
|
32712
32877
|
files: [],
|
|
32713
32878
|
users: [],
|
|
32879
|
+
communityUsers: [],
|
|
32714
32880
|
});
|
|
32715
32881
|
if (permanent) {
|
|
32716
32882
|
scheduleTask(() => pushToTombstone('comment', commentId));
|
|
@@ -32731,10 +32897,10 @@ const deleteComment = async (commentId, permanent = false) => {
|
|
|
32731
32897
|
* const success = await CommentRepository.softDeleteComment('foobar')
|
|
32732
32898
|
* ```
|
|
32733
32899
|
*
|
|
32734
|
-
* Deletes a {@link Amity.
|
|
32900
|
+
* Deletes a {@link Amity.InternalComment}
|
|
32735
32901
|
*
|
|
32736
|
-
* @param commentId The {@link Amity.
|
|
32737
|
-
* @return A success boolean if the {@link Amity.
|
|
32902
|
+
* @param commentId The {@link Amity.InternalComment} ID to delete
|
|
32903
|
+
* @return A success boolean if the {@link Amity.InternalComment} was deleted
|
|
32738
32904
|
*
|
|
32739
32905
|
* @category Comment API
|
|
32740
32906
|
* @async
|
|
@@ -32756,10 +32922,10 @@ const softDeleteComment = async (commentId) => {
|
|
|
32756
32922
|
* const success = await CommentRepository.hardDeleteComment('foobar')
|
|
32757
32923
|
* ```
|
|
32758
32924
|
*
|
|
32759
|
-
* Deletes a {@link Amity.
|
|
32925
|
+
* Deletes a {@link Amity.InternalComment}
|
|
32760
32926
|
*
|
|
32761
|
-
* @param commentId The {@link Amity.
|
|
32762
|
-
* @return A success boolean if the {@link Amity.
|
|
32927
|
+
* @param commentId The {@link Amity.InternalComment} ID to delete
|
|
32928
|
+
* @return A success boolean if the {@link Amity.InternalComment} was deleted
|
|
32763
32929
|
*
|
|
32764
32930
|
* @category Comment API
|
|
32765
32931
|
* @async
|
|
@@ -32860,13 +33026,13 @@ const isCommentFlaggedByMe = async (commentId) => {
|
|
|
32860
33026
|
* const unsub = observeComments(postId, comment => merge(comments, comment))
|
|
32861
33027
|
* ```
|
|
32862
33028
|
*
|
|
32863
|
-
* Observe all mutations on a list of {@link Amity.
|
|
33029
|
+
* Observe all mutations on a list of {@link Amity.InternalComment} for a given {@link Amity.Post} object
|
|
32864
33030
|
*
|
|
32865
33031
|
* @param postId the ID of the post where to observe the comments
|
|
32866
33032
|
* @param callback the function to call when new data are available
|
|
32867
33033
|
* @returns An {@link Amity.Unsubscriber} function to run when willing to stop observing the comments
|
|
32868
33034
|
*
|
|
32869
|
-
* @category
|
|
33035
|
+
* @category InternalComment Observer
|
|
32870
33036
|
*/
|
|
32871
33037
|
const observeComments = (postId, callback) => {
|
|
32872
33038
|
const { log } = getActiveClient();
|
|
@@ -32897,13 +33063,13 @@ const observeComments = (postId, callback) => {
|
|
|
32897
33063
|
* const dispose = observeComment(commentId, ({ data }) => comment = data)
|
|
32898
33064
|
* ```
|
|
32899
33065
|
*
|
|
32900
|
-
* Observe all mutation on a given {@link Amity.
|
|
33066
|
+
* Observe all mutation on a given {@link Amity.InternalComment}
|
|
32901
33067
|
*
|
|
32902
33068
|
* @param commentId the ID of the comment to observe
|
|
32903
33069
|
* @param callback the function to call when new data are available
|
|
32904
33070
|
* @returns An {@link Amity.Unsubscriber} function to run when willing to stop observing the comment
|
|
32905
33071
|
*
|
|
32906
|
-
* @category
|
|
33072
|
+
* @category InternalComment Observer
|
|
32907
33073
|
*/
|
|
32908
33074
|
const observeComment = (commentId, callback, policy = 'cache_then_server') => {
|
|
32909
33075
|
const { log } = getActiveClient();
|
|
@@ -32947,13 +33113,13 @@ const observeComment = (commentId, callback, policy = 'cache_then_server') => {
|
|
|
32947
33113
|
* });
|
|
32948
33114
|
* ```
|
|
32949
33115
|
*
|
|
32950
|
-
* Observe all mutation on a given {@link Amity.
|
|
33116
|
+
* Observe all mutation on a given {@link Amity.InternalComment}
|
|
32951
33117
|
*
|
|
32952
33118
|
* @param commentId the ID of the comment to observe
|
|
32953
33119
|
* @param callback the function to call when new data are available
|
|
32954
33120
|
* @returns An {@link Amity.Unsubscriber} function to run when willing to stop observing the comment
|
|
32955
33121
|
*
|
|
32956
|
-
* @category
|
|
33122
|
+
* @category InternalComment Live Object
|
|
32957
33123
|
*/
|
|
32958
33124
|
const getComment = (commentId, callback) => {
|
|
32959
33125
|
return liveObject(commentId, callback, 'commentId', getComment$1, [
|
|
@@ -32973,10 +33139,10 @@ const getComment = (commentId, callback) => {
|
|
|
32973
33139
|
* const comments = await CommentRepository.queryComments({ referenceType: 'post', referenceId: 'foo' })
|
|
32974
33140
|
* ```
|
|
32975
33141
|
*
|
|
32976
|
-
* Queries a paginable list of {@link Amity.
|
|
33142
|
+
* Queries a paginable list of {@link Amity.InternalComment} objects
|
|
32977
33143
|
*
|
|
32978
33144
|
* @param query The query parameters
|
|
32979
|
-
* @returns A page of {@link Amity.
|
|
33145
|
+
* @returns A page of {@link Amity.InternalComment} objects
|
|
32980
33146
|
*
|
|
32981
33147
|
* @category Comment API
|
|
32982
33148
|
* @async
|
|
@@ -33026,12 +33192,12 @@ const queryComments = async (query) => {
|
|
|
33026
33192
|
*
|
|
33027
33193
|
* let comments = []
|
|
33028
33194
|
* const unsub = getComments({
|
|
33029
|
-
* referenceType: Amity.
|
|
33030
|
-
* referenceId: Amity.
|
|
33195
|
+
* referenceType: Amity.InternalComment['referenceType'];
|
|
33196
|
+
* referenceId: Amity.InternalComment['referenceId'];
|
|
33031
33197
|
* }, response => merge(comments, response.data))
|
|
33032
33198
|
* ```
|
|
33033
33199
|
*
|
|
33034
|
-
* Observe all mutations on a list of {@link Amity.
|
|
33200
|
+
* Observe all mutations on a list of {@link Amity.InternalComment} for a given target object
|
|
33035
33201
|
*
|
|
33036
33202
|
* @param referenceType the type of the target
|
|
33037
33203
|
* @param referenceId the ID of the target
|
|
@@ -33061,7 +33227,7 @@ const getComments = (params, callback, config) => {
|
|
|
33061
33227
|
let comments = (_a = data.data
|
|
33062
33228
|
.map(commentId => pullFromCache(['comment', 'get', commentId]))
|
|
33063
33229
|
.filter(Boolean)
|
|
33064
|
-
.map(({ data }) => data)) !== null && _a !== void 0 ? _a : [];
|
|
33230
|
+
.map(({ data }) => LinkedObject.comment(data))) !== null && _a !== void 0 ? _a : [];
|
|
33065
33231
|
if (!params.includeDeleted) {
|
|
33066
33232
|
comments = filterByPropEquality(comments, 'isDeleted', false);
|
|
33067
33233
|
}
|