@amityco/ts-sdk 7.5.4-ec2fdd4.0 → 7.6.1-65b44ce1.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 +3 -0
- package/dist/@types/domains/channel.d.ts.map +1 -1
- package/dist/@types/domains/group.d.ts +2 -0
- package/dist/@types/domains/group.d.ts.map +1 -1
- package/dist/@types/domains/post.d.ts +3 -0
- package/dist/@types/domains/post.d.ts.map +1 -1
- package/dist/@types/domains/stream.d.ts +4 -0
- package/dist/@types/domains/stream.d.ts.map +1 -1
- package/dist/channelRepository/api/createChannel.d.ts +3 -1
- package/dist/channelRepository/api/createChannel.d.ts.map +1 -1
- package/dist/channelRepository/channelMembership/observers/getMembers/ChannelMemberLiveCollectionController.d.ts.map +1 -1
- package/dist/channelRepository/channelMembership/observers/searchMembers/SearchChannelMemberLiveCollectionController.d.ts.map +1 -1
- package/dist/channelRepository/channelMembership/observers/searchMembers/SearchChannelMemberQueryStreamController.d.ts +2 -2
- package/dist/channelRepository/channelMembership/observers/searchMembers/SearchChannelMemberQueryStreamController.d.ts.map +1 -1
- package/dist/channelRepository/internalApi/getChannel.d.ts.map +1 -1
- package/dist/index.cjs.js +5921 -5734
- package/dist/index.esm.js +5758 -5571
- package/dist/index.umd.js +3 -3
- package/dist/messagePreview/utils/getChannelMessagePreviewWithUser.d.ts +2 -0
- package/dist/messagePreview/utils/getChannelMessagePreviewWithUser.d.ts.map +1 -1
- package/dist/messageRepository/api/deleteMessage.d.ts.map +1 -1
- package/dist/messageRepository/observers/getMessages/MessageQueryStreamController.d.ts.map +1 -1
- package/dist/postRepository/api/createPost.d.ts.map +1 -1
- package/dist/postRepository/utils/payload.d.ts.map +1 -1
- package/dist/streamRepository/api/createStream.d.ts +1 -1
- package/dist/streamRepository/api/createStream.d.ts.map +1 -1
- package/dist/streamRepository/api/editStream.d.ts +18 -0
- package/dist/streamRepository/api/editStream.d.ts.map +1 -0
- package/dist/streamRepository/api/index.d.ts +1 -0
- package/dist/streamRepository/api/index.d.ts.map +1 -1
- package/dist/streamRepository/api/updateStream.d.ts +4 -1
- package/dist/streamRepository/api/updateStream.d.ts.map +1 -1
- package/dist/streamRepository/internalApi/getLiveChat.d.ts +16 -0
- package/dist/streamRepository/internalApi/getLiveChat.d.ts.map +1 -0
- package/dist/streamRepository/internalApi/getStream.d.ts +2 -2
- package/dist/streamRepository/internalApi/getStream.d.ts.map +1 -1
- package/dist/utils/linkedObject/channelLinkedObject.d.ts.map +1 -1
- package/dist/utils/linkedObject/channelMemberLinkedObject.d.ts +2 -0
- package/dist/utils/linkedObject/channelMemberLinkedObject.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/postLinkedObject.d.ts.map +1 -1
- package/dist/utils/linkedObject/streamLinkedObject.d.ts.map +1 -1
- package/dist/utils/postTypePredicate.d.ts +5 -3
- package/dist/utils/postTypePredicate.d.ts.map +1 -1
- package/dist/utils/tests/dummy/community.d.ts +2 -0
- package/dist/utils/tests/dummy/community.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/@types/domains/channel.ts +4 -0
- package/src/@types/domains/group.ts +2 -0
- package/src/@types/domains/post.ts +3 -0
- package/src/@types/domains/stream.ts +4 -0
- package/src/channelRepository/api/createChannel.ts +12 -9
- package/src/channelRepository/channelMembership/observers/getMembers/ChannelMemberLiveCollectionController.ts +3 -1
- package/src/channelRepository/channelMembership/observers/searchMembers/SearchChannelMemberLiveCollectionController.ts +2 -1
- package/src/channelRepository/channelMembership/observers/searchMembers/SearchChannelMemberQueryStreamController.ts +2 -2
- package/src/channelRepository/internalApi/getChannel.ts +0 -1
- package/src/channelRepository/utils/constructChannelObject.ts +2 -2
- package/src/messageRepository/api/deleteMessage.ts +16 -0
- package/src/messageRepository/observers/getMessages/MessageQueryStreamController.ts +13 -0
- package/src/postRepository/api/createPost.ts +3 -2
- package/src/postRepository/utils/payload.ts +37 -1
- package/src/streamRepository/api/createStream.ts +4 -1
- package/src/streamRepository/api/editStream.ts +51 -0
- package/src/streamRepository/api/index.ts +1 -0
- package/src/streamRepository/api/updateStream.ts +8 -1
- package/src/streamRepository/internalApi/getLiveChat.ts +59 -0
- package/src/streamRepository/internalApi/getStream.ts +3 -3
- package/src/streamRepository/observers/getStreams/GetStreamsLiveCollectionController.ts +1 -1
- package/src/utils/linkedObject/channelLinkedObject.ts +19 -0
- package/src/utils/linkedObject/channelMemberLinkedObject.ts +20 -0
- package/src/utils/linkedObject/index.ts +2 -0
- package/src/utils/linkedObject/postLinkedObject.ts +32 -2
- package/src/utils/linkedObject/streamLinkedObject.ts +2 -0
- package/src/utils/postTypePredicate.ts +26 -3
|
@@ -21,6 +21,8 @@ export declare const getChannelMessagePreviewWithUser: (channel: Amity.StaticInt
|
|
|
21
21
|
messagePreviewId?: string | undefined;
|
|
22
22
|
isPublic?: boolean | undefined;
|
|
23
23
|
lastActivity: string;
|
|
24
|
+
attachedToPostId?: string | undefined;
|
|
25
|
+
attachedToVideoStreamId?: string | undefined;
|
|
24
26
|
} & Amity.Metadata & Amity.Taggable & Amity.CreatedAt & Amity.UpdatedAt & Amity.DeletedAt & {
|
|
25
27
|
isDeleted?: boolean | undefined;
|
|
26
28
|
} & Amity.Subscribable & {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getChannelMessagePreviewWithUser.d.ts","sourceRoot":"","sources":["../../../src/messagePreview/utils/getChannelMessagePreviewWithUser.ts"],"names":[],"mappings":"AAIA,eAAO,MAAM,gCAAgC,YAClC,MAAM,qBAAqB
|
|
1
|
+
{"version":3,"file":"getChannelMessagePreviewWithUser.d.ts","sourceRoot":"","sources":["../../../src/messagePreview/utils/getChannelMessagePreviewWithUser.ts"],"names":[],"mappings":"AAIA,eAAO,MAAM,gCAAgC,YAClC,MAAM,qBAAqB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;oBAEpB,MAAM,cAAc,GAAG,IAAI;CAoB5C,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"deleteMessage.d.ts","sourceRoot":"","sources":["../../../src/messageRepository/api/deleteMessage.ts"],"names":[],"mappings":"AAKA;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,aAAa;gBACb,MAAM,OAAO,CAAC,WAAW,CAAC,GACpC,QAAQ,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"deleteMessage.d.ts","sourceRoot":"","sources":["../../../src/messageRepository/api/deleteMessage.ts"],"names":[],"mappings":"AAKA;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,aAAa;gBACb,MAAM,OAAO,CAAC,WAAW,CAAC,GACpC,QAAQ,MAAM,OAAO,CAAC;IAiCzB;;;;;;;;;;;;OAYG;8BAEU,MAAM,OAAO,CAAC,WAAW,CAAC,GACpC,MAAM,MAAM,CAAC,MAAM,OAAO,CAAC,GAAG,SAAS;CAjBzC,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MessageQueryStreamController.d.ts","sourceRoot":"","sources":["../../../../src/messageRepository/observers/getMessages/MessageQueryStreamController.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,qBAAqB,EAAE,MAAM,6CAA6C,CAAC;AAIpF,OAAO,EAAE,2BAA2B,EAAE,MAAM,+BAA+B,CAAC;AAG5E,qBAAa,4BAA6B,SAAQ,qBAAqB,CACrE,KAAK,CAAC,cAAc,EACpB,KAAK,CAAC,sBAAsB,CAC7B;IACC,OAAO,CAAC,YAAY,CAAqD;IAEzE,OAAO,CAAC,cAAc,CAEsB;IAE5C,OAAO,CAAC,oBAAoB,CAA8B;gBAGxD,KAAK,EAAE,KAAK,CAAC,sBAAsB,EACnC,QAAQ,EAAE,MAAM,EAAE,EAClB,YAAY,EAAE,CAAC,MAAM,EAAE,KAAK,CAAC,0BAA0B,KAAK,IAAI,EAChE,cAAc,EAAE,CAAC,QAAQ,EAAE,KAAK,CAAC,cAAc,KAAK,OAAO,CAAC,KAAK,CAAC,uBAAuB,CAAC,EAC1F,oBAAoB,EAAE,2BAA2B;IAS7C,YAAY,CAAC,QAAQ,EAAE,KAAK,CAAC,cAAc;IAWjD,mBAAmB,CACjB,QAAQ,EAAE,KAAK,CAAC,cAAc,GAAG,OAAO,CAAC,KAAK,CAAC,UAAU,CAAC,EAC1D,SAAS,EAAE,KAAK,CAAC,2BAA2B,EAC5C,OAAO,UAAQ;IAsBjB,OAAO,CAAC,MAAM,EAAE,MAAM,aACH,MAAM,eAAe;
|
|
1
|
+
{"version":3,"file":"MessageQueryStreamController.d.ts","sourceRoot":"","sources":["../../../../src/messageRepository/observers/getMessages/MessageQueryStreamController.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,qBAAqB,EAAE,MAAM,6CAA6C,CAAC;AAIpF,OAAO,EAAE,2BAA2B,EAAE,MAAM,+BAA+B,CAAC;AAG5E,qBAAa,4BAA6B,SAAQ,qBAAqB,CACrE,KAAK,CAAC,cAAc,EACpB,KAAK,CAAC,sBAAsB,CAC7B;IACC,OAAO,CAAC,YAAY,CAAqD;IAEzE,OAAO,CAAC,cAAc,CAEsB;IAE5C,OAAO,CAAC,oBAAoB,CAA8B;gBAGxD,KAAK,EAAE,KAAK,CAAC,sBAAsB,EACnC,QAAQ,EAAE,MAAM,EAAE,EAClB,YAAY,EAAE,CAAC,MAAM,EAAE,KAAK,CAAC,0BAA0B,KAAK,IAAI,EAChE,cAAc,EAAE,CAAC,QAAQ,EAAE,KAAK,CAAC,cAAc,KAAK,OAAO,CAAC,KAAK,CAAC,uBAAuB,CAAC,EAC1F,oBAAoB,EAAE,2BAA2B;IAS7C,YAAY,CAAC,QAAQ,EAAE,KAAK,CAAC,cAAc;IAWjD,mBAAmB,CACjB,QAAQ,EAAE,KAAK,CAAC,cAAc,GAAG,OAAO,CAAC,KAAK,CAAC,UAAU,CAAC,EAC1D,SAAS,EAAE,KAAK,CAAC,2BAA2B,EAC5C,OAAO,UAAQ;IAsBjB,OAAO,CAAC,MAAM,EAAE,MAAM,aACH,MAAM,eAAe;IAgExC,YAAY,CACV,gBAAgB,EAAE;QAChB,EAAE,EAAE,CAAC,OAAO,EAAE,KAAK,CAAC,QAAQ,CAAC,KAAK,CAAC,eAAe,CAAC,KAAK,KAAK,CAAC,YAAY,CAAC;QAC3E,MAAM,EAAE,MAAM,CAAC;KAChB,EAAE;CAIN"}
|
|
@@ -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,CAyBlC,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"payload.d.ts","sourceRoot":"","sources":["../../../src/postRepository/utils/payload.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"payload.d.ts","sourceRoot":"","sources":["../../../src/postRepository/utils/payload.ts"],"names":[],"mappings":"AAuBA,eAAO,MAAM,kBAAkB,YAAa,MAAM,WAAW,KAAG,MAAM,oBAuDrE,CAAC;AAEF,eAAO,MAAM,gCAAgC,4CAI1C,MAAM,yBAAyB,KAAG,MAAM,kCAO1C,CAAC"}
|
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
* @category Stream API
|
|
13
13
|
* @async
|
|
14
14
|
*/
|
|
15
|
-
export declare const createStream: (bundle: Pick<Amity.InternalStream, 'title' | 'thumbnailFileId' | 'description'> & {
|
|
15
|
+
export declare const createStream: (bundle: Pick<Amity.InternalStream, 'title' | 'thumbnailFileId' | 'description' | 'channelEnabled'> & {
|
|
16
16
|
isSecure?: boolean;
|
|
17
17
|
}) => Promise<Amity.Cached<Amity.Stream>>;
|
|
18
18
|
//# sourceMappingURL=createStream.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createStream.d.ts","sourceRoot":"","sources":["../../../src/streamRepository/api/createStream.ts"],"names":[],"mappings":"AAQA;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,YAAY,WACf,
|
|
1
|
+
{"version":3,"file":"createStream.d.ts","sourceRoot":"","sources":["../../../src/streamRepository/api/createStream.ts"],"names":[],"mappings":"AAQA;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,YAAY,WACf,KACN,MAAM,cAAc,EACpB,OAAO,GAAG,iBAAiB,GAAG,aAAa,GAAG,gBAAgB,CAC/D,GAAG;IACF,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB,KACA,QAAQ,MAAM,MAAM,CAAC,MAAM,MAAM,CAAC,CAepC,CAAC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
*
|
|
3
|
+
* ```js
|
|
4
|
+
* import { StreamRepository } from '@amityco/ts-sdk'
|
|
5
|
+
* const updated = await StreamRepository.editStream(streamId, { title: 'foobar' })
|
|
6
|
+
* ```
|
|
7
|
+
*
|
|
8
|
+
* Updates an {@link Amity.Stream}
|
|
9
|
+
*
|
|
10
|
+
* @param streamId The ID of the {@link Amity.Stream} to edit
|
|
11
|
+
* @param patch The patch data to apply
|
|
12
|
+
* @returns the updated {@link Amity.Stream} object
|
|
13
|
+
*
|
|
14
|
+
* @category Stream API
|
|
15
|
+
* @async
|
|
16
|
+
*/
|
|
17
|
+
export declare const editStream: (streamId: Amity.Stream['streamId'], patch: Patch<Amity.Stream, 'title' | 'thumbnailFileId' | 'description' | 'metadata' | 'channelEnabled'>) => Promise<Amity.Cached<Amity.Stream>>;
|
|
18
|
+
//# sourceMappingURL=editStream.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"editStream.d.ts","sourceRoot":"","sources":["../../../src/streamRepository/api/editStream.ts"],"names":[],"mappings":"AAQA;;;;;;;;;;;;;;;GAeG;AAEH,eAAO,MAAM,UAAU,aACX,MAAM,MAAM,CAAC,UAAU,CAAC,SAC3B,MACL,MAAM,MAAM,EACZ,OAAO,GAAG,iBAAiB,GAAG,aAAa,GAAG,UAAU,GAAG,gBAAgB,CAC5E,KACA,QAAQ,MAAM,MAAM,CAAC,MAAM,MAAM,CAAC,CAkBpC,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/streamRepository/api/index.ts"],"names":[],"mappings":"AAAA,cAAc,gBAAgB,CAAC;AAC/B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,iBAAiB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/streamRepository/api/index.ts"],"names":[],"mappings":"AAAA,cAAc,gBAAgB,CAAC;AAC/B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,iBAAiB,CAAC;AAChC,cAAc,cAAc,CAAC"}
|
|
@@ -1,4 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
|
+
* @deprecated this function is deprecated,
|
|
3
|
+
* please use {@link Amity.StreamRepository.editStream} instead.
|
|
4
|
+
*
|
|
2
5
|
* ```js
|
|
3
6
|
* import { updateStream } from '@amityco/ts-sdk'
|
|
4
7
|
* const updated = await updateStream(streamId, { title: 'foobar' })
|
|
@@ -13,5 +16,5 @@
|
|
|
13
16
|
* @category Stream API
|
|
14
17
|
* @async
|
|
15
18
|
*/
|
|
16
|
-
export declare const updateStream: (streamId: Amity.Stream['streamId'], patch: Patch<Amity.Stream, 'title' | 'thumbnailFileId' | 'description' | 'metadata'>) => Promise<Amity.Cached<Amity.Stream>>;
|
|
19
|
+
export declare const updateStream: (streamId: Amity.Stream['streamId'], patch: Patch<Amity.Stream, 'title' | 'thumbnailFileId' | 'description' | 'metadata' | 'channelEnabled'>) => Promise<Amity.Cached<Amity.Stream>>;
|
|
17
20
|
//# sourceMappingURL=updateStream.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"updateStream.d.ts","sourceRoot":"","sources":["../../../src/streamRepository/api/updateStream.ts"],"names":[],"mappings":"AAQA
|
|
1
|
+
{"version":3,"file":"updateStream.d.ts","sourceRoot":"","sources":["../../../src/streamRepository/api/updateStream.ts"],"names":[],"mappings":"AAQA;;;;;;;;;;;;;;;;;GAiBG;AAEH,eAAO,MAAM,YAAY,aACb,MAAM,MAAM,CAAC,UAAU,CAAC,SAC3B,MACL,MAAM,MAAM,EACZ,OAAO,GAAG,iBAAiB,GAAG,aAAa,GAAG,UAAU,GAAG,gBAAgB,CAC5E,KACA,QAAQ,MAAM,MAAM,CAAC,MAAM,MAAM,CAAC,CAkBpC,CAAC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ```js
|
|
3
|
+
* import { getStream } from '@amityco/ts-sdk'
|
|
4
|
+
* const stream = await getStream('foobar')
|
|
5
|
+
* ```
|
|
6
|
+
*
|
|
7
|
+
* Fetches a {@link Amity.Channel} object linked with a current stream
|
|
8
|
+
*
|
|
9
|
+
* @param stream {@link Amity.Stream} that has linked live channel
|
|
10
|
+
* @returns the associated {@link Amity.Channel<'live'>} object
|
|
11
|
+
*
|
|
12
|
+
* @category Stream API
|
|
13
|
+
* @async
|
|
14
|
+
*/
|
|
15
|
+
export declare const getLiveChat: (stream: Amity.InternalStream) => Promise<Amity.Channel<'live'> | undefined>;
|
|
16
|
+
//# sourceMappingURL=getLiveChat.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getLiveChat.d.ts","sourceRoot":"","sources":["../../../src/streamRepository/internalApi/getLiveChat.ts"],"names":[],"mappings":"AAOA;;;;;;;;;;;;;GAaG;AAEH,eAAO,MAAM,WAAW,WACd,MAAM,cAAc,KAC3B,QAAQ,MAAM,OAAO,CAAC,MAAM,CAAC,GAAG,SAAS,CAkC3C,CAAC"}
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
* @async
|
|
14
14
|
*/
|
|
15
15
|
export declare const getStream: {
|
|
16
|
-
(streamId: Amity.Stream['streamId']): Promise<Amity.Cached<Amity.
|
|
16
|
+
(streamId: Amity.Stream['streamId']): Promise<Amity.Cached<Amity.InternalStream>>;
|
|
17
17
|
/**
|
|
18
18
|
* ```js
|
|
19
19
|
* import { getStream } from '@amityco/ts-sdk'
|
|
@@ -27,6 +27,6 @@ export declare const getStream: {
|
|
|
27
27
|
*
|
|
28
28
|
* @category Stream API
|
|
29
29
|
*/
|
|
30
|
-
locally(streamId: Amity.Stream['streamId']): Amity.Cached<Amity.
|
|
30
|
+
locally(streamId: Amity.Stream['streamId']): Amity.Cached<Amity.InternalStream> | undefined;
|
|
31
31
|
};
|
|
32
32
|
//# sourceMappingURL=getStream.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getStream.d.ts","sourceRoot":"","sources":["../../../src/streamRepository/internalApi/getStream.ts"],"names":[],"mappings":"AAQA;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,SAAS;eACV,MAAM,MAAM,CAAC,UAAU,CAAC,GACjC,QAAQ,MAAM,MAAM,CAAC,MAAM,
|
|
1
|
+
{"version":3,"file":"getStream.d.ts","sourceRoot":"","sources":["../../../src/streamRepository/internalApi/getStream.ts"],"names":[],"mappings":"AAQA;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,SAAS;eACV,MAAM,MAAM,CAAC,UAAU,CAAC,GACjC,QAAQ,MAAM,MAAM,CAAC,MAAM,cAAc,CAAC,CAAC;IAoB9C;;;;;;;;;;;;OAYG;sBAES,MAAM,MAAM,CAAC,UAAU,CAAC,GACjC,MAAM,MAAM,CAAC,MAAM,cAAc,CAAC,GAAG,SAAS;CAlBhD,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"channelLinkedObject.d.ts","sourceRoot":"","sources":["../../../src/utils/linkedObject/channelLinkedObject.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"channelLinkedObject.d.ts","sourceRoot":"","sources":["../../../src/utils/linkedObject/channelLinkedObject.ts"],"names":[],"mappings":"AAKA,eAAO,MAAM,mBAAmB,YAAa,MAAM,eAAe,KAAG,MAAM,OAqB1E,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"channelMemberLinkedObject.d.ts","sourceRoot":"","sources":["../../../src/utils/linkedObject/channelMemberLinkedObject.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,yBAAyB,kBACrB,MAAM,UAAU,CAAC,SAAS,CAAC,KACzC,MAAM,UAAU,CAAC,SAAS,CAc5B,CAAC"}
|
|
@@ -15,5 +15,6 @@ export declare const LinkedObject: {
|
|
|
15
15
|
community: (community: Amity.InternalCommunity) => Amity.Community;
|
|
16
16
|
invitation: (invitation: Amity.InternalInvitation) => Amity.Invitation;
|
|
17
17
|
joinRequest: (joinRequest: Amity.InternalJoinRequest) => Amity.JoinRequest;
|
|
18
|
+
channelMember: (channelMember: Amity.Membership<"channel">) => Amity.Membership<"channel">;
|
|
18
19
|
};
|
|
19
20
|
//# 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":"AAkBA,eAAO,MAAM,YAAY;;;;;;;;;;;;;;;;;;CAkBxB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"postLinkedObject.d.ts","sourceRoot":"","sources":["../../../src/utils/linkedObject/postLinkedObject.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"postLinkedObject.d.ts","sourceRoot":"","sources":["../../../src/utils/linkedObject/postLinkedObject.ts"],"names":[],"mappings":"AAcA,eAAO,MAAM,gBAAgB,SAAU,MAAM,YAAY,KAAG,MAAM,IAmFjE,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"streamLinkedObject.d.ts","sourceRoot":"","sources":["../../../src/utils/linkedObject/streamLinkedObject.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"streamLinkedObject.d.ts","sourceRoot":"","sources":["../../../src/utils/linkedObject/streamLinkedObject.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,kBAAkB,WAAY,MAAM,cAAc,KAAG,MAAM,MAoBvE,CAAC"}
|
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
export declare function isAmityImagePost(post
|
|
2
|
-
export declare function isAmityFilePost(post
|
|
3
|
-
export declare function isAmityVideoPost(post
|
|
1
|
+
export declare function isAmityImagePost(post?: Amity.InternalPost): post is Amity.Post<'image'>;
|
|
2
|
+
export declare function isAmityFilePost(post?: Amity.InternalPost): post is Amity.Post<'file'>;
|
|
3
|
+
export declare function isAmityVideoPost(post?: Amity.InternalPost): post is Amity.Post<'video'>;
|
|
4
|
+
export declare function isAmityLivestreamPost(post?: Amity.InternalPost): post is Amity.Post<'liveStream'>;
|
|
5
|
+
export declare function isAmityPollPost(post?: Amity.InternalPost): post is Amity.Post<'poll'>;
|
|
4
6
|
//# sourceMappingURL=postTypePredicate.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"postTypePredicate.d.ts","sourceRoot":"","sources":["../../src/utils/postTypePredicate.ts"],"names":[],"mappings":"AAAA,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,KAAK,CAAC,YAAY,GAAG,IAAI,IAAI,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,
|
|
1
|
+
{"version":3,"file":"postTypePredicate.d.ts","sourceRoot":"","sources":["../../src/utils/postTypePredicate.ts"],"names":[],"mappings":"AAAA,wBAAgB,gBAAgB,CAAC,IAAI,CAAC,EAAE,KAAK,CAAC,YAAY,GAAG,IAAI,IAAI,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,CAQvF;AAED,wBAAgB,eAAe,CAAC,IAAI,CAAC,EAAE,KAAK,CAAC,YAAY,GAAG,IAAI,IAAI,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,CAQrF;AAED,wBAAgB,gBAAgB,CAAC,IAAI,CAAC,EAAE,KAAK,CAAC,YAAY,GAAG,IAAI,IAAI,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,CASvF;AAED,wBAAgB,qBAAqB,CAAC,IAAI,CAAC,EAAE,KAAK,CAAC,YAAY,GAAG,IAAI,IAAI,KAAK,CAAC,IAAI,CAAC,YAAY,CAAC,CAQjG;AAED,wBAAgB,eAAe,CAAC,IAAI,CAAC,EAAE,KAAK,CAAC,YAAY,GAAG,IAAI,IAAI,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,CAQrF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"community.d.ts","sourceRoot":"","sources":["../../../../src/utils/tests/dummy/community.ts"],"names":[],"mappings":"AAqBA,eAAO,MAAM,aAAa,EAAE,KAAK,CAAC,SAajC,CAAC;AAEF,eAAO,MAAM,WAAW,EAAE,KAAK,CAAC,SAoB/B,CAAC;AAEF,eAAO,MAAM,WAAW,EAAE,KAAK,CAAC,SAI/B,CAAC;AAEF,eAAO,MAAM,eAAe,EAAE,KAAK,CAAC,aAAa,CAAC,WAAW,CAa5D,CAAC;AAEF,eAAO,MAAM,uBAAuB,+BAAuD,CAAC;AAE5F,eAAO,MAAM,eAAe,EAAE,KAAK,CAAC,aAAa,CAAC,WAAW,CAO5D,CAAC;AAEF,eAAO,MAAM,uBAAuB,+BAAuD,CAAC;AAE5F,eAAO,MAAM,eAAe,EAAE,KAAK,CAAC,aAAa,CAAC,WAAW,CAO5D,CAAC;AAEF,eAAO,MAAM,uBAAuB,+BAAuD,CAAC;AAE5F,eAAO,MAAM,eAAe,EAAE,KAAK,CAAC,aAAa,CAAC,WAAW,CAM5D,CAAC;AAEF,eAAO,MAAM,qBAAqB,+BAAuD,CAAC;AAE1F,eAAO,MAAM,eAAe,EAAE,KAAK,CAAC,aAAa,CAAC,WAAW,CAK5D,CAAC;AAEF,eAAO,MAAM,mBAAmB,+BAAuD,CAAC;AAExF,eAAO,MAAM,qBAAqB;;;;;;;CAOjC,CAAC;AAEF,eAAO,MAAM,gBAAgB,EAAE,KAAK,CAAC,gBAOpC,CAAC;AAEF,eAAO,MAAM,0BAA0B;;;;;;;;;;;;;CAUtC,CAAC;AAEF,eAAO,MAAM,+BAA+B;;;;;;;;;;;;;CAU3C,CAAC;AAEF,eAAO,MAAM,kBAAkB
|
|
1
|
+
{"version":3,"file":"community.d.ts","sourceRoot":"","sources":["../../../../src/utils/tests/dummy/community.ts"],"names":[],"mappings":"AAqBA,eAAO,MAAM,aAAa,EAAE,KAAK,CAAC,SAajC,CAAC;AAEF,eAAO,MAAM,WAAW,EAAE,KAAK,CAAC,SAoB/B,CAAC;AAEF,eAAO,MAAM,WAAW,EAAE,KAAK,CAAC,SAI/B,CAAC;AAEF,eAAO,MAAM,eAAe,EAAE,KAAK,CAAC,aAAa,CAAC,WAAW,CAa5D,CAAC;AAEF,eAAO,MAAM,uBAAuB,+BAAuD,CAAC;AAE5F,eAAO,MAAM,eAAe,EAAE,KAAK,CAAC,aAAa,CAAC,WAAW,CAO5D,CAAC;AAEF,eAAO,MAAM,uBAAuB,+BAAuD,CAAC;AAE5F,eAAO,MAAM,eAAe,EAAE,KAAK,CAAC,aAAa,CAAC,WAAW,CAO5D,CAAC;AAEF,eAAO,MAAM,uBAAuB,+BAAuD,CAAC;AAE5F,eAAO,MAAM,eAAe,EAAE,KAAK,CAAC,aAAa,CAAC,WAAW,CAM5D,CAAC;AAEF,eAAO,MAAM,qBAAqB,+BAAuD,CAAC;AAE1F,eAAO,MAAM,eAAe,EAAE,KAAK,CAAC,aAAa,CAAC,WAAW,CAK5D,CAAC;AAEF,eAAO,MAAM,mBAAmB,+BAAuD,CAAC;AAExF,eAAO,MAAM,qBAAqB;;;;;;;CAOjC,CAAC;AAEF,eAAO,MAAM,gBAAgB,EAAE,KAAK,CAAC,gBAOpC,CAAC;AAEF,eAAO,MAAM,0BAA0B;;;;;;;;;;;;;CAUtC,CAAC;AAEF,eAAO,MAAM,+BAA+B;;;;;;;;;;;;;CAU3C,CAAC;AAEF,eAAO,MAAM,kBAAkB;;;;;;;;;;;;;;;GAG9B,CAAC;AAEF,eAAO,MAAM,aAAa;;;;;;;;;;;;;;;;;;;;;;;CAuBzB,CAAC;AAEF,eAAO,MAAM,aAAa;;;;;;;;;;;;;;;;;;;;;;;CAuBzB,CAAC;AAEF,eAAO,MAAM,sBAAsB;;CAqBlC,CAAC;AAEF,eAAO,MAAM,2BAA2B;;CAqBvC,CAAC"}
|
package/package.json
CHANGED
|
@@ -61,6 +61,9 @@ declare global {
|
|
|
61
61
|
isPublic?: boolean;
|
|
62
62
|
|
|
63
63
|
lastActivity: Amity.timestamp;
|
|
64
|
+
|
|
65
|
+
attachedToPostId?: string;
|
|
66
|
+
attachedToVideoStreamId?: string;
|
|
64
67
|
} & Amity.Metadata &
|
|
65
68
|
Amity.Taggable &
|
|
66
69
|
Amity.Timestamps &
|
|
@@ -93,6 +96,7 @@ declare global {
|
|
|
93
96
|
type Channel<T extends ChannelType = any> = InternalChannel<T> & {
|
|
94
97
|
messagePreview?: Amity.MessagePreview | null;
|
|
95
98
|
markAsRead: () => Promise<boolean>;
|
|
99
|
+
previewMembers: Amity.Membership<'channel'>[];
|
|
96
100
|
};
|
|
97
101
|
|
|
98
102
|
type QueryChannels = {
|
|
@@ -15,6 +15,8 @@ declare global {
|
|
|
15
15
|
|
|
16
16
|
type Member<T extends Amity.GroupType> = {
|
|
17
17
|
userId: Amity.InternalUser['userId'];
|
|
18
|
+
userInternalId: Amity.InternalUser['userInternalId'];
|
|
19
|
+
userPublicId: Amity.InternalUser['userPublicId'];
|
|
18
20
|
} & (T extends 'channel'
|
|
19
21
|
? {
|
|
20
22
|
channelId: Amity.Channel['channelId'];
|
|
@@ -73,6 +73,7 @@ declare global {
|
|
|
73
73
|
};
|
|
74
74
|
|
|
75
75
|
type PostLinkObject = {
|
|
76
|
+
childrenPosts: Amity.Post[];
|
|
76
77
|
latestComments: (Amity.Comment | null)[];
|
|
77
78
|
creator: Amity.User | undefined;
|
|
78
79
|
analytics: {
|
|
@@ -82,6 +83,8 @@ declare global {
|
|
|
82
83
|
getVideoInfo: () => Amity.File<'video'> | undefined;
|
|
83
84
|
getVideoThumbnailInfo: () => Amity.File<'image'> | undefined;
|
|
84
85
|
getFileInfo: () => Amity.File<'file'> | undefined;
|
|
86
|
+
getPollInfo: () => Amity.Poll | undefined;
|
|
87
|
+
getLivestreamInfo: () => Amity.Stream | undefined;
|
|
85
88
|
};
|
|
86
89
|
|
|
87
90
|
type Post<T extends PostContentType = any> = Amity.InternalPost<T> & Amity.PostLinkObject;
|
|
@@ -73,6 +73,9 @@ declare global {
|
|
|
73
73
|
*/
|
|
74
74
|
targetId?: string; // communityId, userId, etc..
|
|
75
75
|
targetType?: string; // 'community', 'user', etc..
|
|
76
|
+
channelId?: string;
|
|
77
|
+
postId?: string;
|
|
78
|
+
channelEnabled?: boolean;
|
|
76
79
|
} & Amity.Metadata &
|
|
77
80
|
Amity.Timestamps &
|
|
78
81
|
Amity.SoftDelete;
|
|
@@ -81,6 +84,7 @@ declare global {
|
|
|
81
84
|
|
|
82
85
|
type StreamLinkedObject = {
|
|
83
86
|
moderation?: Amity.StreamModeration;
|
|
87
|
+
getLiveChat: () => Promise<Amity.Channel<'live'> | undefined>;
|
|
84
88
|
};
|
|
85
89
|
|
|
86
90
|
type Stream = Amity.InternalStream & Amity.StreamLinkedObject;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { getActiveClient } from '~/client/api';
|
|
1
|
+
import { getActiveClient } from '~/client/api/activeClient';
|
|
2
2
|
|
|
3
3
|
import { ingestInCache } from '~/cache/api/ingestInCache';
|
|
4
4
|
|
|
5
|
-
import { prepareChannelPayload } from '../utils';
|
|
6
|
-
import {
|
|
5
|
+
import { prepareChannelPayload } from '../utils/prepareChannelPayload';
|
|
6
|
+
import { constructChannelObject } from '../utils/constructChannelObject';
|
|
7
7
|
|
|
8
8
|
/* begin_public_function
|
|
9
9
|
id: channel.create
|
|
@@ -23,11 +23,14 @@ import { constructChannelDynamicValue } from '../utils/constructChannelDynamicVa
|
|
|
23
23
|
* @async
|
|
24
24
|
*/
|
|
25
25
|
export const createChannel = async <T extends Amity.ChannelType>(
|
|
26
|
-
bundle: {
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
26
|
+
bundle: {
|
|
27
|
+
type: T;
|
|
28
|
+
userIds?: Amity.InternalUser['userId'][];
|
|
29
|
+
// For live channel linked with a livestream post
|
|
30
|
+
videoStreamId?: string;
|
|
31
|
+
postId?: string;
|
|
32
|
+
} & Pick<Amity.Channel<T>, 'displayName' | 'avatarFileId' | 'tags' | 'metadata' | 'isPublic'>,
|
|
33
|
+
): Promise<Amity.Cached<Amity.Channel<T>>> => {
|
|
31
34
|
const client = getActiveClient();
|
|
32
35
|
client.log('user/createChannel', bundle);
|
|
33
36
|
|
|
@@ -53,7 +56,7 @@ export const createChannel = async <T extends Amity.ChannelType>(
|
|
|
53
56
|
|
|
54
57
|
const { channels } = data;
|
|
55
58
|
return {
|
|
56
|
-
data:
|
|
59
|
+
data: constructChannelObject(channels[0]),
|
|
57
60
|
cachedAt,
|
|
58
61
|
};
|
|
59
62
|
};
|
|
@@ -23,6 +23,7 @@ import {
|
|
|
23
23
|
} from '~/core/query';
|
|
24
24
|
import { prepareChannelPayload } from '~/channelRepository/utils';
|
|
25
25
|
import { onUserDeleted } from '~/channelRepository/events/onUserDeleted';
|
|
26
|
+
import { LinkedObject } from '~/utils/linkedObject';
|
|
26
27
|
|
|
27
28
|
export class ChannelMemberLiveCollectionController extends LiveCollectionController<
|
|
28
29
|
'channelUser',
|
|
@@ -100,7 +101,8 @@ export class ChannelMemberLiveCollectionController extends LiveCollectionControl
|
|
|
100
101
|
collection.data
|
|
101
102
|
.map(id => pullFromCache<Amity.Membership<'channel'>>(['channelUsers', 'get', id])!)
|
|
102
103
|
.filter(Boolean)
|
|
103
|
-
.map(({ data }) => data)
|
|
104
|
+
.map(({ data }) => data)
|
|
105
|
+
.map(LinkedObject.channelMember) ?? [],
|
|
104
106
|
);
|
|
105
107
|
|
|
106
108
|
if (!this.shouldNotify(data) && origin === 'event') return;
|
|
@@ -17,6 +17,7 @@ import {
|
|
|
17
17
|
import { filterByPropIntersection, filterBySearchTerm } from '~/core/query';
|
|
18
18
|
import { prepareChannelPayload } from '~/channelRepository/utils';
|
|
19
19
|
import { onUserDeleted } from '~/channelRepository/events/onUserDeleted';
|
|
20
|
+
import { LinkedObject } from '~/utils/linkedObject';
|
|
20
21
|
|
|
21
22
|
export class SearchChannelMemberLiveCollectionController extends LiveCollectionController<
|
|
22
23
|
'channelUser',
|
|
@@ -94,7 +95,7 @@ export class SearchChannelMemberLiveCollectionController extends LiveCollectionC
|
|
|
94
95
|
collection.data
|
|
95
96
|
.map(id => pullFromCache<Amity.Membership<'channel'>>(['channelUsers', 'get', id])!)
|
|
96
97
|
.filter(Boolean)
|
|
97
|
-
.map(({ data }) => data) ?? [],
|
|
98
|
+
.map(({ data }) => LinkedObject.channelMember(data) ?? []),
|
|
98
99
|
);
|
|
99
100
|
|
|
100
101
|
if (!this.shouldNotify(data) && origin === 'event') return;
|
|
@@ -72,7 +72,7 @@ export class SearchChannelMemberQueryStreamController extends QueryStreamControl
|
|
|
72
72
|
}
|
|
73
73
|
|
|
74
74
|
reactor(action: string) {
|
|
75
|
-
return (channel: Amity.
|
|
75
|
+
return (channel: Amity.StaticInternalChannel, channelMember: Amity.Membership<'channel'>) => {
|
|
76
76
|
if (this.query.channelId !== channelMember.channelId) return;
|
|
77
77
|
|
|
78
78
|
const collection = pullFromCache<Amity.ChannelMembersLiveCollectionCache>(
|
|
@@ -100,7 +100,7 @@ export class SearchChannelMemberQueryStreamController extends QueryStreamControl
|
|
|
100
100
|
createSubscriber: {
|
|
101
101
|
fn: (
|
|
102
102
|
reactor: (
|
|
103
|
-
channel: Amity.
|
|
103
|
+
channel: Amity.StaticInternalChannel,
|
|
104
104
|
channelMember: Amity.Membership<'channel'>,
|
|
105
105
|
) => void,
|
|
106
106
|
) => Amity.Unsubscriber;
|
|
@@ -9,7 +9,6 @@ import { pushToTombstone } from '~/cache/api/pushToTombstone';
|
|
|
9
9
|
|
|
10
10
|
import { prepareChannelPayload } from '../utils';
|
|
11
11
|
import { prepareUnreadCountInfo } from '../utils/prepareUnreadCountInfo';
|
|
12
|
-
import { constructChannelDynamicValue } from '../utils/constructChannelDynamicValue';
|
|
13
12
|
|
|
14
13
|
/**
|
|
15
14
|
* ```js
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { getChannelMessagePreviewWithUser } from '~/messagePreview/utils';
|
|
2
2
|
import { constructChannelDynamicValue } from './constructChannelDynamicValue';
|
|
3
|
-
import {
|
|
3
|
+
import { channelLinkedObject } from '~/utils/linkedObject/channelLinkedObject';
|
|
4
4
|
|
|
5
5
|
export const constructChannelObject = (channel: Amity.StaticInternalChannel): Amity.Channel => {
|
|
6
6
|
/**
|
|
@@ -10,7 +10,7 @@ export const constructChannelObject = (channel: Amity.StaticInternalChannel): Am
|
|
|
10
10
|
* 3. [LinkedObject.channel] add markAsRead >> Amity.InternalChannel -> Amity.Channel
|
|
11
11
|
*/
|
|
12
12
|
|
|
13
|
-
return
|
|
13
|
+
return channelLinkedObject(
|
|
14
14
|
constructChannelDynamicValue(getChannelMessagePreviewWithUser(channel)),
|
|
15
15
|
);
|
|
16
16
|
};
|
|
@@ -23,6 +23,22 @@ export const deleteMessage = async (
|
|
|
23
23
|
const client = getActiveClient();
|
|
24
24
|
client.log('message/deleteMessage', messageId);
|
|
25
25
|
|
|
26
|
+
if (messageId.includes('LOCAL_')) {
|
|
27
|
+
const message = pullFromCache<Amity.InternalMessage>(['message', 'get', messageId])?.data;
|
|
28
|
+
if (!message) throw Error('messageId not found');
|
|
29
|
+
|
|
30
|
+
const deletedMessage = {
|
|
31
|
+
...message,
|
|
32
|
+
isDeleted: true,
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
fireEvent('local.message.deleted', {
|
|
36
|
+
messages: [deletedMessage],
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
return LinkedObject.message(deletedMessage);
|
|
40
|
+
}
|
|
41
|
+
|
|
26
42
|
// API-FIX: This endpoint has not been implemented yet.
|
|
27
43
|
const { data: deleted } = await client.http.delete<Amity.MessagePayload>(
|
|
28
44
|
`/api/v5/messages/${encodeURIComponent(messageId)}`,
|
|
@@ -116,6 +116,19 @@ export class MessageQueryStreamController extends QueryStreamController<
|
|
|
116
116
|
pushToCache(this.cacheKey, collection);
|
|
117
117
|
}
|
|
118
118
|
|
|
119
|
+
if (action === 'onDelete' && payload.syncState === Amity.SyncState.Error) {
|
|
120
|
+
const collection = pullFromCache<Amity.MessageLiveCollectionCache>(this.cacheKey)?.data;
|
|
121
|
+
if (!collection) return;
|
|
122
|
+
|
|
123
|
+
if (collection.data.includes(payload.messageId)) {
|
|
124
|
+
const newCollectionData = collection.data.filter(
|
|
125
|
+
messageId => messageId !== payload.messageId,
|
|
126
|
+
);
|
|
127
|
+
|
|
128
|
+
pushToCache(this.cacheKey, { ...collection, data: newCollectionData });
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
|
|
119
132
|
this.notifyChange({ origin: Amity.LiveDataOrigin.EVENT, loading: false });
|
|
120
133
|
};
|
|
121
134
|
}
|
|
@@ -2,8 +2,8 @@ import { getActiveClient } from '~/client/api';
|
|
|
2
2
|
|
|
3
3
|
import { ingestInCache } from '~/cache/api/ingestInCache';
|
|
4
4
|
import { fireEvent } from '~/core/events';
|
|
5
|
-
import { prepareMembershipPayload } from '~/group/utils';
|
|
6
5
|
import { LinkedObject } from '~/utils/linkedObject';
|
|
6
|
+
import { preparePostPayload } from '../utils/payload';
|
|
7
7
|
|
|
8
8
|
/* begin_public_function
|
|
9
9
|
id: post.create.text_post, post.create.image_post, post.create.file_post, post.create.video_post, post.create.poll_post, post.create.livestream_post, post.create.custom_post
|
|
@@ -46,7 +46,8 @@ export const createPost = async <T extends Amity.PostContentType | string>(
|
|
|
46
46
|
|
|
47
47
|
fireEvent('post.created', payload);
|
|
48
48
|
|
|
49
|
-
const data =
|
|
49
|
+
const data = preparePostPayload(payload);
|
|
50
|
+
|
|
50
51
|
const cachedAt = client.cache && Date.now();
|
|
51
52
|
|
|
52
53
|
if (client.cache) ingestInCache(data, { cachedAt });
|
|
@@ -1,8 +1,28 @@
|
|
|
1
1
|
import { addPostSetting } from '~/communityRepository/utils';
|
|
2
2
|
import { updateMembershipStatus } from '~/communityRepository/utils/communityWithMembership';
|
|
3
|
+
import { isAmityLivestreamPost } from '~/utils/postTypePredicate';
|
|
4
|
+
|
|
5
|
+
const updateStreamReferences = (
|
|
6
|
+
streams: Amity.RawStream[],
|
|
7
|
+
streamId: string | undefined,
|
|
8
|
+
postId: string,
|
|
9
|
+
) => {
|
|
10
|
+
if (!streamId) return streams;
|
|
11
|
+
|
|
12
|
+
return streams.map(stream =>
|
|
13
|
+
stream.streamId === streamId
|
|
14
|
+
? {
|
|
15
|
+
...stream,
|
|
16
|
+
referenceType: 'post',
|
|
17
|
+
referenceId: postId,
|
|
18
|
+
postId,
|
|
19
|
+
}
|
|
20
|
+
: stream,
|
|
21
|
+
);
|
|
22
|
+
};
|
|
3
23
|
|
|
4
24
|
export const preparePostPayload = (payload: Amity.PostPayload): Amity.ProcessedPostPayload => {
|
|
5
|
-
const { posts: postsData, ...postPayload } = payload;
|
|
25
|
+
const { posts: postsData, postChildren, videoStreamings, ...postPayload } = payload;
|
|
6
26
|
|
|
7
27
|
// Unpack community payload by mapping payload field to postSetting value.
|
|
8
28
|
const communitiesWithPostSetting = addPostSetting({ communities: postPayload.communities });
|
|
@@ -24,18 +44,34 @@ export const preparePostPayload = (payload: Amity.PostPayload): Amity.ProcessedP
|
|
|
24
44
|
mappedCommunityUsers,
|
|
25
45
|
);
|
|
26
46
|
|
|
47
|
+
let mappedNewStream: Amity.RawStream[] = [];
|
|
48
|
+
|
|
27
49
|
// feed type
|
|
28
50
|
const posts = postsData.map(post => {
|
|
29
51
|
const feedType = postPayload.feeds.find(feed => feed.feedId === post.feedId)?.feedType;
|
|
52
|
+
const childPosts = payload.postChildren.filter(
|
|
53
|
+
children => children.parentPostId === post.postId,
|
|
54
|
+
);
|
|
55
|
+
|
|
56
|
+
if (childPosts.length > 0 && isAmityLivestreamPost(childPosts[0])) {
|
|
57
|
+
mappedNewStream = updateStreamReferences(
|
|
58
|
+
videoStreamings,
|
|
59
|
+
childPosts[0].data?.streamId,
|
|
60
|
+
post.postId,
|
|
61
|
+
);
|
|
62
|
+
}
|
|
30
63
|
|
|
31
64
|
return {
|
|
32
65
|
...post,
|
|
66
|
+
childPosts,
|
|
33
67
|
feedType,
|
|
34
68
|
};
|
|
35
69
|
});
|
|
36
70
|
|
|
37
71
|
return {
|
|
38
72
|
...postPayload,
|
|
73
|
+
postChildren,
|
|
74
|
+
videoStreamings: mappedNewStream,
|
|
39
75
|
posts,
|
|
40
76
|
communities: communityWithMembershipStatus,
|
|
41
77
|
communityUsers: mappedCommunityUsers,
|
|
@@ -21,7 +21,10 @@ import { LinkedObject } from '~/utils/linkedObject';
|
|
|
21
21
|
* @async
|
|
22
22
|
*/
|
|
23
23
|
export const createStream = async (
|
|
24
|
-
bundle: Pick<
|
|
24
|
+
bundle: Pick<
|
|
25
|
+
Amity.InternalStream,
|
|
26
|
+
'title' | 'thumbnailFileId' | 'description' | 'channelEnabled'
|
|
27
|
+
> & {
|
|
25
28
|
isSecure?: boolean;
|
|
26
29
|
},
|
|
27
30
|
): Promise<Amity.Cached<Amity.Stream>> => {
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { getActiveClient } from '~/client/api';
|
|
2
|
+
|
|
3
|
+
import { ingestInCache } from '~/cache/api/ingestInCache';
|
|
4
|
+
import { LinkedObject } from '~/utils/linkedObject';
|
|
5
|
+
|
|
6
|
+
/* begin_public_function
|
|
7
|
+
id: stream.update
|
|
8
|
+
*/
|
|
9
|
+
/**
|
|
10
|
+
*
|
|
11
|
+
* ```js
|
|
12
|
+
* import { StreamRepository } from '@amityco/ts-sdk'
|
|
13
|
+
* const updated = await StreamRepository.editStream(streamId, { title: 'foobar' })
|
|
14
|
+
* ```
|
|
15
|
+
*
|
|
16
|
+
* Updates an {@link Amity.Stream}
|
|
17
|
+
*
|
|
18
|
+
* @param streamId The ID of the {@link Amity.Stream} to edit
|
|
19
|
+
* @param patch The patch data to apply
|
|
20
|
+
* @returns the updated {@link Amity.Stream} object
|
|
21
|
+
*
|
|
22
|
+
* @category Stream API
|
|
23
|
+
* @async
|
|
24
|
+
*/
|
|
25
|
+
|
|
26
|
+
export const editStream = async (
|
|
27
|
+
streamId: Amity.Stream['streamId'],
|
|
28
|
+
patch: Patch<
|
|
29
|
+
Amity.Stream,
|
|
30
|
+
'title' | 'thumbnailFileId' | 'description' | 'metadata' | 'channelEnabled'
|
|
31
|
+
>,
|
|
32
|
+
): Promise<Amity.Cached<Amity.Stream>> => {
|
|
33
|
+
const client = getActiveClient();
|
|
34
|
+
client.log('stream/updateStream', streamId, patch);
|
|
35
|
+
|
|
36
|
+
const { data } = await client.http.put<Amity.StreamPayload>(
|
|
37
|
+
`/api/v3/video-streaming/${streamId}`,
|
|
38
|
+
patch,
|
|
39
|
+
);
|
|
40
|
+
|
|
41
|
+
const cachedAt = client.cache && Date.now();
|
|
42
|
+
if (client.cache) ingestInCache(data, { cachedAt });
|
|
43
|
+
|
|
44
|
+
const { videoStreamings } = data;
|
|
45
|
+
|
|
46
|
+
return {
|
|
47
|
+
data: LinkedObject.stream(videoStreamings.find(stream => stream.streamId === streamId)!),
|
|
48
|
+
cachedAt,
|
|
49
|
+
};
|
|
50
|
+
};
|
|
51
|
+
/* end_public_function */
|