@amityco/ts-sdk-react-native 6.7.1-e8866e9.0 → 6.8.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/README.md +1 -1
- 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/content.d.ts +1 -0
- package/dist/@types/domains/content.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.map +1 -1
- 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 +2409 -18306
- package/dist/index.esm.js +351 -143
- 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/onMessageMarked.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/messageRepository/events/onMessageCreated.d.ts.map +1 -1
- package/dist/messageRepository/observers/getMessages.d.ts.map +1 -1
- package/dist/messageRepository/utils/prepareMessagePayload.d.ts +1 -1
- package/dist/messageRepository/utils/prepareMessagePayload.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/observers/getSubChannels.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/object.d.ts +1 -1
- package/dist/utils/object.d.ts.map +1 -1
- 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 +5 -2
- 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/content.ts +1 -0
- 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 +12 -16
- package/src/client/utils/onOnline.ts +2 -1
- 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/onMessageMarked.ts +37 -0
- 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/messageRepository/events/onMessageCreated.ts +1 -9
- package/src/messageRepository/observers/getMessages.ts +10 -6
- package/src/messageRepository/utils/prepareMessagePayload.ts +16 -1
- 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/events/onSubChannelUpdated.ts +1 -1
- package/src/subChannelRepository/observers/getSubChannels.ts +18 -1
- package/src/subChannelRepository/utils/getSubChannelHasMentioned.ts +34 -0
- package/src/subChannelRepository/utils/markReadEngine.ts +13 -6
- 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/object.ts +3 -2
- 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/src/utils/tests/dummy/message.ts +1 -1
|
@@ -17,7 +17,7 @@ import { synchronousWSCall } from '~/core/transports';
|
|
|
17
17
|
* @async
|
|
18
18
|
* */
|
|
19
19
|
export const isCommentFlaggedByMe = async (
|
|
20
|
-
commentId: Amity.
|
|
20
|
+
commentId: Amity.InternalComment['commentId'],
|
|
21
21
|
): Promise<boolean> => {
|
|
22
22
|
const client = getActiveClient();
|
|
23
23
|
client.log('comment/isCommentFlaggedByMe', commentId);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { getActiveClient } from '~/client/api';
|
|
2
2
|
|
|
3
3
|
import { toPage, toToken } from '~/core/query';
|
|
4
|
-
import {
|
|
4
|
+
import { pushToCache } from '~/cache/api';
|
|
5
5
|
import { ingestInCache } from '~/cache/api/ingestInCache';
|
|
6
6
|
import { getResolver } from '~/core/model';
|
|
7
7
|
|
|
@@ -13,17 +13,17 @@ import { inferIsDeleted } from '~/utils/inferIsDeleted';
|
|
|
13
13
|
* const comments = await CommentRepository.queryComments({ referenceType: 'post', referenceId: 'foo' })
|
|
14
14
|
* ```
|
|
15
15
|
*
|
|
16
|
-
* Queries a paginable list of {@link Amity.
|
|
16
|
+
* Queries a paginable list of {@link Amity.InternalComment} objects
|
|
17
17
|
*
|
|
18
18
|
* @param query The query parameters
|
|
19
|
-
* @returns A page of {@link Amity.
|
|
19
|
+
* @returns A page of {@link Amity.InternalComment} objects
|
|
20
20
|
*
|
|
21
21
|
* @category Comment API
|
|
22
22
|
* @async
|
|
23
23
|
*/
|
|
24
24
|
export const queryComments = async (
|
|
25
25
|
query: Amity.QueryComments,
|
|
26
|
-
): Promise<Amity.Cached<Amity.Paged<Amity.
|
|
26
|
+
): Promise<Amity.Cached<Amity.Paged<Amity.InternalComment>>> => {
|
|
27
27
|
const client = getActiveClient();
|
|
28
28
|
client.log('comment/queryComments', query);
|
|
29
29
|
|
|
@@ -11,17 +11,17 @@ import { deleteComment } from './deleteComment';
|
|
|
11
11
|
* const success = await CommentRepository.softDeleteComment('foobar')
|
|
12
12
|
* ```
|
|
13
13
|
*
|
|
14
|
-
* Deletes a {@link Amity.
|
|
14
|
+
* Deletes a {@link Amity.InternalComment}
|
|
15
15
|
*
|
|
16
|
-
* @param commentId The {@link Amity.
|
|
17
|
-
* @return A success boolean if the {@link Amity.
|
|
16
|
+
* @param commentId The {@link Amity.InternalComment} ID to delete
|
|
17
|
+
* @return A success boolean if the {@link Amity.InternalComment} was deleted
|
|
18
18
|
*
|
|
19
19
|
* @category Comment API
|
|
20
20
|
* @async
|
|
21
21
|
*/
|
|
22
22
|
export const softDeleteComment = async (
|
|
23
|
-
commentId: Amity.
|
|
24
|
-
): Promise<Amity.
|
|
23
|
+
commentId: Amity.InternalComment['commentId'],
|
|
24
|
+
): Promise<Amity.InternalComment> => {
|
|
25
25
|
const client = getActiveClient();
|
|
26
26
|
client.log('comment/softDeleteComment', commentId);
|
|
27
27
|
|
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
import {
|
|
2
2
|
client,
|
|
3
|
+
comment12,
|
|
4
|
+
comment12Payload,
|
|
3
5
|
connectClient,
|
|
6
|
+
deletedCommentPayload,
|
|
7
|
+
deletedCommentResponse,
|
|
4
8
|
disconnectClient,
|
|
5
|
-
textCommentPayload,
|
|
6
9
|
imageCommentPayload,
|
|
7
|
-
post11,
|
|
8
|
-
textCommentResponse,
|
|
9
10
|
imageCommentResponse,
|
|
11
|
+
post11,
|
|
10
12
|
textAndImageCommentMixedPayload,
|
|
13
|
+
textCommentPayload,
|
|
11
14
|
textCommentRequestPayload,
|
|
12
|
-
|
|
13
|
-
comment12Payload,
|
|
14
|
-
deletedCommentPayload,
|
|
15
|
-
deletedCommentResponse,
|
|
15
|
+
textCommentResponse,
|
|
16
16
|
} from '~/utils/tests';
|
|
17
17
|
import { ASCApiError } from '~/core/errors';
|
|
18
18
|
|
|
@@ -20,7 +20,7 @@ import { queryComments } from '../queryComments';
|
|
|
20
20
|
|
|
21
21
|
type mockParamAndResponse = {
|
|
22
22
|
query: Amity.QueryComments;
|
|
23
|
-
response: Amity.
|
|
23
|
+
response: Amity.InternalComment[];
|
|
24
24
|
};
|
|
25
25
|
|
|
26
26
|
const queryParams: mockParamAndResponse = {
|
|
@@ -73,7 +73,7 @@ describe('queryComments', () => {
|
|
|
73
73
|
beforeAll(connectClient);
|
|
74
74
|
afterAll(disconnectClient);
|
|
75
75
|
|
|
76
|
-
const testCase: [string, object, Amity.QueryComments, Amity.
|
|
76
|
+
const testCase: [string, object, Amity.QueryComments, Amity.InternalComment[]][] = [
|
|
77
77
|
[
|
|
78
78
|
// integration_test_id: 0be48975-be6d-4199-bec0-af186af444d3
|
|
79
79
|
'Should return valid comment when user query with valid query',
|
|
@@ -19,7 +19,9 @@ import { fireEvent } from '~/core/events';
|
|
|
19
19
|
* @category Comment API
|
|
20
20
|
* @async
|
|
21
21
|
* */
|
|
22
|
-
export const unflagComment = async (
|
|
22
|
+
export const unflagComment = async (
|
|
23
|
+
commentId: Amity.InternalComment['commentId'],
|
|
24
|
+
): Promise<boolean> => {
|
|
23
25
|
const client = getActiveClient();
|
|
24
26
|
client.log('comment/unflagComment', commentId);
|
|
25
27
|
|
|
@@ -14,19 +14,19 @@ import { fireEvent } from '~/core/events';
|
|
|
14
14
|
* })
|
|
15
15
|
* ```
|
|
16
16
|
*
|
|
17
|
-
* Updates an {@link Amity.
|
|
17
|
+
* Updates an {@link Amity.InternalComment}
|
|
18
18
|
*
|
|
19
|
-
* @param commentId The ID of the {@link Amity.
|
|
19
|
+
* @param commentId The ID of the {@link Amity.InternalComment} to edit
|
|
20
20
|
* @param patch The patch data to apply
|
|
21
|
-
* @returns the updated {@link Amity.
|
|
21
|
+
* @returns the updated {@link Amity.InternalComment} object
|
|
22
22
|
*
|
|
23
23
|
* @category Comment API
|
|
24
24
|
* @async
|
|
25
25
|
*/
|
|
26
26
|
export const updateComment = async (
|
|
27
|
-
commentId: Amity.
|
|
28
|
-
patch: Patch<Amity.
|
|
29
|
-
): Promise<Amity.Cached<Amity.
|
|
27
|
+
commentId: Amity.InternalComment['commentId'],
|
|
28
|
+
patch: Patch<Amity.InternalComment, 'data' | 'metadata' | 'mentionees'>,
|
|
29
|
+
): Promise<Amity.Cached<Amity.InternalComment>> => {
|
|
30
30
|
const client = getActiveClient();
|
|
31
31
|
client.log('user/updateComment', patch);
|
|
32
32
|
|
|
@@ -8,12 +8,13 @@ import { createCommentEventSubscriber } from './utils';
|
|
|
8
8
|
* })
|
|
9
9
|
* ```
|
|
10
10
|
*
|
|
11
|
-
* Fired when a {@link Amity.
|
|
11
|
+
* Fired when a {@link Amity.InternalComment} has been created
|
|
12
12
|
*
|
|
13
13
|
* @param callback The function to call when the event was fired
|
|
14
14
|
* @returns an {@link Amity.Unsubscriber} function to stop listening
|
|
15
15
|
*
|
|
16
|
-
* @category
|
|
16
|
+
* @category InternalComment Events
|
|
17
17
|
*/
|
|
18
|
-
export const onCommentCreated = (
|
|
19
|
-
|
|
18
|
+
export const onCommentCreated = (
|
|
19
|
+
callback: Amity.Listener<Amity.InternalComment>,
|
|
20
|
+
): Amity.Unsubscriber => createCommentEventSubscriber('comment.created', callback);
|
|
@@ -8,12 +8,13 @@ import { createCommentEventSubscriber } from './utils';
|
|
|
8
8
|
* })
|
|
9
9
|
* ```
|
|
10
10
|
*
|
|
11
|
-
* Fired when a {@link Amity.
|
|
11
|
+
* Fired when a {@link Amity.InternalComment} has been deleted
|
|
12
12
|
*
|
|
13
13
|
* @param callback The function to call when the event was fired
|
|
14
14
|
* @returns an {@link Amity.Unsubscriber} function to stop listening
|
|
15
15
|
*
|
|
16
|
-
* @category
|
|
16
|
+
* @category InternalComment Events
|
|
17
17
|
*/
|
|
18
|
-
export const onCommentDeleted = (
|
|
19
|
-
|
|
18
|
+
export const onCommentDeleted = (
|
|
19
|
+
callback: Amity.Listener<Amity.InternalComment>,
|
|
20
|
+
): Amity.Unsubscriber => createCommentEventSubscriber('comment.deleted', callback);
|
|
@@ -8,12 +8,13 @@ import { createCommentEventSubscriber } from './utils';
|
|
|
8
8
|
* })
|
|
9
9
|
* ```
|
|
10
10
|
*
|
|
11
|
-
* Fired when a {@link Amity.
|
|
11
|
+
* Fired when a {@link Amity.InternalComment} has been flagged
|
|
12
12
|
*
|
|
13
13
|
* @param callback The function to call when the event was fired
|
|
14
14
|
* @returns an {@link Amity.Unsubscriber} function to stop listening
|
|
15
15
|
*
|
|
16
|
-
* @category
|
|
16
|
+
* @category InternalComment Events
|
|
17
17
|
*/
|
|
18
|
-
export const onCommentFlagged = (
|
|
19
|
-
|
|
18
|
+
export const onCommentFlagged = (
|
|
19
|
+
callback: Amity.Listener<Amity.InternalComment>,
|
|
20
|
+
): Amity.Unsubscriber => createCommentEventSubscriber('comment.flagged', callback);
|
|
@@ -12,15 +12,15 @@ import { prepareReactionPayloadFormEvent } from '~/reactionRepository/utils';
|
|
|
12
12
|
* })
|
|
13
13
|
* ```
|
|
14
14
|
*
|
|
15
|
-
* Fired when a {@link Amity.
|
|
15
|
+
* Fired when a {@link Amity.InternalComment} has been reacted
|
|
16
16
|
*
|
|
17
17
|
* @param callback The function to call when the event was fired
|
|
18
18
|
* @returns an {@link Amity.Unsubscriber} function to stop listening
|
|
19
19
|
*
|
|
20
|
-
* @category
|
|
20
|
+
* @category InternalComment Events
|
|
21
21
|
*/
|
|
22
22
|
export const onCommentReactionAdded = (
|
|
23
|
-
callback: Amity.Listener<Amity.
|
|
23
|
+
callback: Amity.Listener<Amity.InternalComment>,
|
|
24
24
|
): Amity.Unsubscriber => {
|
|
25
25
|
const client = getActiveClient();
|
|
26
26
|
|
|
@@ -33,7 +33,7 @@ export const onCommentReactionAdded = (
|
|
|
33
33
|
|
|
34
34
|
ingestInCache(commentPayload as Amity.CommentPayload);
|
|
35
35
|
|
|
36
|
-
const comment = pullFromCache<Amity.
|
|
36
|
+
const comment = pullFromCache<Amity.InternalComment>([
|
|
37
37
|
'comment',
|
|
38
38
|
'get',
|
|
39
39
|
payload.comments[0].commentId,
|
|
@@ -12,15 +12,15 @@ import { prepareReactionPayloadFormEvent } from '~/reactionRepository/utils';
|
|
|
12
12
|
* })
|
|
13
13
|
* ```
|
|
14
14
|
*
|
|
15
|
-
* Fired when a reaction has been removed from a {@link Amity.
|
|
15
|
+
* Fired when a reaction has been removed from a {@link Amity.InternalComment}
|
|
16
16
|
*
|
|
17
17
|
* @param callback The function to call when the event was fired
|
|
18
18
|
* @returns an {@link Amity.Unsubscriber} function to stop listening
|
|
19
19
|
*
|
|
20
|
-
* @category
|
|
20
|
+
* @category InternalComment Events
|
|
21
21
|
*/
|
|
22
22
|
export const onCommentReactionRemoved = (
|
|
23
|
-
callback: Amity.Listener<Amity.
|
|
23
|
+
callback: Amity.Listener<Amity.InternalComment>,
|
|
24
24
|
): Amity.Unsubscriber => {
|
|
25
25
|
const client = getActiveClient();
|
|
26
26
|
|
|
@@ -33,7 +33,7 @@ export const onCommentReactionRemoved = (
|
|
|
33
33
|
|
|
34
34
|
ingestInCache(commentPayload as Amity.CommentPayload);
|
|
35
35
|
|
|
36
|
-
const comment = pullFromCache<Amity.
|
|
36
|
+
const comment = pullFromCache<Amity.InternalComment>([
|
|
37
37
|
'comment',
|
|
38
38
|
'get',
|
|
39
39
|
payload.comments[0].commentId,
|
|
@@ -8,12 +8,13 @@ import { createCommentEventSubscriber } from './utils';
|
|
|
8
8
|
* })
|
|
9
9
|
* ```
|
|
10
10
|
*
|
|
11
|
-
* Fired when a flag has been removed from a {@link Amity.
|
|
11
|
+
* Fired when a flag has been removed from a {@link Amity.InternalComment}
|
|
12
12
|
*
|
|
13
13
|
* @param callback The function to call when the event was fired
|
|
14
14
|
* @returns an {@link Amity.Unsubscriber} function to stop listening
|
|
15
15
|
*
|
|
16
|
-
* @category
|
|
16
|
+
* @category InternalComment Events
|
|
17
17
|
*/
|
|
18
|
-
export const onCommentUnflagged = (
|
|
19
|
-
|
|
18
|
+
export const onCommentUnflagged = (
|
|
19
|
+
callback: Amity.Listener<Amity.InternalComment>,
|
|
20
|
+
): Amity.Unsubscriber => createCommentEventSubscriber('comment.unflagged', callback);
|
|
@@ -8,12 +8,13 @@ import { createCommentEventSubscriber } from './utils';
|
|
|
8
8
|
* })
|
|
9
9
|
* ```
|
|
10
10
|
*
|
|
11
|
-
* Fired when a {@link Amity.
|
|
11
|
+
* Fired when a {@link Amity.InternalComment} has been updated
|
|
12
12
|
*
|
|
13
13
|
* @param callback The function to call when the event was fired
|
|
14
14
|
* @returns an {@link Amity.Unsubscriber} function to stop listening
|
|
15
15
|
*
|
|
16
|
-
* @category
|
|
16
|
+
* @category InternalComment Events
|
|
17
17
|
*/
|
|
18
|
-
export const onCommentUpdated = (
|
|
19
|
-
|
|
18
|
+
export const onCommentUpdated = (
|
|
19
|
+
callback: Amity.Listener<Amity.InternalComment>,
|
|
20
|
+
): Amity.Unsubscriber => createCommentEventSubscriber('comment.updated', callback);
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { getActiveClient } from '~/client/api';
|
|
2
2
|
import { createEventSubscriber } from '~/core/events';
|
|
3
|
-
import { queryCache, upsertInCache
|
|
3
|
+
import { pullFromCache, queryCache, upsertInCache } from '~/cache/api';
|
|
4
4
|
import { ingestInCache } from '~/cache/api/ingestInCache';
|
|
5
5
|
|
|
6
6
|
export const createCommentEventSubscriber = (
|
|
7
7
|
event: keyof Amity.MqttCommentEvents,
|
|
8
|
-
callback: Amity.Listener<Amity.
|
|
8
|
+
callback: Amity.Listener<Amity.InternalComment>,
|
|
9
9
|
) => {
|
|
10
10
|
const client = getActiveClient();
|
|
11
11
|
|
|
@@ -16,7 +16,7 @@ export const createCommentEventSubscriber = (
|
|
|
16
16
|
} else {
|
|
17
17
|
ingestInCache(payload);
|
|
18
18
|
|
|
19
|
-
const comment = pullFromCache<Amity.
|
|
19
|
+
const comment = pullFromCache<Amity.InternalComment>([
|
|
20
20
|
'comment',
|
|
21
21
|
'get',
|
|
22
22
|
payload.comments[0].commentId,
|
|
@@ -23,17 +23,17 @@ import {
|
|
|
23
23
|
* });
|
|
24
24
|
* ```
|
|
25
25
|
*
|
|
26
|
-
* Observe all mutation on a given {@link Amity.
|
|
26
|
+
* Observe all mutation on a given {@link Amity.InternalComment}
|
|
27
27
|
*
|
|
28
28
|
* @param commentId the ID of the comment to observe
|
|
29
29
|
* @param callback the function to call when new data are available
|
|
30
30
|
* @returns An {@link Amity.Unsubscriber} function to run when willing to stop observing the comment
|
|
31
31
|
*
|
|
32
|
-
* @category
|
|
32
|
+
* @category InternalComment Live Object
|
|
33
33
|
*/
|
|
34
34
|
export const getComment = (
|
|
35
|
-
commentId: Amity.
|
|
36
|
-
callback: Amity.LiveObjectCallback<Amity.
|
|
35
|
+
commentId: Amity.InternalComment['commentId'],
|
|
36
|
+
callback: Amity.LiveObjectCallback<Amity.InternalComment>,
|
|
37
37
|
): Amity.Unsubscriber => {
|
|
38
38
|
return liveObject(commentId, callback, 'commentId', _getComment, [
|
|
39
39
|
onCommentDeleted,
|
|
@@ -18,6 +18,7 @@ import {
|
|
|
18
18
|
} from '~/utils/constants';
|
|
19
19
|
|
|
20
20
|
import { CACHE_SHORTEN_LIFESPAN } from '~/cache/utils';
|
|
21
|
+
import { LinkedObject } from '~/utils/linkedObject';
|
|
21
22
|
import {
|
|
22
23
|
onCommentCreated,
|
|
23
24
|
onCommentDeleted,
|
|
@@ -38,12 +39,12 @@ import { queryComments } from '../api/queryComments';
|
|
|
38
39
|
*
|
|
39
40
|
* let comments = []
|
|
40
41
|
* const unsub = getComments({
|
|
41
|
-
* referenceType: Amity.
|
|
42
|
-
* referenceId: Amity.
|
|
42
|
+
* referenceType: Amity.InternalComment['referenceType'];
|
|
43
|
+
* referenceId: Amity.InternalComment['referenceId'];
|
|
43
44
|
* }, response => merge(comments, response.data))
|
|
44
45
|
* ```
|
|
45
46
|
*
|
|
46
|
-
* Observe all mutations on a list of {@link Amity.
|
|
47
|
+
* Observe all mutations on a list of {@link Amity.InternalComment} for a given target object
|
|
47
48
|
*
|
|
48
49
|
* @param referenceType the type of the target
|
|
49
50
|
* @param referenceId the ID of the target
|
|
@@ -54,7 +55,7 @@ import { queryComments } from '../api/queryComments';
|
|
|
54
55
|
*/
|
|
55
56
|
export const getComments = (
|
|
56
57
|
params: Amity.CommentLiveCollection,
|
|
57
|
-
callback: Amity.LiveCollectionCallback<Amity.
|
|
58
|
+
callback: Amity.LiveCollectionCallback<Amity.InternalComment>,
|
|
58
59
|
config?: Amity.LiveCollectionConfig,
|
|
59
60
|
): Amity.Unsubscriber => {
|
|
60
61
|
const { log, cache } = getActiveClient();
|
|
@@ -79,11 +80,11 @@ export const getComments = (
|
|
|
79
80
|
];
|
|
80
81
|
|
|
81
82
|
const responder = (data: Amity.CommentLiveCollectionCache) => {
|
|
82
|
-
let comments: Amity.
|
|
83
|
+
let comments: Amity.InternalComment[] =
|
|
83
84
|
data.data
|
|
84
|
-
.map(commentId => pullFromCache<Amity.
|
|
85
|
+
.map(commentId => pullFromCache<Amity.InternalComment>(['comment', 'get', commentId])!)
|
|
85
86
|
.filter(Boolean)
|
|
86
|
-
.map(({ data }) => data) ?? [];
|
|
87
|
+
.map(({ data }) => LinkedObject.comment(data)) ?? [];
|
|
87
88
|
|
|
88
89
|
if (!params.includeDeleted) {
|
|
89
90
|
comments = filterByPropEquality(comments, 'isDeleted', false);
|
|
@@ -102,7 +103,7 @@ export const getComments = (
|
|
|
102
103
|
});
|
|
103
104
|
};
|
|
104
105
|
|
|
105
|
-
const realtimeRouter = (action: Amity.CommentActionType) => (comment: Amity.
|
|
106
|
+
const realtimeRouter = (action: Amity.CommentActionType) => (comment: Amity.InternalComment) => {
|
|
106
107
|
const collection = pullFromCache<Amity.CommentLiveCollectionCache>(cacheKey)?.data;
|
|
107
108
|
|
|
108
109
|
if (
|
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
import { getActiveClient } from '~/client/api';
|
|
2
2
|
|
|
3
|
-
import { createQuery,
|
|
3
|
+
import { createQuery, queryOptions, runQuery } from '~/core/query';
|
|
4
4
|
|
|
5
5
|
import { getComment } from '../api/getComment';
|
|
6
6
|
|
|
7
7
|
import {
|
|
8
|
-
onCommentUpdated,
|
|
9
8
|
onCommentDeleted,
|
|
10
9
|
onCommentFlagged,
|
|
11
|
-
onCommentUnflagged,
|
|
12
10
|
onCommentReactionAdded,
|
|
13
11
|
onCommentReactionRemoved,
|
|
12
|
+
onCommentUnflagged,
|
|
13
|
+
onCommentUpdated,
|
|
14
14
|
} from '../events';
|
|
15
15
|
|
|
16
16
|
/**
|
|
@@ -21,13 +21,13 @@ import {
|
|
|
21
21
|
* const dispose = observeComment(commentId, ({ data }) => comment = data)
|
|
22
22
|
* ```
|
|
23
23
|
*
|
|
24
|
-
* Observe all mutation on a given {@link Amity.
|
|
24
|
+
* Observe all mutation on a given {@link Amity.InternalComment}
|
|
25
25
|
*
|
|
26
26
|
* @param commentId the ID of the comment to observe
|
|
27
27
|
* @param callback the function to call when new data are available
|
|
28
28
|
* @returns An {@link Amity.Unsubscriber} function to run when willing to stop observing the comment
|
|
29
29
|
*
|
|
30
|
-
* @category
|
|
30
|
+
* @category InternalComment Observer
|
|
31
31
|
*/
|
|
32
32
|
export const observeComment = <
|
|
33
33
|
Events extends [
|
|
@@ -41,7 +41,7 @@ export const observeComment = <
|
|
|
41
41
|
],
|
|
42
42
|
>(
|
|
43
43
|
commentId: string,
|
|
44
|
-
callback: Amity.ObjectListener<Amity.Snapshot<Amity.
|
|
44
|
+
callback: Amity.ObjectListener<Amity.Snapshot<Amity.InternalComment | undefined>, Events>,
|
|
45
45
|
policy: Amity.QueryPolicy = 'cache_then_server',
|
|
46
46
|
): Amity.Unsubscriber => {
|
|
47
47
|
const { log } = getActiveClient();
|
|
@@ -50,7 +50,10 @@ export const observeComment = <
|
|
|
50
50
|
log(`observeComment(tmpid: ${timestamp}) > listen`);
|
|
51
51
|
|
|
52
52
|
// wrapper function to make sure
|
|
53
|
-
const router = (
|
|
53
|
+
const router = (
|
|
54
|
+
result: Amity.Snapshot<Amity.InternalComment | undefined>,
|
|
55
|
+
action: Events[number],
|
|
56
|
+
) => {
|
|
54
57
|
if (callback instanceof Function) return callback(result);
|
|
55
58
|
|
|
56
59
|
if (action !== 'onFetch') callback.onEvent?.(action, result);
|
|
@@ -58,7 +61,10 @@ export const observeComment = <
|
|
|
58
61
|
callback[action]?.(result);
|
|
59
62
|
};
|
|
60
63
|
|
|
61
|
-
const realtimeRouter = (
|
|
64
|
+
const realtimeRouter = (
|
|
65
|
+
result: Amity.Snapshot<Amity.InternalComment>,
|
|
66
|
+
action: Events[number],
|
|
67
|
+
) => {
|
|
62
68
|
if (result.data?.commentId !== commentId) return;
|
|
63
69
|
|
|
64
70
|
router(result, action);
|
|
@@ -2,12 +2,12 @@ import { getActiveClient } from '~/client/api';
|
|
|
2
2
|
|
|
3
3
|
import {
|
|
4
4
|
onCommentCreated,
|
|
5
|
-
onCommentUpdated,
|
|
6
5
|
onCommentDeleted,
|
|
7
6
|
onCommentFlagged,
|
|
8
|
-
onCommentUnflagged,
|
|
9
7
|
onCommentReactionAdded,
|
|
10
8
|
onCommentReactionRemoved,
|
|
9
|
+
onCommentUnflagged,
|
|
10
|
+
onCommentUpdated,
|
|
11
11
|
} from '../events';
|
|
12
12
|
|
|
13
13
|
/**
|
|
@@ -18,18 +18,18 @@ import {
|
|
|
18
18
|
* const unsub = observeComments(postId, comment => merge(comments, comment))
|
|
19
19
|
* ```
|
|
20
20
|
*
|
|
21
|
-
* Observe all mutations on a list of {@link Amity.
|
|
21
|
+
* Observe all mutations on a list of {@link Amity.InternalComment} for a given {@link Amity.Post} object
|
|
22
22
|
*
|
|
23
23
|
* @param postId the ID of the post where to observe the comments
|
|
24
24
|
* @param callback the function to call when new data are available
|
|
25
25
|
* @returns An {@link Amity.Unsubscriber} function to run when willing to stop observing the comments
|
|
26
26
|
*
|
|
27
|
-
* @category
|
|
27
|
+
* @category InternalComment Observer
|
|
28
28
|
*/
|
|
29
29
|
export const observeComments = (
|
|
30
30
|
postId: Amity.Post['postId'],
|
|
31
31
|
callback: Amity.ObjectListener<
|
|
32
|
-
Amity.
|
|
32
|
+
Amity.InternalComment,
|
|
33
33
|
[
|
|
34
34
|
'onCreate',
|
|
35
35
|
'onUpdate',
|
|
@@ -48,7 +48,10 @@ export const observeComments = (
|
|
|
48
48
|
|
|
49
49
|
const disposers: Amity.Unsubscriber[] = [];
|
|
50
50
|
|
|
51
|
-
const router = (
|
|
51
|
+
const router = (
|
|
52
|
+
comment: Amity.InternalComment,
|
|
53
|
+
action: Exclude<Amity.CommentActionType, 'onFetch'>,
|
|
54
|
+
) => {
|
|
52
55
|
if (comment.referenceId !== postId) return;
|
|
53
56
|
|
|
54
57
|
if (callback instanceof Function) return callback(comment);
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { disableCache, enableCache } from '~/cache/api';
|
|
2
2
|
import {
|
|
3
|
-
pause,
|
|
4
3
|
client,
|
|
5
4
|
connectClient,
|
|
6
5
|
disconnectClient,
|
|
7
6
|
generateComment,
|
|
7
|
+
pause,
|
|
8
8
|
user12,
|
|
9
9
|
} from '~/utils/tests';
|
|
10
10
|
import { getFutureDate } from '~/core/model';
|
|
@@ -50,6 +50,7 @@ describe('getComment', () => {
|
|
|
50
50
|
client.emitter.emit(event, {
|
|
51
51
|
comments: [update],
|
|
52
52
|
commentChildren: [],
|
|
53
|
+
communityUsers: [],
|
|
53
54
|
users: [],
|
|
54
55
|
files: [],
|
|
55
56
|
});
|
|
@@ -91,6 +92,7 @@ describe('getComment', () => {
|
|
|
91
92
|
comments: [update],
|
|
92
93
|
reactor,
|
|
93
94
|
commentChildren: [],
|
|
95
|
+
communityUsers: [],
|
|
94
96
|
users: [],
|
|
95
97
|
files: [],
|
|
96
98
|
});
|
|
@@ -2,6 +2,7 @@ import { getActiveClient } from '~/client/api/activeClient';
|
|
|
2
2
|
import { fireEvent } from '~/core/events';
|
|
3
3
|
import { toPage, toToken } from '~/core/query';
|
|
4
4
|
import { ingestInCache } from '~/cache/api/ingestInCache';
|
|
5
|
+
import { convertChannelMarkerResponse, convertUserMarkerResponse } from '~/utils/marker';
|
|
5
6
|
|
|
6
7
|
/**
|
|
7
8
|
* ```js
|
|
@@ -38,12 +39,17 @@ export const getChannelMarkers = async (
|
|
|
38
39
|
});
|
|
39
40
|
|
|
40
41
|
const { paging, ...payload } = queryPayload;
|
|
41
|
-
const { userEntityMarkers, userMarkers } = payload;
|
|
42
|
+
const { userEntityMarkers: userEntityMarkersPayload, userMarkers: userMarkersPayload } = payload;
|
|
43
|
+
|
|
44
|
+
const userMarkers = convertUserMarkerResponse(userMarkersPayload);
|
|
45
|
+
const userEntityMarkers = convertChannelMarkerResponse(userEntityMarkersPayload);
|
|
42
46
|
|
|
43
47
|
const cachedAt = client.cache && Date.now();
|
|
44
|
-
if (client.cache) ingestInCache(
|
|
48
|
+
if (client.cache) ingestInCache({ userEntityMarkers, userMarkers }, { cachedAt });
|
|
45
49
|
|
|
46
|
-
fireEvent('local.channelMarker.fetched', {
|
|
50
|
+
fireEvent('local.channelMarker.fetched', {
|
|
51
|
+
userEntityMarkers,
|
|
52
|
+
});
|
|
47
53
|
fireEvent('local.userMarker.fetched', { userMarkers });
|
|
48
54
|
|
|
49
55
|
const nextPage = toPage(paging.next);
|
|
@@ -2,6 +2,7 @@ import { getActiveClient } from '~/client/api/activeClient';
|
|
|
2
2
|
import { fireEvent } from '~/core/events';
|
|
3
3
|
import { toPage, toToken } from '~/core/query';
|
|
4
4
|
import { ingestInCache } from '~/cache/api/ingestInCache';
|
|
5
|
+
import { convertUserMarkerResponse } from '~/utils/marker';
|
|
5
6
|
|
|
6
7
|
/**
|
|
7
8
|
* ```js
|
|
@@ -38,10 +39,12 @@ export const getMessageMarkers = async (
|
|
|
38
39
|
});
|
|
39
40
|
|
|
40
41
|
const { paging, ...payload } = queryPayload;
|
|
41
|
-
const { contentMarkers, feedMarkers, userMarkers } = payload;
|
|
42
|
+
const { contentMarkers, feedMarkers, userMarkers: userMarkersPayload } = payload;
|
|
43
|
+
|
|
44
|
+
const userMarkers = convertUserMarkerResponse(userMarkersPayload);
|
|
42
45
|
|
|
43
46
|
const cachedAt = client.cache && Date.now();
|
|
44
|
-
if (client.cache) ingestInCache(
|
|
47
|
+
if (client.cache) ingestInCache({ contentMarkers, feedMarkers, userMarkers }, { cachedAt });
|
|
45
48
|
|
|
46
49
|
fireEvent('local.feedMarker.fetched', { feedMarkers });
|
|
47
50
|
fireEvent('local.messageMarker.fetched', { contentMarkers });
|
|
@@ -2,6 +2,11 @@ import { getActiveClient } from '~/client/api/activeClient';
|
|
|
2
2
|
import { fireEvent } from '~/core/events';
|
|
3
3
|
import { toPage, toToken } from '~/core/query';
|
|
4
4
|
import { ingestInCache } from '~/cache/api/ingestInCache';
|
|
5
|
+
import {
|
|
6
|
+
convertChannelMarkerResponse,
|
|
7
|
+
convertSubChannelMarkerResponse,
|
|
8
|
+
convertUserMarkerResponse,
|
|
9
|
+
} from '~/utils/marker';
|
|
5
10
|
|
|
6
11
|
/**
|
|
7
12
|
* ```js
|
|
@@ -38,10 +43,19 @@ export const getSubChannelMarkers = async (
|
|
|
38
43
|
});
|
|
39
44
|
|
|
40
45
|
const { paging, ...payload } = queryPayload;
|
|
41
|
-
const {
|
|
46
|
+
const {
|
|
47
|
+
userEntityMarkers: userEntityMarkersPayload,
|
|
48
|
+
userFeedMarkers: userFeedMarkersPayload,
|
|
49
|
+
userMarkers: userMarkersPayload,
|
|
50
|
+
} = payload;
|
|
51
|
+
|
|
52
|
+
const userMarkers = convertUserMarkerResponse(userMarkersPayload);
|
|
53
|
+
const userEntityMarkers = convertChannelMarkerResponse(userEntityMarkersPayload);
|
|
54
|
+
const userFeedMarkers = convertSubChannelMarkerResponse(userFeedMarkersPayload);
|
|
42
55
|
|
|
43
56
|
const cachedAt = client.cache && Date.now();
|
|
44
|
-
if (client.cache)
|
|
57
|
+
if (client.cache)
|
|
58
|
+
ingestInCache({ userEntityMarkers, userFeedMarkers, userMarkers }, { cachedAt });
|
|
45
59
|
|
|
46
60
|
fireEvent('local.channelMarker.fetched', { userEntityMarkers });
|
|
47
61
|
fireEvent('local.subChannelMarker.fetched', { userFeedMarkers });
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { ingestInCache } from '~/cache/api/ingestInCache';
|
|
2
2
|
import { getActiveClient } from '~/client/api/activeClient';
|
|
3
3
|
import { fireEvent } from '~/core/events';
|
|
4
|
+
// import { convertMarkerResponse } from '~/utils/marker';
|
|
5
|
+
import { convertUserMarkerResponse } from '~/utils/marker';
|
|
4
6
|
|
|
5
7
|
export const getUserMarker = async (): Promise<Amity.Cached<Amity.UserMarker>> => {
|
|
6
8
|
const client = getActiveClient();
|
|
@@ -10,10 +12,15 @@ export const getUserMarker = async (): Promise<Amity.Cached<Amity.UserMarker>> =
|
|
|
10
12
|
`/api/v1/markers/userMarker`,
|
|
11
13
|
);
|
|
12
14
|
|
|
13
|
-
const { userMarkers } = payload;
|
|
15
|
+
const { userMarkers: UserMarkersPayload } = payload;
|
|
16
|
+
|
|
17
|
+
/*
|
|
18
|
+
change field isMentioned from backend to be hasMentioned
|
|
19
|
+
*/
|
|
20
|
+
const userMarkers = convertUserMarkerResponse(UserMarkersPayload);
|
|
14
21
|
|
|
15
22
|
const cachedAt = client.cache && Date.now();
|
|
16
|
-
if (client.cache) ingestInCache(
|
|
23
|
+
if (client.cache) ingestInCache({ userMarkers }, { cachedAt });
|
|
17
24
|
|
|
18
25
|
fireEvent('local.userMarker.fetched', { userMarkers });
|
|
19
26
|
|