@amityco/ts-sdk-react-native 6.21.1 → 6.23.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/domains/channel.d.ts +1 -0
- package/dist/@types/domains/channel.d.ts.map +1 -1
- package/dist/@types/domains/post.d.ts +2 -3
- package/dist/@types/domains/post.d.ts.map +1 -1
- package/dist/channelRepository/api/getChannel.d.ts +1 -1
- package/dist/channelRepository/api/getChannel.d.ts.map +1 -1
- package/dist/channelRepository/api/getChannelByIds.d.ts +1 -1
- package/dist/channelRepository/api/getChannelByIds.d.ts.map +1 -1
- package/dist/channelRepository/api/markAsRead.d.ts +3 -1
- package/dist/channelRepository/api/markAsRead.d.ts.map +1 -1
- package/dist/channelRepository/channelMembership/observers/getMembers/ChannelMemberQueryStreamController.d.ts +2 -2
- package/dist/channelRepository/channelMembership/observers/getMembers/ChannelMemberQueryStreamController.d.ts.map +1 -1
- package/dist/channelRepository/events/onChannelMemberRoleAdded.d.ts +1 -1
- package/dist/channelRepository/events/onChannelMemberRoleAdded.d.ts.map +1 -1
- package/dist/channelRepository/events/onChannelMemberRoleRemoved.d.ts +1 -1
- package/dist/channelRepository/events/onChannelMemberRoleRemoved.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/observeChannel.d.ts.map +1 -1
- package/dist/channelRepository/observers/observeChannels.d.ts.map +1 -1
- package/dist/client/api/index.d.ts +1 -0
- package/dist/client/api/index.d.ts.map +1 -1
- package/dist/client/api/logout.d.ts +2 -2
- package/dist/client/api/secureLogout.d.ts +15 -0
- package/dist/client/api/secureLogout.d.ts.map +1 -0
- package/dist/core/liveCollection/LiveCollectionController.d.ts.map +1 -1
- package/dist/index.cjs.js +149 -87
- package/dist/index.esm.js +149 -87
- package/dist/index.umd.js +2 -2
- package/dist/messagePreview/utils/getChannelMessagePreviewWithUser.d.ts +35 -1
- package/dist/messagePreview/utils/getChannelMessagePreviewWithUser.d.ts.map +1 -1
- package/dist/messageRepository/events/onMessageCreated.d.ts.map +1 -1
- package/dist/messageRepository/utils/markReadMessage.d.ts +2 -0
- package/dist/messageRepository/utils/markReadMessage.d.ts.map +1 -0
- package/dist/postRepository/api/createPost.d.ts +1 -1
- package/dist/postRepository/api/createPost.d.ts.map +1 -1
- package/dist/subChannelRepository/observers/getSubChannel.d.ts.map +1 -1
- package/dist/subChannelRepository/observers/getSubChannels/SubChannelLiveCollectionController.d.ts.map +1 -1
- package/dist/utils/linkedObject/channelLinkedObject.d.ts +2 -0
- package/dist/utils/linkedObject/channelLinkedObject.d.ts.map +1 -0
- package/dist/utils/linkedObject/index.d.ts +1 -0
- package/dist/utils/linkedObject/index.d.ts.map +1 -1
- package/dist/utils/linkedObject/messageLinkedObject.d.ts.map +1 -1
- package/dist/utils/object.d.ts +1 -0
- package/dist/utils/object.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/@types/domains/channel.ts +1 -0
- package/src/@types/domains/post.ts +3 -3
- package/src/channelRepository/api/getChannel.ts +1 -1
- package/src/channelRepository/api/getChannelByIds.ts +4 -3
- package/src/channelRepository/api/markAsRead.ts +6 -2
- package/src/channelRepository/channelMembership/observers/getMembers/ChannelMemberQueryStreamController.ts +5 -2
- package/src/channelRepository/events/onChannelMemberRoleAdded.ts +1 -1
- package/src/channelRepository/events/onChannelMemberRoleRemoved.ts +1 -1
- package/src/channelRepository/observers/getChannel.ts +6 -2
- package/src/channelRepository/observers/getChannels/ChannelLiveCollectionController.ts +3 -1
- package/src/channelRepository/observers/observeChannel.ts +15 -3
- package/src/channelRepository/observers/observeChannels.ts +8 -4
- package/src/client/api/index.ts +1 -0
- package/src/client/api/logout.ts +2 -2
- package/src/client/api/secureLogout.ts +33 -0
- package/src/communityRepository/communityMembership/events/utils.ts +2 -2
- package/src/core/liveCollection/LiveCollectionController.ts +4 -3
- package/src/messagePreview/utils/getChannelMessagePreviewWithUser.ts +5 -1
- package/src/messageRepository/events/onMessageCreated.ts +4 -0
- package/src/messageRepository/utils/markReadMessage.ts +8 -0
- package/src/postRepository/api/createPost.ts +1 -2
- package/src/subChannelRepository/observers/getSubChannel.ts +8 -4
- package/src/subChannelRepository/observers/getSubChannels/SubChannelLiveCollectionController.ts +9 -6
- package/src/utils/linkedObject/channelLinkedObject.ts +8 -0
- package/src/utils/linkedObject/index.ts +2 -0
- package/src/utils/linkedObject/messageLinkedObject.ts +2 -7
- package/src/utils/object.ts +15 -0
|
@@ -1,2 +1,36 @@
|
|
|
1
|
-
export declare const getChannelMessagePreviewWithUser: (channel: Amity.InternalChannel) =>
|
|
1
|
+
export declare const getChannelMessagePreviewWithUser: (channel: Amity.InternalChannel) => {
|
|
2
|
+
_id: string;
|
|
3
|
+
channelId: string;
|
|
4
|
+
channelInternalId: string;
|
|
5
|
+
channelPublicId: string;
|
|
6
|
+
displayName?: string | undefined;
|
|
7
|
+
avatarFileId?: string | undefined;
|
|
8
|
+
type: any;
|
|
9
|
+
isDistinct?: boolean | undefined;
|
|
10
|
+
isMuted?: boolean | undefined;
|
|
11
|
+
muteTimeout?: string | undefined;
|
|
12
|
+
isRateLimited?: boolean | undefined;
|
|
13
|
+
rateLimit?: number | undefined;
|
|
14
|
+
rateLimitWindow?: number | undefined;
|
|
15
|
+
rateLimitTimeout?: number | undefined;
|
|
16
|
+
messageAutoDeleteEnabled?: boolean | undefined;
|
|
17
|
+
autoDeleteMessageByFlagLimit?: number | undefined;
|
|
18
|
+
memberCount?: number | undefined;
|
|
19
|
+
messageCount: number;
|
|
20
|
+
moderatorMemberCount?: number | undefined;
|
|
21
|
+
messagePreviewId?: string | undefined;
|
|
22
|
+
isPublic?: boolean | undefined;
|
|
23
|
+
lastActivity: string;
|
|
24
|
+
} & Amity.Metadata & Amity.Taggable & Amity.CreatedAt & Amity.UpdatedAt & Amity.DeletedAt & {
|
|
25
|
+
isDeleted?: boolean | undefined;
|
|
26
|
+
} & Amity.Subscribable & {
|
|
27
|
+
defaultSubChannelId: string;
|
|
28
|
+
isUnreadCountSupport: boolean;
|
|
29
|
+
unreadCount: number;
|
|
30
|
+
hasMentioned: boolean;
|
|
31
|
+
isMentioned: boolean;
|
|
32
|
+
subChannelsUnreadCount: number;
|
|
33
|
+
} & {
|
|
34
|
+
messagePreview: Amity.MessagePreview | null;
|
|
35
|
+
};
|
|
2
36
|
//# sourceMappingURL=getChannelMessagePreviewWithUser.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getChannelMessagePreviewWithUser.d.ts","sourceRoot":"","sources":["../../../src/messagePreview/utils/getChannelMessagePreviewWithUser.ts"],"names":[],"mappings":"AAIA,eAAO,MAAM,gCAAgC,
|
|
1
|
+
{"version":3,"file":"getChannelMessagePreviewWithUser.d.ts","sourceRoot":"","sources":["../../../src/messagePreview/utils/getChannelMessagePreviewWithUser.ts"],"names":[],"mappings":"AAIA,eAAO,MAAM,gCAAgC,YAClC,MAAM,eAAe;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;oBAEd,MAAM,cAAc,GAAG,IAAI;CAoB5C,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"onMessageCreated.d.ts","sourceRoot":"","sources":["../../../src/messageRepository/events/onMessageCreated.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"onMessageCreated.d.ts","sourceRoot":"","sources":["../../../src/messageRepository/events/onMessageCreated.ts"],"names":[],"mappings":"AASA;;;;;;;;;;;;;;;GAeG;AACH,eAAO,MAAM,oBAAoB,aACrB,MAAM,QAAQ,CAAC,MAAM,eAAe,CAAC,KAC9C,MAAM,YA+BR,CAAC;AAEF,eAAO,MAAM,qBAAqB,aACtB,MAAM,QAAQ,CAAC,MAAM,eAAe,CAAC,KAC9C,MAAM,YAcR,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"markReadMessage.d.ts","sourceRoot":"","sources":["../../../src/messageRepository/utils/markReadMessage.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,eAAe,YAAa,MAAM,eAAe,SAK7D,CAAC"}
|
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
* @category Post API
|
|
17
17
|
* @async
|
|
18
18
|
*/
|
|
19
|
-
export declare const createPost: <T extends
|
|
19
|
+
export declare const createPost: <T extends string>(bundle: Pick<Amity.Post<T>, "targetType" | "targetId"> & Partial<Pick<Amity.Post<T>, "metadata" | "tags" | "mentionees">> & {
|
|
20
20
|
dataType?: T | undefined;
|
|
21
21
|
data?: {
|
|
22
22
|
[k: string]: any;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createPost.d.ts","sourceRoot":"","sources":["../../../src/postRepository/api/createPost.ts"],"names":[],"mappings":"AAUA;;;;;;;;;;;;;;;;;GAiBG;AACH,eAAO,MAAM,UAAU;;;;;;;gBAKgB,UAAU,CAAC,QAAQ,CAAC;;MAExD,QAAQ,MAAM,MAAM,CAAC,MAAM,IAAI,CAAC,
|
|
1
|
+
{"version":3,"file":"createPost.d.ts","sourceRoot":"","sources":["../../../src/postRepository/api/createPost.ts"],"names":[],"mappings":"AAUA;;;;;;;;;;;;;;;;;GAiBG;AACH,eAAO,MAAM,UAAU;;;;;;;gBAKgB,UAAU,CAAC,QAAQ,CAAC;;MAExD,QAAQ,MAAM,MAAM,CAAC,MAAM,IAAI,CAAC,CAwBlC,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getSubChannel.d.ts","sourceRoot":"","sources":["../../../src/subChannelRepository/observers/getSubChannel.ts"],"names":[],"mappings":"AA2BA;;;;;;;;;;;;;;;;;;GAkBG;AACH,eAAO,MAAM,aAAa,iBACV,MAAM,UAAU,CAAC,cAAc,CAAC,YACpC,MAAM,kBAAkB,CAAC,MAAM,UAAU,CAAC,KACnD,MAAM,
|
|
1
|
+
{"version":3,"file":"getSubChannel.d.ts","sourceRoot":"","sources":["../../../src/subChannelRepository/observers/getSubChannel.ts"],"names":[],"mappings":"AA2BA;;;;;;;;;;;;;;;;;;GAkBG;AACH,eAAO,MAAM,aAAa,iBACV,MAAM,UAAU,CAAC,cAAc,CAAC,YACpC,MAAM,kBAAkB,CAAC,MAAM,UAAU,CAAC,KACnD,MAAM,YAoLR,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SubChannelLiveCollectionController.d.ts","sourceRoot":"","sources":["../../../../src/subChannelRepository/observers/getSubChannels/SubChannelLiveCollectionController.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,wBAAwB,EAAE,MAAM,gDAAgD,CAAC;AAE1F,OAAO,EAAE,8BAA8B,EAAE,MAAM,kCAAkC,CAAC;AA6BlF,qBAAa,kCAAmC,SAAQ,wBAAwB,CAC9E,YAAY,EACZ,KAAK,CAAC,wBAAwB,EAC9B,KAAK,CAAC,UAAU,EAChB,8BAA8B,CAC/B;IACC,OAAO,CAAC,qBAAqB,CAAkC;IAE/D,OAAO,CAAC,KAAK,CAAiC;gBAG5C,KAAK,EAAE,KAAK,CAAC,wBAAwB,EACrC,QAAQ,EAAE,KAAK,CAAC,sBAAsB,CAAC,KAAK,CAAC,UAAU,CAAC;IAmB1D,SAAS,CAAC,KAAK;cASC,YAAY,CAAC,QAAQ,EAAE,KAAK,CAAC,iBAAiB,GAAG,KAAK,CAAC,UAAU;IAIjF,SAAS,CAAC,kBAAkB,CAAC,EAC3B,QAAQ,EACR,SAAS,EACT,OAAO,GACR,EAAE,KAAK,CAAC,sCAAsC,CAAC,YAAY,CAAC;IAI7D,iBAAiB;
|
|
1
|
+
{"version":3,"file":"SubChannelLiveCollectionController.d.ts","sourceRoot":"","sources":["../../../../src/subChannelRepository/observers/getSubChannels/SubChannelLiveCollectionController.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,wBAAwB,EAAE,MAAM,gDAAgD,CAAC;AAE1F,OAAO,EAAE,8BAA8B,EAAE,MAAM,kCAAkC,CAAC;AA6BlF,qBAAa,kCAAmC,SAAQ,wBAAwB,CAC9E,YAAY,EACZ,KAAK,CAAC,wBAAwB,EAC9B,KAAK,CAAC,UAAU,EAChB,8BAA8B,CAC/B;IACC,OAAO,CAAC,qBAAqB,CAAkC;IAE/D,OAAO,CAAC,KAAK,CAAiC;gBAG5C,KAAK,EAAE,KAAK,CAAC,wBAAwB,EACrC,QAAQ,EAAE,KAAK,CAAC,sBAAsB,CAAC,KAAK,CAAC,UAAU,CAAC;IAmB1D,SAAS,CAAC,KAAK;cASC,YAAY,CAAC,QAAQ,EAAE,KAAK,CAAC,iBAAiB,GAAG,KAAK,CAAC,UAAU;IAIjF,SAAS,CAAC,kBAAkB,CAAC,EAC3B,QAAQ,EACR,SAAS,EACT,OAAO,GACR,EAAE,KAAK,CAAC,sCAAsC,CAAC,YAAY,CAAC;IAI7D,iBAAiB;IAyNjB,YAAY,CAAC,EAAE,MAAM,EAAE,OAAO,EAAE,KAAK,EAAE,EAAE,KAAK,CAAC,0BAA0B;IAuBzE,WAAW,CAAC,IAAI,EAAE,KAAK,CAAC,UAAU,EAAE;CAWrC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"channelLinkedObject.d.ts","sourceRoot":"","sources":["../../../src/utils/linkedObject/channelLinkedObject.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,mBAAmB,YAAa,MAAM,eAAe,KAAG,MAAM,OAK1E,CAAC"}
|
|
@@ -7,5 +7,6 @@ export declare const LinkedObject: {
|
|
|
7
7
|
storyTarget: (storyTarget: Amity.RawStoryTarget) => Amity.StoryTarget;
|
|
8
8
|
message: (message: Amity.InternalMessage<any>) => Amity.Message<any>;
|
|
9
9
|
reactor: (reactor: Amity.InternalReactor) => Amity.Reactor;
|
|
10
|
+
channel: (channel: Amity.InternalChannel<any>) => Amity.Channel<any>;
|
|
10
11
|
};
|
|
11
12
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/utils/linkedObject/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/utils/linkedObject/index.ts"],"names":[],"mappings":"AAUA,eAAO,MAAM,YAAY;;;;;;;;;;CAUxB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"messageLinkedObject.d.ts","sourceRoot":"","sources":["../../../src/utils/linkedObject/messageLinkedObject.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,mBAAmB,YAAa,MAAM,eAAe,KAAG,MAAM,
|
|
1
|
+
{"version":3,"file":"messageLinkedObject.d.ts","sourceRoot":"","sources":["../../../src/utils/linkedObject/messageLinkedObject.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,mBAAmB,YAAa,MAAM,eAAe,KAAG,MAAM,OAY1E,CAAC"}
|
package/dist/utils/object.d.ts
CHANGED
|
@@ -3,4 +3,5 @@ export declare function isObject(value: unknown): value is Record<string, unknow
|
|
|
3
3
|
* convert all object getter property to static value
|
|
4
4
|
*/
|
|
5
5
|
export declare const convertGetterPropsToStatic: <T extends Record<string, unknown>>(obj: T) => T;
|
|
6
|
+
export declare const removeFunctionProperties: <T extends Record<string, unknown>>(obj: T) => T;
|
|
6
7
|
//# sourceMappingURL=object.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"object.d.ts","sourceRoot":"","sources":["../../src/utils/object.ts"],"names":[],"mappings":"AAAA,wBAAgB,QAAQ,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAEzE;AACD;;GAEG;AACH,eAAO,MAAM,0BAA0B,kDAetC,CAAC"}
|
|
1
|
+
{"version":3,"file":"object.d.ts","sourceRoot":"","sources":["../../src/utils/object.ts"],"names":[],"mappings":"AAAA,wBAAgB,QAAQ,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAEzE;AACD;;GAEG;AACH,eAAO,MAAM,0BAA0B,kDAetC,CAAC;AAEF,eAAO,MAAM,wBAAwB,kDAapC,CAAC"}
|
package/package.json
CHANGED
|
@@ -5,7 +5,6 @@ export const PostContentType = Object.freeze({
|
|
|
5
5
|
VIDEO: 'video',
|
|
6
6
|
LIVESTREAM: 'liveStream',
|
|
7
7
|
POLL: 'poll',
|
|
8
|
-
CUSTOM: 'custom',
|
|
9
8
|
});
|
|
10
9
|
|
|
11
10
|
declare global {
|
|
@@ -27,7 +26,7 @@ declare global {
|
|
|
27
26
|
| 'onReactionAdded'
|
|
28
27
|
| 'onReactionRemoved';
|
|
29
28
|
|
|
30
|
-
type InternalPost<T extends PostContentType = any> = {
|
|
29
|
+
type InternalPost<T extends PostContentType | string = any> = {
|
|
31
30
|
postId: string;
|
|
32
31
|
postedUserId: Amity.InternalUser['userId']; // API-FIX: it should be "userId"
|
|
33
32
|
parentId: Amity.InternalPost['postId'];
|
|
@@ -60,7 +59,8 @@ declare global {
|
|
|
60
59
|
};
|
|
61
60
|
};
|
|
62
61
|
|
|
63
|
-
type Post<T extends PostContentType = any> = Amity.InternalPost<T> &
|
|
62
|
+
type Post<T extends PostContentType | string = any> = Amity.InternalPost<T> &
|
|
63
|
+
Amity.PostLinkObject;
|
|
64
64
|
|
|
65
65
|
type QueryPosts = {
|
|
66
66
|
targetId: string;
|
|
@@ -79,7 +79,7 @@ export const getChannel = async (
|
|
|
79
79
|
*/
|
|
80
80
|
getChannel.locally = (
|
|
81
81
|
channelId: Amity.Channel['channelPublicId'],
|
|
82
|
-
): Amity.Cached<Amity.
|
|
82
|
+
): Amity.Cached<Amity.InternalChannel> | undefined => {
|
|
83
83
|
const client = getActiveClient();
|
|
84
84
|
client.log('channel/getChannel.locally', channelId);
|
|
85
85
|
|
|
@@ -8,6 +8,7 @@ import { pushToTombstone } from '~/cache/api/pushToTombstone';
|
|
|
8
8
|
import { prepareChannelPayload } from '../utils';
|
|
9
9
|
import { fireEvent } from '~/core/events';
|
|
10
10
|
import { prepareUnreadCountInfo } from '../utils/prepateUnreadCountInfo';
|
|
11
|
+
import { LinkedObject } from '~/utils/linkedObject';
|
|
11
12
|
|
|
12
13
|
/**
|
|
13
14
|
* ```js
|
|
@@ -25,7 +26,7 @@ import { prepareUnreadCountInfo } from '../utils/prepateUnreadCountInfo';
|
|
|
25
26
|
*/
|
|
26
27
|
export const getChannelByIds = async (
|
|
27
28
|
channelIds: Amity.Channel['channelPublicId'][],
|
|
28
|
-
): Promise<Amity.Cached<Amity.
|
|
29
|
+
): Promise<Amity.Cached<Amity.Channel[]>> => {
|
|
29
30
|
const client = getActiveClient();
|
|
30
31
|
client.log('channel/getChannelByIds', channelIds);
|
|
31
32
|
|
|
@@ -63,7 +64,7 @@ export const getChannelByIds = async (
|
|
|
63
64
|
fireEvent('local.channel.fetched', data.channels);
|
|
64
65
|
|
|
65
66
|
return {
|
|
66
|
-
data: data.channels,
|
|
67
|
+
data: data.channels.map(channel => LinkedObject.channel(channel)),
|
|
67
68
|
cachedAt,
|
|
68
69
|
};
|
|
69
70
|
};
|
|
@@ -99,7 +100,7 @@ getChannelByIds.locally = (
|
|
|
99
100
|
const oldest = cached.sort((a, b) => (a.cachedAt! < b.cachedAt! ? -1 : 1))?.[0];
|
|
100
101
|
|
|
101
102
|
return {
|
|
102
|
-
data: channels,
|
|
103
|
+
data: channels.map(channel => LinkedObject.channel(channel)),
|
|
103
104
|
cachedAt: oldest.cachedAt,
|
|
104
105
|
};
|
|
105
106
|
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { getActiveClient } from '~/client/api';
|
|
1
|
+
import { getActiveClient } from '~/client/api/activeClient';
|
|
2
2
|
import { ingestInCache } from '~/cache/api/ingestInCache';
|
|
3
3
|
import { convertChannelMarkerResponse, convertSubChannelMarkerResponse } from '~/utils/marker';
|
|
4
4
|
import { fireEvent } from '~/core/events';
|
|
@@ -9,6 +9,8 @@ import { fireEvent } from '~/core/events';
|
|
|
9
9
|
* const success = await ChannelRepository.markAsRead('channelId')
|
|
10
10
|
* ```
|
|
11
11
|
*
|
|
12
|
+
* @deprecated Please use the {@link Amity.Channel.markAsRead} method instead
|
|
13
|
+
*
|
|
12
14
|
* Updating all {@link Amity.SubChannel} in specify {@link Amity.Channel} as read
|
|
13
15
|
*
|
|
14
16
|
* @param channelId the ID of to specify {@link Amity.Channel}
|
|
@@ -17,7 +19,9 @@ import { fireEvent } from '~/core/events';
|
|
|
17
19
|
* @category Channel API
|
|
18
20
|
* @async
|
|
19
21
|
*/
|
|
20
|
-
export const markAsRead = async (
|
|
22
|
+
export const markAsRead = async (
|
|
23
|
+
channelId: Amity.Channel['channelInternalId'],
|
|
24
|
+
): Promise<boolean> => {
|
|
21
25
|
const client = getActiveClient();
|
|
22
26
|
client.log('channel/markAsRead', channelId);
|
|
23
27
|
|
|
@@ -72,7 +72,7 @@ export class ChannelMemberQueryStreamController extends QueryStreamController<
|
|
|
72
72
|
}
|
|
73
73
|
|
|
74
74
|
reactor(action: string) {
|
|
75
|
-
return (channel: Amity.
|
|
75
|
+
return (channel: Amity.InternalChannel, channelMember: Amity.Membership<'channel'>) => {
|
|
76
76
|
if (this.query.channelId !== channelMember.channelId) return;
|
|
77
77
|
|
|
78
78
|
const collection = pullFromCache<Amity.ChannelMembersLiveCollectionCache>(
|
|
@@ -99,7 +99,10 @@ export class ChannelMemberQueryStreamController extends QueryStreamController<
|
|
|
99
99
|
subscribeRTE(
|
|
100
100
|
createSubscriber: {
|
|
101
101
|
fn: (
|
|
102
|
-
reactor: (
|
|
102
|
+
reactor: (
|
|
103
|
+
channel: Amity.InternalChannel,
|
|
104
|
+
channelMember: Amity.Membership<'channel'>,
|
|
105
|
+
) => void,
|
|
103
106
|
) => Amity.Unsubscriber;
|
|
104
107
|
action: string;
|
|
105
108
|
}[],
|
|
@@ -17,7 +17,7 @@ import { createEventSubscriber } from '~/core/events';
|
|
|
17
17
|
* @category Channel Events
|
|
18
18
|
*/
|
|
19
19
|
export const onChannelMemberRoleAdded = (
|
|
20
|
-
callback: (channel: Amity.
|
|
20
|
+
callback: (channel: Amity.InternalChannel, member: Amity.Membership<'channel'>) => void,
|
|
21
21
|
): Amity.Unsubscriber => {
|
|
22
22
|
const client = getActiveClient();
|
|
23
23
|
|
|
@@ -20,7 +20,7 @@ import { prepareChannelPayload } from '../utils';
|
|
|
20
20
|
* @category Channel Events
|
|
21
21
|
*/
|
|
22
22
|
export const onChannelMemberRoleRemoved = (
|
|
23
|
-
callback: (channel: Amity.
|
|
23
|
+
callback: (channel: Amity.InternalChannel, member: Amity.Membership<'channel'>) => void,
|
|
24
24
|
): Amity.Unsubscriber => {
|
|
25
25
|
const client = getActiveClient();
|
|
26
26
|
|
|
@@ -34,6 +34,7 @@ import { updateChannelCache } from '../utils/updateChannelCache';
|
|
|
34
34
|
import { onChannelMarkerUpdated } from '~/marker/events/onChannelMarkerUpdated';
|
|
35
35
|
import { onSubChannelCreated } from '~/subChannelRepository';
|
|
36
36
|
import { onUserFeedMarkerUpdated } from '~/marker/events/onUserFeedMarkerUpdated';
|
|
37
|
+
import { LinkedObject } from '~/utils/linkedObject';
|
|
37
38
|
|
|
38
39
|
/* begin_public_function
|
|
39
40
|
id: channel.get
|
|
@@ -72,7 +73,7 @@ export const getChannel = (
|
|
|
72
73
|
|
|
73
74
|
const data = {
|
|
74
75
|
...response,
|
|
75
|
-
data: getChannelMessagePreviewWithUser(response.data),
|
|
76
|
+
data: LinkedObject.channel(getChannelMessagePreviewWithUser(response.data)),
|
|
76
77
|
};
|
|
77
78
|
|
|
78
79
|
const { origin, ...newSnapshot } = data;
|
|
@@ -126,7 +127,10 @@ export const getChannel = (
|
|
|
126
127
|
callback(message);
|
|
127
128
|
};
|
|
128
129
|
|
|
129
|
-
return onMessageCreatedMqtt(
|
|
130
|
+
return onMessageCreatedMqtt(async (message: Amity.InternalMessage) => {
|
|
131
|
+
await updateMessagePreview(message);
|
|
132
|
+
callback(message);
|
|
133
|
+
});
|
|
130
134
|
},
|
|
131
135
|
'channelId',
|
|
132
136
|
'channel',
|
|
@@ -55,6 +55,7 @@ import { prepareUnreadCountInfo } from '~/channelRepository/utils/prepateUnreadC
|
|
|
55
55
|
import { resolveUnreadInfoOnChannelEvent } from '~/channelRepository/utils/resolveUnreadInfoOnChannelEvent';
|
|
56
56
|
import { onChannelResolved } from '~/channelRepository/events/onChannelResolved';
|
|
57
57
|
import { onUserMessageFeedMarkerResolved } from '~/marker/events/onUserMessageFeedMarkerResolved';
|
|
58
|
+
import { LinkedObject } from '~/utils/linkedObject';
|
|
58
59
|
|
|
59
60
|
export class ChannelLiveCollectionController extends LiveCollectionController<
|
|
60
61
|
'channel',
|
|
@@ -135,7 +136,8 @@ export class ChannelLiveCollectionController extends LiveCollectionController<
|
|
|
135
136
|
.map(channelId => pullFromCache<Amity.Channel>(['channel', 'get', channelId])!)
|
|
136
137
|
.filter(Boolean)
|
|
137
138
|
.map(({ data }) => data)
|
|
138
|
-
.map(getChannelMessagePreviewWithUser)
|
|
139
|
+
.map(getChannelMessagePreviewWithUser)
|
|
140
|
+
.map(LinkedObject.channel) ?? [];
|
|
139
141
|
|
|
140
142
|
if (this.paginationController instanceof ChannelPaginationController) {
|
|
141
143
|
data = this.applyFilter(data);
|
|
@@ -15,6 +15,7 @@ import {
|
|
|
15
15
|
onChannelMemberAdded,
|
|
16
16
|
onChannelMemberRemoved,
|
|
17
17
|
} from '../events';
|
|
18
|
+
import { LinkedObject } from '~/utils/linkedObject';
|
|
18
19
|
|
|
19
20
|
/**
|
|
20
21
|
* ```js
|
|
@@ -46,11 +47,22 @@ export const observeChannel = <Events extends [Exclude<Amity.ChannelActionType,
|
|
|
46
47
|
// filter function
|
|
47
48
|
if (result.data?.channelId !== channelId) return;
|
|
48
49
|
|
|
49
|
-
if (callback instanceof Function)
|
|
50
|
+
if (callback instanceof Function)
|
|
51
|
+
return callback({
|
|
52
|
+
...result,
|
|
53
|
+
data: LinkedObject.channel(result.data),
|
|
54
|
+
});
|
|
50
55
|
|
|
51
|
-
if (action !== 'onFetch')
|
|
56
|
+
if (action !== 'onFetch')
|
|
57
|
+
callback.onEvent?.(action, {
|
|
58
|
+
...result,
|
|
59
|
+
data: LinkedObject.channel(result.data),
|
|
60
|
+
});
|
|
52
61
|
|
|
53
|
-
callback[action]?.(
|
|
62
|
+
callback[action]?.({
|
|
63
|
+
...result,
|
|
64
|
+
data: LinkedObject.channel(result.data),
|
|
65
|
+
});
|
|
54
66
|
};
|
|
55
67
|
|
|
56
68
|
const disposers: Amity.Unsubscriber[] = [];
|
|
@@ -12,6 +12,7 @@ import {
|
|
|
12
12
|
onChannelMemberAdded,
|
|
13
13
|
onChannelMemberRemoved,
|
|
14
14
|
} from '../events';
|
|
15
|
+
import { LinkedObject } from '~/utils/linkedObject';
|
|
15
16
|
|
|
16
17
|
/**
|
|
17
18
|
* ```js
|
|
@@ -38,11 +39,14 @@ export const observeChannels = (
|
|
|
38
39
|
|
|
39
40
|
const disposers: Amity.Unsubscriber[] = [];
|
|
40
41
|
|
|
41
|
-
const router = (
|
|
42
|
-
|
|
42
|
+
const router = (
|
|
43
|
+
channel: Amity.InternalChannel,
|
|
44
|
+
action: Exclude<Amity.ChannelActionType, 'onFetch'>,
|
|
45
|
+
) => {
|
|
46
|
+
if (callback instanceof Function) return callback(LinkedObject.channel(channel));
|
|
43
47
|
|
|
44
|
-
callback.onEvent?.(action, channel);
|
|
45
|
-
callback[action]?.(channel);
|
|
48
|
+
callback.onEvent?.(action, LinkedObject.channel(channel));
|
|
49
|
+
callback[action]?.(LinkedObject.channel(channel));
|
|
46
50
|
};
|
|
47
51
|
|
|
48
52
|
disposers.push(
|
package/src/client/api/index.ts
CHANGED
package/src/client/api/logout.ts
CHANGED
|
@@ -6,8 +6,8 @@ import { setSessionState } from './setSessionState';
|
|
|
6
6
|
*/
|
|
7
7
|
/**
|
|
8
8
|
* ```js
|
|
9
|
-
* import {
|
|
10
|
-
* const success = await
|
|
9
|
+
* import { Client } from '@amityco/ts-sdk-react-native';
|
|
10
|
+
* const success = await Client.logout()
|
|
11
11
|
* ```
|
|
12
12
|
*
|
|
13
13
|
* Disconnects an {@link Amity.Client} instance from ASC servers
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { getActiveClient } from '~/client/api/activeClient';
|
|
2
|
+
import { logout } from './logout';
|
|
3
|
+
|
|
4
|
+
/* begin_public_function
|
|
5
|
+
id: client.secureLogout
|
|
6
|
+
*/
|
|
7
|
+
/**
|
|
8
|
+
* ```js
|
|
9
|
+
* import { Client } from '@amityco/ts-sdk'
|
|
10
|
+
* const success = await Client.secureLogout()
|
|
11
|
+
* ```
|
|
12
|
+
*
|
|
13
|
+
* Revoke access token for current user and disconnects an {@link Amity.Client} instance from ASC servers
|
|
14
|
+
*
|
|
15
|
+
* @returns a success boolean if disconnected
|
|
16
|
+
*
|
|
17
|
+
* @category Client API
|
|
18
|
+
* @async
|
|
19
|
+
*/
|
|
20
|
+
export const secureLogout = async (): Promise<boolean> => {
|
|
21
|
+
const client = getActiveClient();
|
|
22
|
+
const {
|
|
23
|
+
data: { success },
|
|
24
|
+
} = await client.http.delete<{ success: boolean }>('/api/v4/sessions');
|
|
25
|
+
|
|
26
|
+
if (!success) {
|
|
27
|
+
throw new Error('Failed to logout');
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
const result = await logout();
|
|
31
|
+
return result;
|
|
32
|
+
};
|
|
33
|
+
/* end_public_function */
|
|
@@ -11,7 +11,7 @@ import { isNonNullable } from '~/utils';
|
|
|
11
11
|
function hasPermission(
|
|
12
12
|
member: Amity.Membership<'community'>,
|
|
13
13
|
payload: {
|
|
14
|
-
|
|
14
|
+
communityUsers: Amity.Membership<'community'>[];
|
|
15
15
|
},
|
|
16
16
|
permission: string,
|
|
17
17
|
) {
|
|
@@ -20,7 +20,7 @@ function hasPermission(
|
|
|
20
20
|
}
|
|
21
21
|
|
|
22
22
|
return payload
|
|
23
|
-
.
|
|
23
|
+
.communityUsers!.find(user => user.userId === member.userId)!
|
|
24
24
|
.permissions.some(x => x === permission);
|
|
25
25
|
}
|
|
26
26
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { convertGetterPropsToStatic } from '~/utils/object';
|
|
1
|
+
import { convertGetterPropsToStatic, removeFunctionProperties } from '~/utils/object';
|
|
2
2
|
import { isEqual } from '~/utils/isEqual';
|
|
3
3
|
import { PaginationController } from './PaginationController';
|
|
4
4
|
import { PaginationNoPageController } from './PaginationNoPageController';
|
|
@@ -129,9 +129,10 @@ export abstract class LiveCollectionController<
|
|
|
129
129
|
abstract notifyChange(params: Amity.LiveCollectionNotifyParams): void;
|
|
130
130
|
|
|
131
131
|
protected shouldNotify(data: TPublicPayload[]) {
|
|
132
|
-
|
|
132
|
+
const newData = data.map(convertGetterPropsToStatic).map(removeFunctionProperties);
|
|
133
|
+
if (isEqual(this.snapshot, newData)) return false;
|
|
133
134
|
|
|
134
|
-
this.snapshot =
|
|
135
|
+
this.snapshot = newData as TPublicPayload[];
|
|
135
136
|
return true;
|
|
136
137
|
}
|
|
137
138
|
|
|
@@ -2,7 +2,11 @@ import { pullFromCache } from '~/cache/api';
|
|
|
2
2
|
import { getChannelMessagePreview } from './getChannelMessagePreview';
|
|
3
3
|
import { LinkedObject } from '~/utils/linkedObject';
|
|
4
4
|
|
|
5
|
-
export const getChannelMessagePreviewWithUser = (
|
|
5
|
+
export const getChannelMessagePreviewWithUser = (
|
|
6
|
+
channel: Amity.InternalChannel,
|
|
7
|
+
): Amity.InternalChannel & {
|
|
8
|
+
messagePreview: Amity.MessagePreview | null;
|
|
9
|
+
} => {
|
|
6
10
|
const messagePreview = channel.messagePreviewId
|
|
7
11
|
? getChannelMessagePreview(channel.channelId)
|
|
8
12
|
: null;
|
|
@@ -4,6 +4,8 @@ import { ingestInCache } from '~/cache/api/ingestInCache';
|
|
|
4
4
|
import { prepareMessagePayload } from '../utils';
|
|
5
5
|
import { updateSubChannelUnreadFromMessage } from '~/marker/utils/updateSubChannelUnreadFromMessage';
|
|
6
6
|
import { reCalculateChannelUnreadInfo } from '~/marker/utils/reCalculateChannelUnreadInfo';
|
|
7
|
+
import { markReadMessage } from '../utils/markReadMessage';
|
|
8
|
+
import { getActiveUser } from '~/client/api/activeUser';
|
|
7
9
|
|
|
8
10
|
/**
|
|
9
11
|
* ```js
|
|
@@ -25,6 +27,7 @@ export const onMessageCreatedMqtt = (
|
|
|
25
27
|
callback: Amity.Listener<Amity.InternalMessage>,
|
|
26
28
|
): Amity.Unsubscriber => {
|
|
27
29
|
const client = getActiveClient();
|
|
30
|
+
const user = getActiveUser();
|
|
28
31
|
|
|
29
32
|
const filter = async (rawPayload: Amity.MessagePayload) => {
|
|
30
33
|
const payload = await prepareMessagePayload(rawPayload);
|
|
@@ -41,6 +44,7 @@ export const onMessageCreatedMqtt = (
|
|
|
41
44
|
ingestInCache(payload);
|
|
42
45
|
|
|
43
46
|
payload.messages.forEach(message => {
|
|
47
|
+
if (message.creatorPrivateId === user._id) markReadMessage(message);
|
|
44
48
|
callback(message);
|
|
45
49
|
});
|
|
46
50
|
};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import ReadReceiptSyncEngine from '~/client/utils/ReadReceiptSync/readReceiptSyncEngine';
|
|
2
|
+
|
|
3
|
+
export const markReadMessage = (message: Amity.InternalMessage) => {
|
|
4
|
+
const { subChannelId, channelSegment } = message;
|
|
5
|
+
const markReadReceiptEngine = ReadReceiptSyncEngine.getInstance();
|
|
6
|
+
|
|
7
|
+
markReadReceiptEngine.markRead(subChannelId, channelSegment);
|
|
8
|
+
};
|
|
@@ -26,7 +26,7 @@ import { LinkedObject } from '~/utils/linkedObject';
|
|
|
26
26
|
* @category Post API
|
|
27
27
|
* @async
|
|
28
28
|
*/
|
|
29
|
-
export const createPost = async <T extends Amity.PostContentType>(
|
|
29
|
+
export const createPost = async <T extends Amity.PostContentType | string>(
|
|
30
30
|
bundle: Pick<Amity.Post<T>, 'targetType' | 'targetId'> &
|
|
31
31
|
Partial<Pick<Amity.Post<T>, 'metadata' | 'mentionees' | 'tags'>> & {
|
|
32
32
|
dataType?: T;
|
|
@@ -37,7 +37,6 @@ export const createPost = async <T extends Amity.PostContentType>(
|
|
|
37
37
|
const client = getActiveClient();
|
|
38
38
|
client.log('post/createPost', bundle);
|
|
39
39
|
|
|
40
|
-
// API-FIX: backend rejects that we pass the dataType manually T_T
|
|
41
40
|
if (!bundle.dataType || ['text', 'image', 'file', 'video'].includes(bundle.dataType)) {
|
|
42
41
|
// eslint-disable-next-line no-param-reassign
|
|
43
42
|
delete bundle.dataType;
|
|
@@ -135,10 +135,12 @@ export const getSubChannel = (
|
|
|
135
135
|
updateSubChannelCache(message.subChannelId, subChannel, {
|
|
136
136
|
messagePreviewId: message.messageId,
|
|
137
137
|
});
|
|
138
|
+
};
|
|
138
139
|
|
|
140
|
+
return onMessageCreatedMqtt(async (message: Amity.InternalMessage) => {
|
|
141
|
+
await updateMessagePreview(message);
|
|
139
142
|
callback(message);
|
|
140
|
-
};
|
|
141
|
-
return onMessageCreatedMqtt(updateMessagePreview);
|
|
143
|
+
});
|
|
142
144
|
},
|
|
143
145
|
'subChannelId',
|
|
144
146
|
'subChannel',
|
|
@@ -163,10 +165,12 @@ export const getSubChannel = (
|
|
|
163
165
|
updateSubChannelCache(message.subChannelId, subChannel, {
|
|
164
166
|
messagePreviewId: message.messageId,
|
|
165
167
|
});
|
|
168
|
+
};
|
|
166
169
|
|
|
170
|
+
return onMessageCreatedLocal(async (message: Amity.InternalMessage) => {
|
|
171
|
+
await updateMessagePreview(message);
|
|
167
172
|
callback(message);
|
|
168
|
-
};
|
|
169
|
-
return onMessageCreatedLocal(updateMessagePreview);
|
|
173
|
+
});
|
|
170
174
|
},
|
|
171
175
|
'subChannelId',
|
|
172
176
|
'subChannel',
|
package/src/subChannelRepository/observers/getSubChannels/SubChannelLiveCollectionController.ts
CHANGED
|
@@ -119,6 +119,14 @@ export class SubChannelLiveCollectionController extends LiveCollectionController
|
|
|
119
119
|
},
|
|
120
120
|
{
|
|
121
121
|
fn: callback => {
|
|
122
|
+
const updateMessagePreview = async (message: Amity.InternalMessage) => {
|
|
123
|
+
const client = getActiveClient();
|
|
124
|
+
const messagePreviewSetting = await client.getMessagePreviewSetting(false);
|
|
125
|
+
|
|
126
|
+
if (messagePreviewSetting === Amity.MessagePreviewSetting.NO_MESSAGE_PREVIEW) return;
|
|
127
|
+
|
|
128
|
+
handleMessageCreated(message);
|
|
129
|
+
};
|
|
122
130
|
return onMessageCreatedMqtt(async message => {
|
|
123
131
|
const cacheData = pullFromCache<Amity.SubChannel>([
|
|
124
132
|
'subChannel',
|
|
@@ -134,12 +142,7 @@ export class SubChannelLiveCollectionController extends LiveCollectionController
|
|
|
134
142
|
|
|
135
143
|
if (!collection || !collection.data.includes(message.subChannelId)) return;
|
|
136
144
|
|
|
137
|
-
|
|
138
|
-
const messagePreviewSetting = await client.getMessagePreviewSetting(false);
|
|
139
|
-
|
|
140
|
-
if (messagePreviewSetting === Amity.MessagePreviewSetting.NO_MESSAGE_PREVIEW) return;
|
|
141
|
-
|
|
142
|
-
handleMessageCreated(message);
|
|
145
|
+
await updateMessagePreview(message);
|
|
143
146
|
|
|
144
147
|
const subChannelCache = pullFromCache<Amity.SubChannel>([
|
|
145
148
|
'subChannel',
|
|
@@ -6,6 +6,7 @@ import { postLinkedObject } from './postLinkedObject';
|
|
|
6
6
|
import { messageLinkedObject } from './messageLinkedObject';
|
|
7
7
|
import { storyTargetLinkedObject } from './storyTargetLinkedObject';
|
|
8
8
|
import { reactorLinkedObject } from './reactorLinkedObject';
|
|
9
|
+
import { channelLinkedObject } from './channelLinkedObject';
|
|
9
10
|
|
|
10
11
|
export const LinkedObject = {
|
|
11
12
|
comment: commentLinkedObject,
|
|
@@ -16,4 +17,5 @@ export const LinkedObject = {
|
|
|
16
17
|
storyTarget: storyTargetLinkedObject,
|
|
17
18
|
message: messageLinkedObject,
|
|
18
19
|
reactor: reactorLinkedObject,
|
|
20
|
+
channel: channelLinkedObject,
|
|
19
21
|
};
|