@amityco/ts-sdk-react-native 6.23.0 → 6.23.1-d5c2fe6.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/.env +26 -26
- package/dist/@types/core/events.d.ts +5 -0
- package/dist/@types/core/events.d.ts.map +1 -1
- package/dist/@types/domains/community.d.ts +16 -1
- package/dist/@types/domains/community.d.ts.map +1 -1
- package/dist/client/api/secureLogout.d.ts +1 -1
- package/dist/client/utils/ReadReceiptSync/readReceiptSyncEngine.d.ts.map +1 -1
- package/dist/commentRepository/api/deleteComment.d.ts.map +1 -1
- package/dist/commentRepository/events/utils.d.ts.map +1 -1
- package/dist/commentRepository/internalApi/createComment.d.ts.map +1 -1
- package/dist/communityRepository/api/createCommunity.d.ts.map +1 -1
- package/dist/communityRepository/api/getCommunities.d.ts.map +1 -1
- package/dist/communityRepository/api/getCommunity.d.ts.map +1 -1
- package/dist/communityRepository/api/queryCommunities.d.ts.map +1 -1
- package/dist/communityRepository/api/updateCommunity.d.ts.map +1 -1
- package/dist/communityRepository/communityMembership/observers/getMembers/CommunityMembersLiveCollectionController.d.ts +14 -0
- package/dist/communityRepository/communityMembership/observers/getMembers/CommunityMembersLiveCollectionController.d.ts.map +1 -0
- package/dist/communityRepository/communityMembership/observers/getMembers/CommunityMembersPaginationController.d.ts +9 -0
- package/dist/communityRepository/communityMembership/observers/getMembers/CommunityMembersPaginationController.d.ts.map +1 -0
- package/dist/communityRepository/communityMembership/observers/getMembers/CommunityMembersQueryStreamController.d.ts +15 -0
- package/dist/communityRepository/communityMembership/observers/getMembers/CommunityMembersQueryStreamController.d.ts.map +1 -0
- package/dist/communityRepository/communityMembership/observers/getMembers/enums.d.ts +10 -0
- package/dist/communityRepository/communityMembership/observers/getMembers/enums.d.ts.map +1 -0
- package/dist/communityRepository/communityMembership/observers/getMembers.d.ts.map +1 -1
- package/dist/communityRepository/communityMembership/observers/searchMembers.d.ts +20 -0
- package/dist/communityRepository/communityMembership/observers/searchMembers.d.ts.map +1 -0
- package/dist/communityRepository/observers/getCommunities/CommunitiesLiveCollectionController.d.ts +14 -0
- package/dist/communityRepository/observers/getCommunities/CommunitiesLiveCollectionController.d.ts.map +1 -0
- package/dist/communityRepository/observers/getCommunities/CommunitiesPaginationController.d.ts +9 -0
- package/dist/communityRepository/observers/getCommunities/CommunitiesPaginationController.d.ts.map +1 -0
- package/dist/communityRepository/observers/getCommunities/CommunitiesQueryStreamController.d.ts +15 -0
- package/dist/communityRepository/observers/getCommunities/CommunitiesQueryStreamController.d.ts.map +1 -0
- package/dist/communityRepository/observers/getCommunities/enums.d.ts +6 -0
- package/dist/communityRepository/observers/getCommunities/enums.d.ts.map +1 -0
- package/dist/communityRepository/observers/getCommunities.d.ts.map +1 -1
- package/dist/communityRepository/observers/index.d.ts +1 -0
- package/dist/communityRepository/observers/index.d.ts.map +1 -1
- package/dist/communityRepository/observers/searchCommunities/SearchCommunitiesLiveCollectionController.d.ts +14 -0
- package/dist/communityRepository/observers/searchCommunities/SearchCommunitiesLiveCollectionController.d.ts.map +1 -0
- package/dist/communityRepository/observers/searchCommunities/SearchCommunitiesPaginationController.d.ts +9 -0
- package/dist/communityRepository/observers/searchCommunities/SearchCommunitiesPaginationController.d.ts.map +1 -0
- package/dist/communityRepository/observers/searchCommunities/SearchCommunitiesQueryStreamController.d.ts +15 -0
- package/dist/communityRepository/observers/searchCommunities/SearchCommunitiesQueryStreamController.d.ts.map +1 -0
- package/dist/communityRepository/observers/searchCommunities/enums.d.ts +6 -0
- package/dist/communityRepository/observers/searchCommunities/enums.d.ts.map +1 -0
- package/dist/communityRepository/observers/searchCommunities.d.ts +20 -0
- package/dist/communityRepository/observers/searchCommunities.d.ts.map +1 -0
- package/dist/communityRepository/utils/payload.d.ts.map +1 -1
- package/dist/communityRepository/utils/saveCommunityUsers.d.ts +2 -0
- package/dist/communityRepository/utils/saveCommunityUsers.d.ts.map +1 -0
- package/dist/core/events.d.ts +3 -3
- package/dist/core/events.d.ts.map +1 -1
- package/dist/core/liveCollection/LiveCollectionController.d.ts +4 -1
- package/dist/core/liveCollection/LiveCollectionController.d.ts.map +1 -1
- package/dist/index.cjs.js +1149 -797
- package/dist/index.esm.js +1148 -796
- package/dist/index.umd.js +4 -4
- package/dist/marker/events/onChannelUnreadUpdatedLocal.d.ts +12 -0
- package/dist/marker/events/onChannelUnreadUpdatedLocal.d.ts.map +1 -0
- package/dist/marker/events/onSubChannelUnreadUpdatedLocal.d.ts +12 -0
- package/dist/marker/events/onSubChannelUnreadUpdatedLocal.d.ts.map +1 -0
- package/dist/marker/events/onUserFeedMarkerUpdated.d.ts.map +1 -1
- package/dist/marker/utils/reCalculateChannelUnreadInfo.d.ts +1 -1
- package/dist/marker/utils/reCalculateChannelUnreadInfo.d.ts.map +1 -1
- package/dist/postRepository/observers/getPost.d.ts.map +1 -1
- package/dist/postRepository/observers/getPosts.d.ts.map +1 -1
- package/dist/streamRepository/api/getStreams.d.ts +2 -2
- package/dist/streamRepository/events/onStreamFlagged.d.ts +17 -0
- package/dist/streamRepository/events/onStreamFlagged.d.ts.map +1 -0
- package/dist/streamRepository/events/onStreamTerminated.d.ts +17 -0
- package/dist/streamRepository/events/onStreamTerminated.d.ts.map +1 -0
- package/dist/streamRepository/observers/getStreams.d.ts +1 -1
- package/dist/utils/liveObject.d.ts +3 -0
- package/dist/utils/liveObject.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/@types/core/events.ts +8 -0
- package/src/@types/domains/community.ts +26 -1
- package/src/channelRepository/channelMembership/observers/getMembers/ChannelMemberLiveCollectionController.ts +2 -2
- package/src/channelRepository/observers/getChannel.ts +2 -2
- package/src/channelRepository/observers/getChannels/ChannelLiveCollectionController.ts +7 -7
- package/src/client/api/secureLogout.ts +1 -1
- package/src/client/utils/ReadReceiptSync/readReceiptSyncEngine.ts +6 -3
- package/src/commentRepository/api/createComment.ts +2 -2
- package/src/commentRepository/api/deleteComment.ts +2 -4
- package/src/commentRepository/events/utils.ts +8 -5
- package/src/commentRepository/internalApi/createComment.ts +3 -2
- package/src/commentRepository/internalApi/deleteComment.ts +2 -2
- package/src/communityRepository/api/createCommunity.ts +5 -2
- package/src/communityRepository/api/getCommunities.ts +5 -1
- package/src/communityRepository/api/getCommunity.ts +5 -1
- package/src/communityRepository/api/queryCommunities.ts +2 -2
- package/src/communityRepository/api/updateCommunity.ts +5 -1
- package/src/communityRepository/communityMembership/observers/getMembers/CommunityMembersLiveCollectionController.ts +152 -0
- package/src/communityRepository/communityMembership/observers/getMembers/CommunityMembersPaginationController.ts +26 -0
- package/src/communityRepository/communityMembership/observers/getMembers/CommunityMembersQueryStreamController.ts +107 -0
- package/src/communityRepository/communityMembership/observers/getMembers/enums.ts +9 -0
- package/src/communityRepository/communityMembership/observers/getMembers.ts +15 -128
- package/src/communityRepository/communityMembership/observers/searchMembers.ts +60 -0
- package/src/communityRepository/observers/getCommunities/CommunitiesLiveCollectionController.ts +147 -0
- package/src/communityRepository/observers/getCommunities/CommunitiesPaginationController.ts +31 -0
- package/src/communityRepository/observers/getCommunities/CommunitiesQueryStreamController.ts +88 -0
- package/src/communityRepository/observers/getCommunities/enums.ts +5 -0
- package/src/communityRepository/observers/getCommunities.ts +7 -150
- package/src/communityRepository/observers/index.ts +1 -0
- package/src/communityRepository/observers/searchCommunities/SearchCommunitiesLiveCollectionController.ts +129 -0
- package/src/communityRepository/observers/searchCommunities/SearchCommunitiesPaginationController.ts +31 -0
- package/src/communityRepository/observers/searchCommunities/SearchCommunitiesQueryStreamController.ts +81 -0
- package/src/communityRepository/observers/searchCommunities/enums.ts +5 -0
- package/src/communityRepository/observers/searchCommunities.ts +56 -0
- package/src/communityRepository/utils/payload.ts +35 -1
- package/src/communityRepository/utils/saveCommunityUsers.ts +16 -0
- package/src/core/liveCollection/LiveCollectionController.ts +6 -3
- package/src/marker/events/onChannelUnreadUpdatedLocal.ts +29 -0
- package/src/marker/events/onSubChannelMarkerFetched.ts +1 -1
- package/src/marker/events/onSubChannelUnreadUpdatedLocal.ts +29 -0
- package/src/marker/events/onUserFeedMarkerUpdated.ts +3 -4
- package/src/marker/utils/reCalculateChannelUnreadInfo.ts +7 -3
- package/src/messageRepository/observers/getMessages/MessageLiveCollectionController.ts +3 -3
- package/src/postRepository/api/editPost.ts +1 -1
- package/src/postRepository/api/updatePost.ts +1 -1
- package/src/postRepository/observers/getPost.ts +26 -0
- package/src/postRepository/observers/getPosts.ts +31 -0
- package/src/storyRepository/observers/getGlobalStoryTargets/GlobalStoryLiveCollectionController.ts +2 -2
- package/src/storyRepository/observers/getStoriesByTargetIds/StoryLiveCollectionController.ts +1 -1
- package/src/streamRepository/api/getStreams.ts +2 -2
- package/src/streamRepository/events/onStreamFlagged.ts +37 -0
- package/src/streamRepository/events/onStreamTerminated.ts +37 -0
- package/src/streamRepository/observers/getStreams.ts +1 -1
- package/src/subChannelRepository/observers/getSubChannel.ts +2 -2
- package/src/subChannelRepository/observers/getSubChannels/SubChannelLiveCollectionController.ts +4 -4
- package/src/utils/liveObject.ts +3 -0
|
@@ -57,10 +57,13 @@ export abstract class LiveCollectionController<
|
|
|
57
57
|
}
|
|
58
58
|
}
|
|
59
59
|
|
|
60
|
-
protected loadPage(
|
|
60
|
+
protected loadPage({
|
|
61
61
|
initial = false,
|
|
62
|
-
direction
|
|
63
|
-
|
|
62
|
+
direction = Amity.LiveCollectionPageDirection.NEXT,
|
|
63
|
+
}: {
|
|
64
|
+
initial?: boolean;
|
|
65
|
+
direction?: Amity.LiveCollectionPageDirection;
|
|
66
|
+
}) {
|
|
64
67
|
this.setup();
|
|
65
68
|
|
|
66
69
|
this.notifyChange({ origin: Amity.LiveDataOrigin.LOCAL, loading: true });
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { getActiveClient } from '~/client/api/activeClient';
|
|
2
|
+
import { createEventSubscriber } from '~/core/events';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Internal used only
|
|
6
|
+
*
|
|
7
|
+
* Fired when an {@link Amity.userMessageFeedMarkers} has been resolved by Object Rsesolver
|
|
8
|
+
*
|
|
9
|
+
* @param callback The function to call when the event was fired
|
|
10
|
+
* @returns an {@link Amity.Unsubscriber} function to stop listening
|
|
11
|
+
*
|
|
12
|
+
* @category MessageMarker Events
|
|
13
|
+
*/
|
|
14
|
+
export const onChannelUnreadUpdatedLocal = (
|
|
15
|
+
callback: Amity.Listener<Amity.Events['local.channelUnread.updated']>,
|
|
16
|
+
): Amity.Unsubscriber => {
|
|
17
|
+
const client = getActiveClient();
|
|
18
|
+
|
|
19
|
+
const filter = (payload: Amity.Events['local.channelUnread.updated']) => {
|
|
20
|
+
callback(payload);
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
return createEventSubscriber(
|
|
24
|
+
client,
|
|
25
|
+
'channelMarker/onChannelUnreadUpdatedLocal',
|
|
26
|
+
'local.channelUnread.updated',
|
|
27
|
+
filter,
|
|
28
|
+
);
|
|
29
|
+
};
|
|
@@ -22,7 +22,7 @@ export const onSubChannelMarkerFetched = (
|
|
|
22
22
|
const client = getActiveClient();
|
|
23
23
|
|
|
24
24
|
const filter = (payload: Amity.Events['local.subChannelMarker.fetched']) => {
|
|
25
|
-
|
|
25
|
+
payload.userFeedMarkers.forEach(callback);
|
|
26
26
|
};
|
|
27
27
|
|
|
28
28
|
return createEventSubscriber(
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { getActiveClient } from '~/client/api/activeClient';
|
|
2
|
+
import { createEventSubscriber } from '~/core/events';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Internal used only
|
|
6
|
+
*
|
|
7
|
+
* Fired when an {@link Amity.userMessageFeedMarkers} has been resolved by Object Rsesolver
|
|
8
|
+
*
|
|
9
|
+
* @param callback The function to call when the event was fired
|
|
10
|
+
* @returns an {@link Amity.Unsubscriber} function to stop listening
|
|
11
|
+
*
|
|
12
|
+
* @category MessageMarker Events
|
|
13
|
+
*/
|
|
14
|
+
export const onSubChannelUnreadUpdatedLocal = (
|
|
15
|
+
callback: Amity.Listener<Amity.Events['local.subChannelUnread.updated']>,
|
|
16
|
+
): Amity.Unsubscriber => {
|
|
17
|
+
const client = getActiveClient();
|
|
18
|
+
|
|
19
|
+
const filter = (payload: Amity.Events['local.subChannelUnread.updated']) => {
|
|
20
|
+
callback(payload);
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
return createEventSubscriber(
|
|
24
|
+
client,
|
|
25
|
+
'subChannelMarker/onSubChannelUnreadUpdatedLocal',
|
|
26
|
+
'local.subChannelUnread.updated',
|
|
27
|
+
filter,
|
|
28
|
+
);
|
|
29
|
+
};
|
|
@@ -23,10 +23,9 @@ export const onUserFeedMarkerUpdated = (
|
|
|
23
23
|
const client = getActiveClient();
|
|
24
24
|
|
|
25
25
|
const filter = (payload: Amity.Events['marker.userFeed-updated']) => {
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
callback(payload.feedMarkers[0]);
|
|
26
|
+
payload.feedMarkers.forEach(feedMarker => {
|
|
27
|
+
callback(feedMarker);
|
|
28
|
+
});
|
|
30
29
|
};
|
|
31
30
|
|
|
32
31
|
return createEventSubscriber(
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { pushToCache, queryCache } from '~/cache/api';
|
|
2
2
|
import { pullFromCache } from '~/cache/api/pullFromCache';
|
|
3
3
|
|
|
4
|
-
export const reCalculateChannelUnreadInfo =
|
|
4
|
+
export const reCalculateChannelUnreadInfo = (channelId: string): Amity.ChannelUnreadInfo => {
|
|
5
5
|
const cacheKeyChannelUnread = ['channelUnreadInfo', 'get', channelId];
|
|
6
6
|
const cacheChannelUnreadInfo =
|
|
7
7
|
pullFromCache<Amity.ChannelUnreadInfo>(cacheKeyChannelUnread)?.data;
|
|
@@ -25,7 +25,7 @@ export const reCalculateChannelUnreadInfo = async (channelId: string) => {
|
|
|
25
25
|
isMentioned = subChannelUnreadsInfo.some(({ data }) => data.isMentioned);
|
|
26
26
|
}
|
|
27
27
|
|
|
28
|
-
|
|
28
|
+
const channelUnreadInfo = {
|
|
29
29
|
...(cacheChannelUnreadInfo ?? {
|
|
30
30
|
channelId,
|
|
31
31
|
createdAt: new Date().toISOString(),
|
|
@@ -33,5 +33,9 @@ export const reCalculateChannelUnreadInfo = async (channelId: string) => {
|
|
|
33
33
|
updatedAt: new Date().toISOString(),
|
|
34
34
|
unreadCount: channelUnreads,
|
|
35
35
|
isMentioned,
|
|
36
|
-
}
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
pushToCache(cacheKeyChannelUnread, channelUnreadInfo);
|
|
39
|
+
|
|
40
|
+
return channelUnreadInfo;
|
|
37
41
|
};
|
|
@@ -49,7 +49,7 @@ export class MessageLiveCollectionController extends LiveCollectionController<
|
|
|
49
49
|
);
|
|
50
50
|
|
|
51
51
|
this.callback = callback.bind(this);
|
|
52
|
-
this.loadPage(true);
|
|
52
|
+
this.loadPage({ initial: true });
|
|
53
53
|
}
|
|
54
54
|
|
|
55
55
|
protected setup() {
|
|
@@ -107,8 +107,8 @@ export class MessageLiveCollectionController extends LiveCollectionController<
|
|
|
107
107
|
if (!this.shouldNotify(data) && origin === 'event') return;
|
|
108
108
|
|
|
109
109
|
this.callback({
|
|
110
|
-
onNextPage: () => this.loadPage(
|
|
111
|
-
onPrevPage: () => this.loadPage(
|
|
110
|
+
onNextPage: () => this.loadPage({ direction: Amity.LiveCollectionPageDirection.NEXT }),
|
|
111
|
+
onPrevPage: () => this.loadPage({ direction: Amity.LiveCollectionPageDirection.PREV }),
|
|
112
112
|
data,
|
|
113
113
|
hasNextPage: !!this.paginationController.getNextToken(),
|
|
114
114
|
hasPrevPage: !!this.paginationController.getPrevToken(),
|
|
@@ -47,7 +47,7 @@ export const editPost = async <T extends Amity.PostContentType>(
|
|
|
47
47
|
const cachedAt = client.cache && Date.now();
|
|
48
48
|
if (client.cache) ingestInCache(data, { cachedAt });
|
|
49
49
|
|
|
50
|
-
fireEvent('post.updated', data);
|
|
50
|
+
fireEvent('local.post.updated', data);
|
|
51
51
|
|
|
52
52
|
const { posts } = data;
|
|
53
53
|
|
|
@@ -51,7 +51,7 @@ export const updatePost = async <T extends Amity.PostContentType>(
|
|
|
51
51
|
const cachedAt = client.cache && Date.now();
|
|
52
52
|
if (client.cache) ingestInCache(data, { cachedAt });
|
|
53
53
|
|
|
54
|
-
fireEvent('post.updated', data);
|
|
54
|
+
fireEvent('local.post.updated', data);
|
|
55
55
|
|
|
56
56
|
const { posts } = data;
|
|
57
57
|
|
|
@@ -13,6 +13,8 @@ import {
|
|
|
13
13
|
} from '../events';
|
|
14
14
|
import { pullFromCache, pushToCache } from '~/cache/api';
|
|
15
15
|
import { LinkedObject } from '~/utils/linkedObject';
|
|
16
|
+
import { onCommentCreated, onCommentDeleted } from '~/commentRepository';
|
|
17
|
+
import { convertEventPayload } from '~/utils/event';
|
|
16
18
|
|
|
17
19
|
/* begin_public_function
|
|
18
20
|
id: post.get
|
|
@@ -80,6 +82,30 @@ export const getPost = (
|
|
|
80
82
|
},
|
|
81
83
|
onPostUnflagged,
|
|
82
84
|
onPostUpdated,
|
|
85
|
+
convertEventPayload(
|
|
86
|
+
(callback: Amity.Listener<Amity.InternalComment>) => {
|
|
87
|
+
return onCommentCreated(async (comment: Amity.InternalComment) => {
|
|
88
|
+
if (comment.referenceId === postId) {
|
|
89
|
+
await _getPost(postId);
|
|
90
|
+
callback(comment);
|
|
91
|
+
}
|
|
92
|
+
});
|
|
93
|
+
},
|
|
94
|
+
'referenceId',
|
|
95
|
+
'post',
|
|
96
|
+
),
|
|
97
|
+
convertEventPayload(
|
|
98
|
+
(callback: Amity.Listener<Amity.InternalComment>) => {
|
|
99
|
+
return onCommentDeleted(async (comment: Amity.InternalComment) => {
|
|
100
|
+
if (comment.referenceId === postId) {
|
|
101
|
+
await _getPost(postId);
|
|
102
|
+
callback(comment);
|
|
103
|
+
}
|
|
104
|
+
});
|
|
105
|
+
},
|
|
106
|
+
'referenceId',
|
|
107
|
+
'post',
|
|
108
|
+
),
|
|
83
109
|
]);
|
|
84
110
|
};
|
|
85
111
|
/* end_public_function */
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
import { getResolver } from '~/core/model';
|
|
3
3
|
import { getActiveClient } from '~/client/api';
|
|
4
4
|
import { dropFromCache, pullFromCache, pushToCache } from '~/cache/api';
|
|
5
|
+
import { getPost as _getPost } from '../api/getPost';
|
|
5
6
|
|
|
6
7
|
import {
|
|
7
8
|
createQuery,
|
|
@@ -34,6 +35,8 @@ import {
|
|
|
34
35
|
onPostUpdated,
|
|
35
36
|
} from '../events';
|
|
36
37
|
import { queryPosts } from '../api/queryPosts';
|
|
38
|
+
import { convertEventPayload } from '~/utils/event';
|
|
39
|
+
import { onCommentCreated, onCommentDeleted } from '~/commentRepository';
|
|
37
40
|
|
|
38
41
|
/* begin_public_function
|
|
39
42
|
id: post.query
|
|
@@ -204,6 +207,34 @@ export const getPosts = (
|
|
|
204
207
|
onPostUnflagged(realtimeRouter('onUnflagged')),
|
|
205
208
|
onPostReactionAdded(realtimeRouter('onReactionAdded')),
|
|
206
209
|
onPostReactionRemoved(realtimeRouter('onReactionRemoved')),
|
|
210
|
+
convertEventPayload(
|
|
211
|
+
(callback: Amity.Listener<Amity.InternalComment>) => {
|
|
212
|
+
return onCommentCreated(async (comment: Amity.InternalComment) => {
|
|
213
|
+
const currentCollection = pullFromCache<Amity.PostLiveCollectionCache>(cacheKey)?.data;
|
|
214
|
+
|
|
215
|
+
if (!currentCollection || currentCollection.data.includes(comment.referenceId)) return;
|
|
216
|
+
|
|
217
|
+
await _getPost(comment.referenceId);
|
|
218
|
+
callback(comment);
|
|
219
|
+
});
|
|
220
|
+
},
|
|
221
|
+
'referenceId',
|
|
222
|
+
'post',
|
|
223
|
+
)(realtimeRouter('onUpdate')),
|
|
224
|
+
convertEventPayload(
|
|
225
|
+
(callback: Amity.Listener<Amity.InternalComment>) => {
|
|
226
|
+
return onCommentDeleted(async (comment: Amity.InternalComment) => {
|
|
227
|
+
const currentCollection = pullFromCache<Amity.PostLiveCollectionCache>(cacheKey)?.data;
|
|
228
|
+
|
|
229
|
+
if (!currentCollection || currentCollection.data.includes(comment.referenceId)) return;
|
|
230
|
+
|
|
231
|
+
await _getPost(comment.referenceId);
|
|
232
|
+
callback(comment);
|
|
233
|
+
});
|
|
234
|
+
},
|
|
235
|
+
'referenceId',
|
|
236
|
+
'post',
|
|
237
|
+
)(realtimeRouter('onUpdate')),
|
|
207
238
|
);
|
|
208
239
|
|
|
209
240
|
onFetch(true);
|
package/src/storyRepository/observers/getGlobalStoryTargets/GlobalStoryLiveCollectionController.ts
CHANGED
|
@@ -48,7 +48,7 @@ export class GlobalStoryLiveCollectionController extends LiveCollectionControlle
|
|
|
48
48
|
|
|
49
49
|
this.paginationController = paginationController;
|
|
50
50
|
this.callback = callback.bind(this);
|
|
51
|
-
this.loadPage(true);
|
|
51
|
+
this.loadPage({ initial: true });
|
|
52
52
|
}
|
|
53
53
|
|
|
54
54
|
protected setup() {
|
|
@@ -94,7 +94,7 @@ export class GlobalStoryLiveCollectionController extends LiveCollectionControlle
|
|
|
94
94
|
) as Amity.StoryTarget[];
|
|
95
95
|
|
|
96
96
|
this.callback({
|
|
97
|
-
onNextPage: () => this.loadPage(
|
|
97
|
+
onNextPage: () => this.loadPage({ direction: Amity.LiveCollectionPageDirection.NEXT }),
|
|
98
98
|
data,
|
|
99
99
|
hasNextPage: !!this.paginationController.getNextToken(),
|
|
100
100
|
loading,
|
package/src/storyRepository/observers/getStoriesByTargetIds/StoryLiveCollectionController.ts
CHANGED
|
@@ -42,7 +42,7 @@ export class StoryLiveCollectionController extends LiveCollectionController<
|
|
|
42
42
|
|
|
43
43
|
this.paginationController = paginationController;
|
|
44
44
|
this.callback = callback.bind(this);
|
|
45
|
-
this.loadPage(true);
|
|
45
|
+
this.loadPage({ initial: true });
|
|
46
46
|
}
|
|
47
47
|
|
|
48
48
|
protected setup() {
|
|
@@ -8,7 +8,7 @@ import { ingestInCache } from '~/cache/api/ingestInCache';
|
|
|
8
8
|
*/
|
|
9
9
|
/**
|
|
10
10
|
* ```js
|
|
11
|
-
* import { getStreams } from '@amityco/ts-sdk
|
|
11
|
+
* import { getStreams } from '@amityco/ts-sdk'
|
|
12
12
|
* const streams = await getStreams()
|
|
13
13
|
* ```
|
|
14
14
|
*
|
|
@@ -62,7 +62,7 @@ export const getStreams = async (query?: {
|
|
|
62
62
|
|
|
63
63
|
/**
|
|
64
64
|
* ```js
|
|
65
|
-
* import { getStreams } from '@amityco/ts-sdk
|
|
65
|
+
* import { getStreams } from '@amityco/ts-sdk'
|
|
66
66
|
* const streams = getStreams.locally()
|
|
67
67
|
* ```
|
|
68
68
|
*
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { getActiveClient } from '~/client/api';
|
|
2
|
+
import { createEventSubscriber } from '~/core/events';
|
|
3
|
+
|
|
4
|
+
import { ingestInCache } from '~/cache/api/ingestInCache';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* ```js
|
|
8
|
+
* import { onStreamFlagged } from '@amityco/ts-sdk-react-native'
|
|
9
|
+
* const dispose = onStreamFlagged(stream => {
|
|
10
|
+
* // ...
|
|
11
|
+
* })
|
|
12
|
+
* ```
|
|
13
|
+
*
|
|
14
|
+
* Fired when a {@link Amity.InternalStream} has started airing
|
|
15
|
+
*
|
|
16
|
+
* @param callback The function to call when the event was fired
|
|
17
|
+
* @returns an {@link Amity.Unsubscriber} function to stop listening
|
|
18
|
+
*
|
|
19
|
+
* @category Stream Events
|
|
20
|
+
*/
|
|
21
|
+
export const onStreamFlagged = (
|
|
22
|
+
callback: Amity.Listener<Amity.InternalStream>,
|
|
23
|
+
): Amity.Unsubscriber => {
|
|
24
|
+
const client = getActiveClient();
|
|
25
|
+
|
|
26
|
+
const filter = (payload: Amity.StreamPayload) => {
|
|
27
|
+
ingestInCache(payload);
|
|
28
|
+
callback(payload.videoStreamings[0]);
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
return createEventSubscriber(
|
|
32
|
+
client,
|
|
33
|
+
'stream/onStreamFlagged',
|
|
34
|
+
'v3.video-streaming.didFlag',
|
|
35
|
+
filter,
|
|
36
|
+
);
|
|
37
|
+
};
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { getActiveClient } from '~/client/api';
|
|
2
|
+
import { createEventSubscriber } from '~/core/events';
|
|
3
|
+
|
|
4
|
+
import { ingestInCache } from '~/cache/api/ingestInCache';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* ```js
|
|
8
|
+
* import { onStreamTerminated } from '@amityco/ts-sdk-react-native'
|
|
9
|
+
* const dispose = onStreamTerminated(stream => {
|
|
10
|
+
* // ...
|
|
11
|
+
* })
|
|
12
|
+
* ```
|
|
13
|
+
*
|
|
14
|
+
* Fired when a {@link Amity.InternalStream} has started airing
|
|
15
|
+
*
|
|
16
|
+
* @param callback The function to call when the event was fired
|
|
17
|
+
* @returns an {@link Amity.Unsubscriber} function to stop listening
|
|
18
|
+
*
|
|
19
|
+
* @category Stream Events
|
|
20
|
+
*/
|
|
21
|
+
export const onStreamTerminated = (
|
|
22
|
+
callback: Amity.Listener<Amity.InternalStream>,
|
|
23
|
+
): Amity.Unsubscriber => {
|
|
24
|
+
const client = getActiveClient();
|
|
25
|
+
|
|
26
|
+
const filter = (payload: Amity.StreamPayload) => {
|
|
27
|
+
ingestInCache(payload);
|
|
28
|
+
callback(payload.videoStreamings[0]);
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
return createEventSubscriber(
|
|
32
|
+
client,
|
|
33
|
+
'stream/onStreamTerminated',
|
|
34
|
+
'v3.video-streaming.didTerminate',
|
|
35
|
+
filter,
|
|
36
|
+
);
|
|
37
|
+
};
|
|
@@ -26,7 +26,7 @@ import { onStreamRecorded, onStreamStarted, onStreamStopped } from '../events';
|
|
|
26
26
|
*/
|
|
27
27
|
/**
|
|
28
28
|
* ```js
|
|
29
|
-
* import { StreamRepository } from '@amityco/ts-sdk
|
|
29
|
+
* import { StreamRepository } from '@amityco/ts-sdk'
|
|
30
30
|
* const streams = await StreamRepository.getStreams()
|
|
31
31
|
* ```
|
|
32
32
|
*
|
|
@@ -20,7 +20,7 @@ import { getActiveClient } from '~/client';
|
|
|
20
20
|
import { getSubChannelMessagePreviewWithUser } from '~/messagePreview/utils';
|
|
21
21
|
import { isEqual } from '~/utils/isEqual';
|
|
22
22
|
import { updateSubChannelCache } from '../utils/updateSubChannelCache';
|
|
23
|
-
import {
|
|
23
|
+
import { onSubChannelUnreadUpdatedLocal } from '~/marker/events/onSubChannelUnreadUpdatedLocal';
|
|
24
24
|
|
|
25
25
|
/* begin_public_function
|
|
26
26
|
id: subchannel.get
|
|
@@ -221,7 +221,7 @@ export const getSubChannel = (
|
|
|
221
221
|
'subChannelId',
|
|
222
222
|
'subChannel',
|
|
223
223
|
),
|
|
224
|
-
convertEventPayload(
|
|
224
|
+
convertEventPayload(onSubChannelUnreadUpdatedLocal, 'subChannelId', 'subChannel'),
|
|
225
225
|
],
|
|
226
226
|
{
|
|
227
227
|
forceDispatch: true,
|
package/src/subChannelRepository/observers/getSubChannels/SubChannelLiveCollectionController.ts
CHANGED
|
@@ -29,7 +29,7 @@ import { getSubChannel } from '~/subChannelRepository/api/getSubChannel';
|
|
|
29
29
|
import { updateSubChannelCache } from '~/subChannelRepository/utils/updateSubChannelCache';
|
|
30
30
|
import { prepareSubChannelPayload } from '~/subChannelRepository/utils';
|
|
31
31
|
import { onSubChannelFetched } from '~/subChannelRepository/events/onSubChannelFetched';
|
|
32
|
-
import {
|
|
32
|
+
import { onSubChannelUnreadUpdatedLocal } from '~/marker/events/onSubChannelUnreadUpdatedLocal';
|
|
33
33
|
|
|
34
34
|
export class SubChannelLiveCollectionController extends LiveCollectionController<
|
|
35
35
|
'subChannel',
|
|
@@ -59,7 +59,7 @@ export class SubChannelLiveCollectionController extends LiveCollectionController
|
|
|
59
59
|
prepareSubChannelPayload,
|
|
60
60
|
);
|
|
61
61
|
this.callback = callback.bind(this);
|
|
62
|
-
this.loadPage(true);
|
|
62
|
+
this.loadPage({ initial: true });
|
|
63
63
|
}
|
|
64
64
|
|
|
65
65
|
protected setup() {
|
|
@@ -294,7 +294,7 @@ export class SubChannelLiveCollectionController extends LiveCollectionController
|
|
|
294
294
|
action: 'onUpdate',
|
|
295
295
|
},
|
|
296
296
|
{
|
|
297
|
-
fn: convertEventPayload(
|
|
297
|
+
fn: convertEventPayload(onSubChannelUnreadUpdatedLocal, 'subChannelId', 'subChannel'),
|
|
298
298
|
action: 'onUpdate',
|
|
299
299
|
},
|
|
300
300
|
]);
|
|
@@ -315,7 +315,7 @@ export class SubChannelLiveCollectionController extends LiveCollectionController
|
|
|
315
315
|
if (!this.shouldNotify(data) && origin === 'event') return;
|
|
316
316
|
|
|
317
317
|
this.callback({
|
|
318
|
-
onNextPage: () => this.loadPage(
|
|
318
|
+
onNextPage: () => this.loadPage({ direction: Amity.LiveCollectionPageDirection.NEXT }),
|
|
319
319
|
data,
|
|
320
320
|
hasNextPage: !!this.paginationController.getNextToken(),
|
|
321
321
|
loading,
|
package/src/utils/liveObject.ts
CHANGED