@amityco/ts-sdk-react-native 7.5.1-f996b3e.0 → 7.5.2-94bff6e.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 +1 -1
- package/dist/@types/core/events.d.ts.map +1 -1
- package/dist/@types/domains/post.d.ts +18 -1
- package/dist/@types/domains/post.d.ts.map +1 -1
- package/dist/channelRepository/observers/getChannel.d.ts.map +1 -1
- package/dist/channelRepository/observers/getChannels/ChannelLiveCollectionController.d.ts.map +1 -1
- package/dist/channelRepository/observers/getTotalChannelsUnread.d.ts.map +1 -1
- package/dist/channelRepository/utils/prepareChannelPayload.d.ts.map +1 -1
- package/dist/index.cjs.js +28 -14
- package/dist/index.esm.js +28 -14
- package/dist/index.umd.js +2 -2
- package/dist/postRepository/api/getPost.d.ts +2 -2
- package/dist/postRepository/api/getPost.d.ts.map +1 -1
- package/dist/userRepository/observers/getBlockedUsers.d.ts +4 -4
- package/dist/userRepository/observers/getBlockedUsers.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/@types/core/events.ts +1 -1
- package/src/@types/domains/post.ts +25 -8
- package/src/channelRepository/observers/getChannel.ts +11 -1
- package/src/channelRepository/observers/getChannels/ChannelLiveCollectionController.ts +10 -1
- package/src/channelRepository/observers/getTotalChannelsUnread.ts +3 -1
- package/src/channelRepository/utils/prepareChannelPayload.ts +6 -1
- package/src/client/utils/ReadReceiptSync/readReceiptSyncEngine.ts +1 -1
- package/src/commentRepository/api/createComment.ts +1 -1
- package/src/commentRepository/api/deleteComment.ts +1 -1
- package/src/messageRepository/events/onMessageCreated.ts +1 -1
- package/src/postRepository/api/getPost.ts +6 -4
- package/src/postRepository/observers/getPost.ts +2 -2
- package/src/userRepository/observers/getBlockedUsers.ts +4 -4
- package/src/utils/linkedObject/streamLinkedObject.ts +1 -1
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
* @async
|
|
14
14
|
*/
|
|
15
15
|
export declare const getPost: {
|
|
16
|
-
(postId: Amity.Post['postId']): Promise<Amity.Cached<Amity.
|
|
16
|
+
(postId: Amity.Post['postId']): Promise<Amity.Cached<Amity.InternalPost>>;
|
|
17
17
|
/**
|
|
18
18
|
* ```js
|
|
19
19
|
* import { getPost } from '@amityco/ts-sdk-react-native'
|
|
@@ -27,6 +27,6 @@ export declare const getPost: {
|
|
|
27
27
|
*
|
|
28
28
|
* @category Post API
|
|
29
29
|
*/
|
|
30
|
-
locally(postId: Amity.Post['postId']): Amity.Cached<Amity.
|
|
30
|
+
locally(postId: Amity.Post['postId']): Amity.Cached<Amity.InternalPost> | undefined;
|
|
31
31
|
};
|
|
32
32
|
//# sourceMappingURL=getPost.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getPost.d.ts","sourceRoot":"","sources":["../../../src/postRepository/api/getPost.ts"],"names":[],"mappings":"AAUA;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,OAAO;
|
|
1
|
+
{"version":3,"file":"getPost.d.ts","sourceRoot":"","sources":["../../../src/postRepository/api/getPost.ts"],"names":[],"mappings":"AAUA;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,OAAO;aACV,MAAM,IAAI,CAAC,QAAQ,CAAC,GAC3B,QAAQ,MAAM,MAAM,CAAC,MAAM,YAAY,CAAC,CAAC;IAqC5C;;;;;;;;;;;;OAYG;oBACwB,MAAM,IAAI,CAAC,QAAQ,CAAC,GAAG,MAAM,MAAM,CAAC,MAAM,YAAY,CAAC,GAAG,SAAS;CAf7F,CAAC"}
|
|
@@ -4,14 +4,14 @@
|
|
|
4
4
|
* const unblockedUser = await UserRepository.blockUser('userId')
|
|
5
5
|
* ```
|
|
6
6
|
*
|
|
7
|
-
* Blocks a {@link Amity.
|
|
7
|
+
* Blocks a {@link Amity.User}
|
|
8
8
|
*
|
|
9
|
-
* @param params The params to get blocked {@link Amity.
|
|
10
|
-
* @param callback to recieve updates on unblocked {@link Amity.
|
|
9
|
+
* @param params The params to get blocked {@link Amity.User}s
|
|
10
|
+
* @param callback to recieve updates on unblocked {@link Amity.User}s
|
|
11
11
|
* @returns {@link Amity.Unsubscriber} to unsubscribe from collection
|
|
12
12
|
*
|
|
13
13
|
* @category Post API
|
|
14
14
|
* @async
|
|
15
15
|
*/
|
|
16
|
-
export declare const getBlockedUsers: (params: Amity.BlockedUsersLiveCollection, callback: Amity.LiveCollectionCallback<Amity.
|
|
16
|
+
export declare const getBlockedUsers: (params: Amity.BlockedUsersLiveCollection, callback: Amity.LiveCollectionCallback<Amity.User>, config?: Amity.LiveCollectionConfig) => Amity.Unsubscriber;
|
|
17
17
|
//# sourceMappingURL=getBlockedUsers.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getBlockedUsers.d.ts","sourceRoot":"","sources":["../../../src/userRepository/observers/getBlockedUsers.ts"],"names":[],"mappings":"AAQA;;;;;;;;;;;;;;GAcG;AACH,eAAO,MAAM,eAAe,WAClB,MAAM,0BAA0B,YAC9B,MAAM,sBAAsB,CAAC,MAAM,
|
|
1
|
+
{"version":3,"file":"getBlockedUsers.d.ts","sourceRoot":"","sources":["../../../src/userRepository/observers/getBlockedUsers.ts"],"names":[],"mappings":"AAQA;;;;;;;;;;;;;;GAcG;AACH,eAAO,MAAM,eAAe,WAClB,MAAM,0BAA0B,YAC9B,MAAM,sBAAsB,CAAC,MAAM,IAAI,CAAC,WACzC,MAAM,oBAAoB,KAClC,MAAM,YAsBR,CAAC"}
|
package/package.json
CHANGED
|
@@ -238,7 +238,7 @@ declare global {
|
|
|
238
238
|
|
|
239
239
|
'local.subChannelUnread.updated': Amity.SubChannelUnreadInfo;
|
|
240
240
|
'local.channelUnreadInfo.updated': Amity.ChannelUnreadInfo;
|
|
241
|
-
'local.channelUnread.updated': Amity.ChannelUnread;
|
|
241
|
+
'local.channelUnread.updated': Amity.ChannelUnread[];
|
|
242
242
|
|
|
243
243
|
'local.story.created': Amity.StoryPayload;
|
|
244
244
|
'local.story.updated': Amity.StoryPayload;
|
|
@@ -40,15 +40,32 @@ declare global {
|
|
|
40
40
|
hasFlaggedChildren: false;
|
|
41
41
|
hasFlaggedComment: false;
|
|
42
42
|
editedAt: Amity.timestamp;
|
|
43
|
+
// Amity.Metadata
|
|
44
|
+
metadata?: Record<string, any>;
|
|
45
|
+
// Amity.Flaggable
|
|
46
|
+
flagCount: number;
|
|
47
|
+
hashFlag: {
|
|
48
|
+
bits: number;
|
|
49
|
+
hashes: number;
|
|
50
|
+
hash: string;
|
|
51
|
+
} | null;
|
|
52
|
+
// Amity.Taggable
|
|
53
|
+
tags?: string[];
|
|
54
|
+
// Amity.Timestamps
|
|
55
|
+
createdAt: Amity.timestamp;
|
|
56
|
+
updatedAt?: Amity.timestamp;
|
|
57
|
+
// Amity.SoftDelete
|
|
58
|
+
isDeleted?: boolean;
|
|
59
|
+
// Amity.Subscribable
|
|
60
|
+
path: string;
|
|
61
|
+
// Amity.AnalyticPostData
|
|
62
|
+
impression: number;
|
|
63
|
+
reach: number;
|
|
64
|
+
// Amity.Reactable
|
|
65
|
+
reactionsCount: number;
|
|
66
|
+
reactions: Record<string, number>;
|
|
67
|
+
myReactions?: string[];
|
|
43
68
|
} & Amity.Content<T> &
|
|
44
|
-
Amity.Metadata &
|
|
45
|
-
Amity.Flaggable &
|
|
46
|
-
Amity.Reactable &
|
|
47
|
-
Amity.Taggable &
|
|
48
|
-
Amity.Timestamps &
|
|
49
|
-
Amity.SoftDelete &
|
|
50
|
-
Amity.Subscribable &
|
|
51
|
-
Amity.AnalyticPostData &
|
|
52
69
|
Amity.Mentionable<'user'>;
|
|
53
70
|
|
|
54
71
|
type InternalPost<T extends PostContentType = any> = RawPost<T> & {
|
|
@@ -297,7 +297,17 @@ export const getChannel = (
|
|
|
297
297
|
),
|
|
298
298
|
convertEventPayload(onSubChannelCreated, 'channelId', 'channel'),
|
|
299
299
|
convertEventPayload(onChannelUnreadInfoUpdatedLocal, 'channelId', 'channel'),
|
|
300
|
-
convertEventPayload(
|
|
300
|
+
convertEventPayload(
|
|
301
|
+
(callback: Amity.Listener<Amity.ChannelUnread>) => {
|
|
302
|
+
const processPayload = (payloads: Amity.ChannelUnread[]) => {
|
|
303
|
+
payloads.forEach(callback);
|
|
304
|
+
};
|
|
305
|
+
|
|
306
|
+
return onChannelUnreadUpdatedLocal(processPayload);
|
|
307
|
+
},
|
|
308
|
+
'channelId',
|
|
309
|
+
'channel',
|
|
310
|
+
),
|
|
301
311
|
],
|
|
302
312
|
{
|
|
303
313
|
forceDispatch: true,
|
|
@@ -572,7 +572,16 @@ export class ChannelLiveCollectionController extends LiveCollectionController<
|
|
|
572
572
|
action: Amity.ChannelActionType.OnUpdate,
|
|
573
573
|
},
|
|
574
574
|
{
|
|
575
|
-
fn: convertEventPayload(
|
|
575
|
+
fn: convertEventPayload(
|
|
576
|
+
(callback: Amity.Listener<Amity.ChannelUnread>) => {
|
|
577
|
+
const processPayload = (payloads: Amity.ChannelUnread[]) => {
|
|
578
|
+
payloads.forEach(callback);
|
|
579
|
+
};
|
|
580
|
+
return onChannelUnreadUpdatedLocal(processPayload);
|
|
581
|
+
},
|
|
582
|
+
'channelId',
|
|
583
|
+
'channel',
|
|
584
|
+
),
|
|
576
585
|
action: Amity.ChannelActionType.OnUpdate,
|
|
577
586
|
},
|
|
578
587
|
];
|
|
@@ -82,7 +82,9 @@ export const getTotalChannelsUnread = (
|
|
|
82
82
|
});
|
|
83
83
|
};
|
|
84
84
|
|
|
85
|
-
const realtimeRouter = (
|
|
85
|
+
const realtimeRouter = (_: Amity.ChannelUnread[]) => {
|
|
86
|
+
const { data: userUnread } = _getTotalChannelsUnread();
|
|
87
|
+
|
|
86
88
|
if (isEqual(model, userUnread)) return;
|
|
87
89
|
|
|
88
90
|
dispatcher({
|
|
@@ -7,6 +7,7 @@ import { getActiveClient } from '~/client/api/activeClient';
|
|
|
7
7
|
import { pullFromCache } from '~/cache/api/pullFromCache';
|
|
8
8
|
import { convertRawUserToInternalUser } from '~/userRepository/utils/convertRawUserToInternalUser';
|
|
9
9
|
import { pushToCache } from '~/cache/api';
|
|
10
|
+
import { fireEvent } from '~/core/events';
|
|
10
11
|
|
|
11
12
|
export const MARKER_INCLUDED_CHANNEL_TYPE = ['broadcast', 'conversation', 'community'];
|
|
12
13
|
export const isUnreadCountSupport = ({ type }: Pick<Amity.RawChannel, 'type'>) =>
|
|
@@ -56,6 +57,8 @@ const updateChannelUnread = ({
|
|
|
56
57
|
channels: Amity.RawChannel[];
|
|
57
58
|
channelUsers: Amity.RawMembership<'channel'>[];
|
|
58
59
|
}) => {
|
|
60
|
+
const channelsUnread: Amity.ChannelUnread[] = [];
|
|
61
|
+
|
|
59
62
|
for (let i = 0; i < channels.length; i += 1) {
|
|
60
63
|
const cacheKey = ['channelUnread', 'get', channels[i].channelId];
|
|
61
64
|
const channelUser = channelUsers.find(
|
|
@@ -84,9 +87,11 @@ const updateChannelUnread = ({
|
|
|
84
87
|
isMentioned,
|
|
85
88
|
isDeleted: channels[i].isDeleted || false,
|
|
86
89
|
};
|
|
87
|
-
|
|
88
90
|
pushToCache(cacheKey, cacheChannelUnread);
|
|
91
|
+
|
|
92
|
+
channelsUnread.push(cacheChannelUnread);
|
|
89
93
|
}
|
|
94
|
+
fireEvent('local.channelUnread.updated', channelsUnread);
|
|
90
95
|
};
|
|
91
96
|
|
|
92
97
|
export const prepareChannelPayload = async (
|
|
@@ -167,7 +167,7 @@ export class MessageReadReceiptSyncEngine {
|
|
|
167
167
|
channelUnread.unreadCount = Math.max(channelUnread.lastSegment - segment, 0);
|
|
168
168
|
|
|
169
169
|
pushToCache(cacheKey, channelUnread);
|
|
170
|
-
fireEvent('local.channelUnread.updated', channelUnread);
|
|
170
|
+
fireEvent('local.channelUnread.updated', [channelUnread]);
|
|
171
171
|
}
|
|
172
172
|
|
|
173
173
|
// Step 2: Enqueue the read receipt
|
|
@@ -51,7 +51,7 @@ export const createComment = async (
|
|
|
51
51
|
if (client.cache) ingestInCache(data, { cachedAt });
|
|
52
52
|
|
|
53
53
|
if (['post', 'content'].includes(bundle.referenceType)) {
|
|
54
|
-
const post = pullFromCache<Amity.
|
|
54
|
+
const post = pullFromCache<Amity.InternalPost>(['post', 'get', bundle.referenceId])?.data;
|
|
55
55
|
|
|
56
56
|
if (post) {
|
|
57
57
|
post.commentsCount += 1;
|
|
@@ -62,7 +62,7 @@ export const deleteComment = async (
|
|
|
62
62
|
users: [],
|
|
63
63
|
});
|
|
64
64
|
} else {
|
|
65
|
-
const post = pullFromCache<Amity.
|
|
65
|
+
const post = pullFromCache<Amity.InternalPost>(['post', 'get', comment.data.referenceId])?.data;
|
|
66
66
|
|
|
67
67
|
if (post) {
|
|
68
68
|
let removeCount: number;
|
|
@@ -80,7 +80,7 @@ export const onMessageCreatedMqtt = (
|
|
|
80
80
|
};
|
|
81
81
|
|
|
82
82
|
pushToCache(['channelUnread', 'get', message.channelId], updatedChannelUnread);
|
|
83
|
-
fireEvent('local.channelUnread.updated', updatedChannelUnread);
|
|
83
|
+
fireEvent('local.channelUnread.updated', [updatedChannelUnread]);
|
|
84
84
|
});
|
|
85
85
|
}
|
|
86
86
|
|
|
@@ -22,7 +22,9 @@ import { LinkedObject } from '~/utils/linkedObject';
|
|
|
22
22
|
* @category Post API
|
|
23
23
|
* @async
|
|
24
24
|
*/
|
|
25
|
-
export const getPost = async (
|
|
25
|
+
export const getPost = async (
|
|
26
|
+
postId: Amity.Post['postId'],
|
|
27
|
+
): Promise<Amity.Cached<Amity.InternalPost>> => {
|
|
26
28
|
const client = getActiveClient();
|
|
27
29
|
client.log('post/getPost', postId);
|
|
28
30
|
|
|
@@ -54,7 +56,7 @@ export const getPost = async (postId: Amity.Post['postId']): Promise<Amity.Cache
|
|
|
54
56
|
const result = posts.find(post => post.postId === postId)!;
|
|
55
57
|
|
|
56
58
|
return {
|
|
57
|
-
data:
|
|
59
|
+
data: result,
|
|
58
60
|
cachedAt,
|
|
59
61
|
};
|
|
60
62
|
};
|
|
@@ -72,7 +74,7 @@ export const getPost = async (postId: Amity.Post['postId']): Promise<Amity.Cache
|
|
|
72
74
|
*
|
|
73
75
|
* @category Post API
|
|
74
76
|
*/
|
|
75
|
-
getPost.locally = (postId: Amity.Post['postId']): Amity.Cached<Amity.
|
|
77
|
+
getPost.locally = (postId: Amity.Post['postId']): Amity.Cached<Amity.InternalPost> | undefined => {
|
|
76
78
|
const client = getActiveClient();
|
|
77
79
|
client.log('post/getPost.locally', postId);
|
|
78
80
|
|
|
@@ -83,7 +85,7 @@ getPost.locally = (postId: Amity.Post['postId']): Amity.Cached<Amity.Post> | und
|
|
|
83
85
|
if (!cached) return;
|
|
84
86
|
|
|
85
87
|
return {
|
|
86
|
-
data:
|
|
88
|
+
data: cached.data,
|
|
87
89
|
cachedAt: cached.cachedAt,
|
|
88
90
|
};
|
|
89
91
|
};
|
|
@@ -85,12 +85,12 @@ export const getPost = (
|
|
|
85
85
|
onPostFlagged,
|
|
86
86
|
(callback: Amity.Listener<Amity.InternalPost>) => {
|
|
87
87
|
return onPostReactionAdded((post: Amity.InternalPost) => {
|
|
88
|
-
callback(
|
|
88
|
+
callback(post);
|
|
89
89
|
});
|
|
90
90
|
},
|
|
91
91
|
(callback: Amity.Listener<Amity.InternalPost>) => {
|
|
92
92
|
return onPostReactionRemoved((post: Amity.InternalPost) => {
|
|
93
|
-
callback(
|
|
93
|
+
callback(post);
|
|
94
94
|
});
|
|
95
95
|
},
|
|
96
96
|
onPostUnflagged,
|
|
@@ -12,10 +12,10 @@ import { BlockedUserLiveCollectionController } from './getBlockedUsers/BlockedUs
|
|
|
12
12
|
* const unblockedUser = await UserRepository.blockUser('userId')
|
|
13
13
|
* ```
|
|
14
14
|
*
|
|
15
|
-
* Blocks a {@link Amity.
|
|
15
|
+
* Blocks a {@link Amity.User}
|
|
16
16
|
*
|
|
17
|
-
* @param params The params to get blocked {@link Amity.
|
|
18
|
-
* @param callback to recieve updates on unblocked {@link Amity.
|
|
17
|
+
* @param params The params to get blocked {@link Amity.User}s
|
|
18
|
+
* @param callback to recieve updates on unblocked {@link Amity.User}s
|
|
19
19
|
* @returns {@link Amity.Unsubscriber} to unsubscribe from collection
|
|
20
20
|
*
|
|
21
21
|
* @category Post API
|
|
@@ -23,7 +23,7 @@ import { BlockedUserLiveCollectionController } from './getBlockedUsers/BlockedUs
|
|
|
23
23
|
*/
|
|
24
24
|
export const getBlockedUsers = (
|
|
25
25
|
params: Amity.BlockedUsersLiveCollection,
|
|
26
|
-
callback: Amity.LiveCollectionCallback<Amity.
|
|
26
|
+
callback: Amity.LiveCollectionCallback<Amity.User>,
|
|
27
27
|
config?: Amity.LiveCollectionConfig,
|
|
28
28
|
): Amity.Unsubscriber => {
|
|
29
29
|
const { log, cache } = getActiveClient();
|
|
@@ -9,7 +9,7 @@ export const streamLinkedObject = (stream: Amity.InternalStream): Amity.Stream =
|
|
|
9
9
|
},
|
|
10
10
|
get post() {
|
|
11
11
|
if (stream.referenceType !== 'post') return;
|
|
12
|
-
return pullFromCache<Amity.
|
|
12
|
+
return pullFromCache<Amity.InternalPost>(['post', 'get', stream.referenceId])?.data;
|
|
13
13
|
},
|
|
14
14
|
get community() {
|
|
15
15
|
if (stream.targetType !== 'community') return;
|