@amityco/ts-sdk 7.6.1-2841ad2c.0 → 7.6.1-63bd9d56.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.
Files changed (247) hide show
  1. package/dist/@types/core/events.d.ts +1 -6
  2. package/dist/@types/core/events.d.ts.map +1 -1
  3. package/dist/@types/core/payload.d.ts +1 -26
  4. package/dist/@types/core/payload.d.ts.map +1 -1
  5. package/dist/@types/domains/channel.d.ts +0 -6
  6. package/dist/@types/domains/channel.d.ts.map +1 -1
  7. package/dist/@types/domains/content.d.ts +8 -2
  8. package/dist/@types/domains/content.d.ts.map +1 -1
  9. package/dist/@types/domains/feed.d.ts +6 -1
  10. package/dist/@types/domains/feed.d.ts.map +1 -1
  11. package/dist/@types/domains/file.d.ts +3 -1
  12. package/dist/@types/domains/file.d.ts.map +1 -1
  13. package/dist/@types/domains/post.d.ts +3 -3
  14. package/dist/@types/domains/post.d.ts.map +1 -1
  15. package/dist/@types/domains/stream.d.ts +1 -9
  16. package/dist/@types/domains/stream.d.ts.map +1 -1
  17. package/dist/@types/index.d.ts +0 -1
  18. package/dist/@types/index.d.ts.map +1 -1
  19. package/dist/channelRepository/api/createChannel.d.ts +1 -3
  20. package/dist/channelRepository/api/createChannel.d.ts.map +1 -1
  21. package/dist/channelRepository/channelMembership/observers/getMembers/ChannelMemberLiveCollectionController.d.ts.map +1 -1
  22. package/dist/channelRepository/events/index.d.ts +1 -1
  23. package/dist/channelRepository/events/index.d.ts.map +1 -1
  24. package/dist/channelRepository/events/onChannelMuted.d.ts +2 -0
  25. package/dist/channelRepository/events/onChannelMuted.d.ts.map +1 -0
  26. package/dist/channelRepository/internalApi/getChannel.d.ts.map +1 -1
  27. package/dist/channelRepository/observers/getChannels/ChannelLiveCollectionController.d.ts.map +1 -1
  28. package/dist/client/api/login.d.ts.map +1 -1
  29. package/dist/communityRepository/api/getCommunity.d.ts +1 -1
  30. package/dist/communityRepository/api/getCommunity.d.ts.map +1 -1
  31. package/dist/core/events.d.ts +3 -3
  32. package/dist/core/events.d.ts.map +1 -1
  33. package/dist/core/model/index.d.ts.map +1 -1
  34. package/dist/core/subscription.d.ts +1 -2
  35. package/dist/core/subscription.d.ts.map +1 -1
  36. package/dist/feedRepository/api/index.d.ts +0 -1
  37. package/dist/feedRepository/api/index.d.ts.map +1 -1
  38. package/dist/feedRepository/api/queryGlobalFeed.d.ts +3 -0
  39. package/dist/feedRepository/api/queryGlobalFeed.d.ts.map +1 -1
  40. package/dist/feedRepository/index.d.ts +2 -1
  41. package/dist/feedRepository/index.d.ts.map +1 -1
  42. package/dist/feedRepository/observers/getCustomRankingGlobalFeed/LiveCollectionController.d.ts +13 -0
  43. package/dist/feedRepository/observers/getCustomRankingGlobalFeed/LiveCollectionController.d.ts.map +1 -0
  44. package/dist/feedRepository/observers/getCustomRankingGlobalFeed/PaginationController.d.ts +5 -0
  45. package/dist/feedRepository/observers/getCustomRankingGlobalFeed/PaginationController.d.ts.map +1 -0
  46. package/dist/feedRepository/observers/getCustomRankingGlobalFeed/QueryStreamController.d.ts +15 -0
  47. package/dist/feedRepository/observers/getCustomRankingGlobalFeed/QueryStreamController.d.ts.map +1 -0
  48. package/dist/feedRepository/observers/getCustomRankingGlobalFeed.d.ts +22 -0
  49. package/dist/feedRepository/observers/getCustomRankingGlobalFeed.d.ts.map +1 -0
  50. package/dist/feedRepository/observers/getGlobalFeed/LiveCollectionController.d.ts +13 -0
  51. package/dist/feedRepository/observers/getGlobalFeed/LiveCollectionController.d.ts.map +1 -0
  52. package/dist/feedRepository/observers/getGlobalFeed/PaginationController.d.ts +5 -0
  53. package/dist/feedRepository/observers/getGlobalFeed/PaginationController.d.ts.map +1 -0
  54. package/dist/feedRepository/observers/getGlobalFeed/QueryStreamController.d.ts +15 -0
  55. package/dist/feedRepository/observers/getGlobalFeed/QueryStreamController.d.ts.map +1 -0
  56. package/dist/feedRepository/observers/getGlobalFeed.d.ts +22 -0
  57. package/dist/feedRepository/observers/getGlobalFeed.d.ts.map +1 -0
  58. package/dist/feedRepository/observers/index.d.ts +3 -0
  59. package/dist/feedRepository/observers/index.d.ts.map +1 -0
  60. package/dist/feedRepository/observers/utils.d.ts +6 -0
  61. package/dist/feedRepository/observers/utils.d.ts.map +1 -0
  62. package/dist/fileRepository/api/index.d.ts +1 -0
  63. package/dist/fileRepository/api/index.d.ts.map +1 -1
  64. package/dist/fileRepository/api/uploadClip.d.ts +17 -0
  65. package/dist/fileRepository/api/uploadClip.d.ts.map +1 -0
  66. package/dist/index.cjs.js +7215 -7438
  67. package/dist/index.d.ts +0 -1
  68. package/dist/index.d.ts.map +1 -1
  69. package/dist/index.esm.js +7289 -7510
  70. package/dist/index.umd.js +3 -3
  71. package/dist/liveStreamPlayer/utils/eventRegister.d.ts +1 -2
  72. package/dist/liveStreamPlayer/utils/eventRegister.d.ts.map +1 -1
  73. package/dist/messagePreview/utils/getChannelMessagePreviewWithUser.d.ts +0 -4
  74. package/dist/messagePreview/utils/getChannelMessagePreviewWithUser.d.ts.map +1 -1
  75. package/dist/messagePreview/utils/getSubChannelMessagePreviewWithUser.d.ts +1 -1
  76. package/dist/messageRepository/api/deleteMessage.d.ts.map +1 -1
  77. package/dist/messageRepository/observers/getMessage.d.ts.map +1 -1
  78. package/dist/messageRepository/observers/getMessages/MessageLiveCollectionController.d.ts.map +1 -1
  79. package/dist/messageRepository/observers/getMessages/MessageQueryStreamController.d.ts.map +1 -1
  80. package/dist/postRepository/api/createClipPost.d.ts +32 -0
  81. package/dist/postRepository/api/createClipPost.d.ts.map +1 -0
  82. package/dist/postRepository/api/createPost.d.ts.map +1 -1
  83. package/dist/postRepository/api/index.d.ts +1 -0
  84. package/dist/postRepository/api/index.d.ts.map +1 -1
  85. package/dist/postRepository/events/utils.d.ts.map +1 -1
  86. package/dist/postRepository/observers/getGlobalPinnedPosts/GlobalPinnedPostLiveCollectionController.d.ts.map +1 -1
  87. package/dist/postRepository/observers/getPinnedPosts/PinnedPostLiveCollectionController.d.ts.map +1 -1
  88. package/dist/postRepository/observers/getPinnedPosts/PinnedPostQueryStreamController.d.ts +6 -0
  89. package/dist/postRepository/observers/getPinnedPosts/PinnedPostQueryStreamController.d.ts.map +1 -1
  90. package/dist/postRepository/observers/getPosts/PostLiveCollectionController.d.ts.map +1 -1
  91. package/dist/postRepository/observers/utils.d.ts +13 -0
  92. package/dist/postRepository/observers/utils.d.ts.map +1 -0
  93. package/dist/postRepository/utils/payload.d.ts.map +1 -1
  94. package/dist/reactionRepository/api/addReaction.d.ts.map +1 -1
  95. package/dist/reactionRepository/api/removeReaction.d.ts.map +1 -1
  96. package/dist/streamRepository/api/createStream.d.ts +1 -1
  97. package/dist/streamRepository/api/createStream.d.ts.map +1 -1
  98. package/dist/streamRepository/api/index.d.ts +0 -1
  99. package/dist/streamRepository/api/index.d.ts.map +1 -1
  100. package/dist/streamRepository/api/updateStream.d.ts +1 -4
  101. package/dist/streamRepository/api/updateStream.d.ts.map +1 -1
  102. package/dist/streamRepository/events/index.d.ts +0 -2
  103. package/dist/streamRepository/events/index.d.ts.map +1 -1
  104. package/dist/streamRepository/internalApi/getStream.d.ts +2 -2
  105. package/dist/streamRepository/internalApi/getStream.d.ts.map +1 -1
  106. package/dist/streamRepository/observers/getStreamById.d.ts.map +1 -1
  107. package/dist/streamRepository/observers/getStreams/GetStreamsLiveCollectionController.d.ts.map +1 -1
  108. package/dist/utils/linkedObject/channelLinkedObject.d.ts.map +1 -1
  109. package/dist/utils/linkedObject/postLinkedObject.d.ts.map +1 -1
  110. package/dist/utils/linkedObject/streamLinkedObject.d.ts.map +1 -1
  111. package/dist/utils/postTypePredicate.d.ts +4 -5
  112. package/dist/utils/postTypePredicate.d.ts.map +1 -1
  113. package/dist/utils/tests/dummy/comment.d.ts +1 -1
  114. package/package.json +1 -1
  115. package/src/@types/core/events.ts +1 -10
  116. package/src/@types/core/payload.ts +1 -33
  117. package/src/@types/domains/channel.ts +0 -9
  118. package/src/@types/domains/content.ts +10 -0
  119. package/src/@types/domains/feed.ts +18 -1
  120. package/src/@types/domains/file.ts +5 -0
  121. package/src/@types/domains/post.ts +4 -4
  122. package/src/@types/domains/stream.ts +1 -13
  123. package/src/@types/index.ts +0 -1
  124. package/src/channelRepository/api/createChannel.ts +8 -11
  125. package/src/channelRepository/channelMembership/observers/getMembers/ChannelMemberLiveCollectionController.ts +0 -2
  126. package/src/channelRepository/events/index.ts +1 -1
  127. package/src/channelRepository/events/onChannelMuted.ts +39 -0
  128. package/src/channelRepository/internalApi/getChannel.ts +1 -0
  129. package/src/channelRepository/observers/getChannel.ts +2 -2
  130. package/src/channelRepository/observers/getChannels/ChannelLiveCollectionController.ts +2 -2
  131. package/src/channelRepository/utils/constructChannelObject.ts +2 -2
  132. package/src/client/api/login.ts +0 -2
  133. package/src/commentRepository/api/deleteComment.ts +6 -6
  134. package/src/communityRepository/api/getCommunity.ts +0 -9
  135. package/src/core/events.ts +1 -4
  136. package/src/core/model/index.ts +2 -1
  137. package/src/core/subscription.ts +6 -10
  138. package/src/feedRepository/api/index.ts +0 -1
  139. package/src/feedRepository/api/queryGlobalFeed.ts +6 -1
  140. package/src/feedRepository/index.ts +2 -1
  141. package/src/feedRepository/observers/getCustomRankingGlobalFeed/LiveCollectionController.ts +95 -0
  142. package/src/feedRepository/observers/getCustomRankingGlobalFeed/PaginationController.ts +25 -0
  143. package/src/feedRepository/observers/getCustomRankingGlobalFeed/QueryStreamController.ts +101 -0
  144. package/src/feedRepository/observers/getCustomRankingGlobalFeed.ts +56 -0
  145. package/src/feedRepository/observers/getGlobalFeed/LiveCollectionController.ts +91 -0
  146. package/src/feedRepository/observers/getGlobalFeed/PaginationController.ts +23 -0
  147. package/src/feedRepository/observers/getGlobalFeed/QueryStreamController.ts +99 -0
  148. package/src/feedRepository/observers/getGlobalFeed.ts +56 -0
  149. package/src/feedRepository/observers/index.ts +2 -0
  150. package/src/feedRepository/observers/utils.ts +85 -0
  151. package/src/fileRepository/api/index.ts +1 -0
  152. package/src/fileRepository/api/uploadClip.ts +71 -0
  153. package/src/index.ts +0 -2
  154. package/src/liveStreamPlayer/api/getPlayer.ts +1 -1
  155. package/src/liveStreamPlayer/utils/eventRegister.ts +1 -16
  156. package/src/messageRepository/api/deleteMessage.ts +0 -16
  157. package/src/messageRepository/observers/getMessage.ts +0 -2
  158. package/src/messageRepository/observers/getMessages/MessageLiveCollectionController.ts +0 -2
  159. package/src/messageRepository/observers/getMessages/MessageQueryStreamController.ts +0 -13
  160. package/src/postRepository/api/createClipPost.ts +62 -0
  161. package/src/postRepository/api/createPost.ts +2 -3
  162. package/src/postRepository/api/index.ts +2 -0
  163. package/src/postRepository/api/queryPosts.ts +1 -1
  164. package/src/postRepository/events/utils.ts +35 -1
  165. package/src/postRepository/observers/getGlobalPinnedPosts/GlobalPinnedPostLiveCollectionController.ts +5 -0
  166. package/src/postRepository/observers/getPinnedPosts/PinnedPostLiveCollectionController.ts +7 -1
  167. package/src/postRepository/observers/getPinnedPosts/PinnedPostQueryStreamController.ts +27 -0
  168. package/src/postRepository/observers/getPosts/PostLiveCollectionController.ts +2 -74
  169. package/src/postRepository/observers/getPosts/PostPaginationController.ts +1 -1
  170. package/src/postRepository/observers/utils.ts +97 -0
  171. package/src/postRepository/utils/payload.ts +1 -37
  172. package/src/reactionRepository/api/addReaction.ts +1 -0
  173. package/src/reactionRepository/api/removeReaction.ts +1 -0
  174. package/src/streamRepository/api/createStream.ts +1 -4
  175. package/src/streamRepository/api/index.ts +0 -1
  176. package/src/streamRepository/api/updateStream.ts +1 -8
  177. package/src/streamRepository/events/index.ts +0 -2
  178. package/src/streamRepository/internalApi/getStream.ts +3 -3
  179. package/src/streamRepository/observers/getStreamById.ts +0 -2
  180. package/src/streamRepository/observers/getStreams/GetStreamsLiveCollectionController.ts +1 -5
  181. package/src/utils/linkedObject/channelLinkedObject.ts +0 -3
  182. package/src/utils/linkedObject/postLinkedObject.ts +8 -28
  183. package/src/utils/linkedObject/streamLinkedObject.ts +0 -4
  184. package/src/utils/postTypePredicate.ts +6 -20
  185. package/dist/@types/domains/liveReaction.d.ts +0 -20
  186. package/dist/@types/domains/liveReaction.d.ts.map +0 -1
  187. package/dist/channelRepository/events/onChannelSetMuted.d.ts +0 -2
  188. package/dist/channelRepository/events/onChannelSetMuted.d.ts.map +0 -1
  189. package/dist/channelRepository/events/onChannelSetUserMuted.d.ts +0 -2
  190. package/dist/channelRepository/events/onChannelSetUserMuted.d.ts.map +0 -1
  191. package/dist/channelRepository/internalApi/getMyMembership.d.ts +0 -11
  192. package/dist/channelRepository/internalApi/getMyMembership.d.ts.map +0 -1
  193. package/dist/channelRepository/observers/getMyMembership.d.ts +0 -2
  194. package/dist/channelRepository/observers/getMyMembership.d.ts.map +0 -1
  195. package/dist/feedRepository/api/getCustomRankingGlobalFeed.d.ts +0 -37
  196. package/dist/feedRepository/api/getCustomRankingGlobalFeed.d.ts.map +0 -1
  197. package/dist/liveReactionRepository/api/createReaction.d.ts +0 -20
  198. package/dist/liveReactionRepository/api/createReaction.d.ts.map +0 -1
  199. package/dist/liveReactionRepository/api/index.d.ts +0 -2
  200. package/dist/liveReactionRepository/api/index.d.ts.map +0 -1
  201. package/dist/liveReactionRepository/events/index.d.ts +0 -2
  202. package/dist/liveReactionRepository/events/index.d.ts.map +0 -1
  203. package/dist/liveReactionRepository/events/onLiveReactionCreated.d.ts +0 -17
  204. package/dist/liveReactionRepository/events/onLiveReactionCreated.d.ts.map +0 -1
  205. package/dist/liveReactionRepository/events/onLiveReactionCreatedLocal.d.ts +0 -17
  206. package/dist/liveReactionRepository/events/onLiveReactionCreatedLocal.d.ts.map +0 -1
  207. package/dist/liveReactionRepository/index.d.ts +0 -4
  208. package/dist/liveReactionRepository/index.d.ts.map +0 -1
  209. package/dist/liveReactionRepository/internalApi/createLiveReaction.d.ts +0 -20
  210. package/dist/liveReactionRepository/internalApi/createLiveReaction.d.ts.map +0 -1
  211. package/dist/liveReactionRepository/observers/getReactions.d.ts +0 -19
  212. package/dist/liveReactionRepository/observers/getReactions.d.ts.map +0 -1
  213. package/dist/liveReactionRepository/observers/index.d.ts +0 -2
  214. package/dist/liveReactionRepository/observers/index.d.ts.map +0 -1
  215. package/dist/liveReactionRepository/service/ReactionSyncEngine.d.ts +0 -26
  216. package/dist/liveReactionRepository/service/ReactionSyncEngine.d.ts.map +0 -1
  217. package/dist/liveReactionRepository/utils/ReactionSyncEngineOnLoginHandler.d.ts +0 -3
  218. package/dist/liveReactionRepository/utils/ReactionSyncEngineOnLoginHandler.d.ts.map +0 -1
  219. package/dist/streamRepository/api/editStream.d.ts +0 -18
  220. package/dist/streamRepository/api/editStream.d.ts.map +0 -1
  221. package/dist/streamRepository/events/onStreamViewerBanned.d.ts +0 -17
  222. package/dist/streamRepository/events/onStreamViewerBanned.d.ts.map +0 -1
  223. package/dist/streamRepository/events/onStreamViewerUnbanned.d.ts +0 -17
  224. package/dist/streamRepository/events/onStreamViewerUnbanned.d.ts.map +0 -1
  225. package/dist/streamRepository/internalApi/getLiveChat.d.ts +0 -16
  226. package/dist/streamRepository/internalApi/getLiveChat.d.ts.map +0 -1
  227. package/src/@types/domains/liveReaction.ts +0 -25
  228. package/src/channelRepository/events/onChannelSetMuted.ts +0 -48
  229. package/src/channelRepository/events/onChannelSetUserMuted.ts +0 -65
  230. package/src/channelRepository/internalApi/getMyMembership.ts +0 -37
  231. package/src/channelRepository/observers/getMyMembership.ts +0 -98
  232. package/src/feedRepository/api/getCustomRankingGlobalFeed.ts +0 -115
  233. package/src/liveReactionRepository/api/createReaction.ts +0 -58
  234. package/src/liveReactionRepository/api/index.ts +0 -1
  235. package/src/liveReactionRepository/events/index.ts +0 -1
  236. package/src/liveReactionRepository/events/onLiveReactionCreated.ts +0 -37
  237. package/src/liveReactionRepository/events/onLiveReactionCreatedLocal.ts +0 -29
  238. package/src/liveReactionRepository/index.ts +0 -3
  239. package/src/liveReactionRepository/internalApi/createLiveReaction.ts +0 -42
  240. package/src/liveReactionRepository/observers/getReactions.ts +0 -59
  241. package/src/liveReactionRepository/observers/index.ts +0 -1
  242. package/src/liveReactionRepository/service/ReactionSyncEngine.ts +0 -138
  243. package/src/liveReactionRepository/utils/ReactionSyncEngineOnLoginHandler.ts +0 -19
  244. package/src/streamRepository/api/editStream.ts +0 -51
  245. package/src/streamRepository/events/onStreamViewerBanned.ts +0 -58
  246. package/src/streamRepository/events/onStreamViewerUnbanned.ts +0 -47
  247. package/src/streamRepository/internalApi/getLiveChat.ts +0 -59
@@ -1,10 +1,38 @@
1
1
  import { getActiveClient } from '~/client/api';
2
2
  import { ingestInCache } from '~/cache/api/ingestInCache';
3
3
  import { createEventSubscriber, fireEvent } from '~/core/events';
4
- import { dropFromCache, pullFromCache, queryCache, upsertInCache } from '~/cache/api';
4
+ import { dropFromCache, pullFromCache, pushToCache, queryCache, upsertInCache } from '~/cache/api';
5
5
  import { isInTombstone } from '~/cache/api/isInTombstone';
6
6
  import { preparePostPayload } from '~/postRepository/utils/payload';
7
7
 
8
+ const processDeleteChildPost = (payload: Amity.PostPayload) => {
9
+ const post = payload.posts[0];
10
+ if (!post.parentId) return;
11
+
12
+ const parentPost = pullFromCache<Amity.InternalPost>(['post', 'get', post.parentPostId])?.data;
13
+
14
+ if (!parentPost) return;
15
+
16
+ pushToCache(['post', 'get', parentPost.postId], {
17
+ ...parentPost,
18
+ children: parentPost.children.filter(childId => childId !== post.postId),
19
+ });
20
+ };
21
+
22
+ const processCreateChildPost = (payload: Amity.PostPayload) => {
23
+ const post = payload.posts[0];
24
+ if (!post.parentId) return;
25
+
26
+ const parentPost = pullFromCache<Amity.InternalPost>(['post', 'get', post.parentPostId])?.data;
27
+
28
+ if (!parentPost) return;
29
+
30
+ pushToCache(['post', 'get', parentPost.postId], {
31
+ ...parentPost,
32
+ children: [...new Set([post.postId, ...parentPost.children])],
33
+ });
34
+ };
35
+
8
36
  export const createPostEventSubscriber = (
9
37
  event: keyof Amity.MqttPostEvents,
10
38
  callback: Amity.Listener<Amity.InternalPost>,
@@ -36,6 +64,8 @@ export const createPostEventSubscriber = (
36
64
  if (event === 'post.deleted') {
37
65
  const { postId, postedUserId } = payload.posts[0];
38
66
 
67
+ processDeleteChildPost(payload);
68
+
39
69
  try {
40
70
  isInTombstone('post', postId);
41
71
  } catch (e) {
@@ -70,6 +100,8 @@ export const createPostEventSubscriber = (
70
100
  queries?.map(({ key, data }) => upsertInCache(key, data as any, { cachedAt: -1 }));
71
101
  }
72
102
 
103
+ if (event === 'post.created') processCreateChildPost(payload);
104
+
73
105
  callback(post.data);
74
106
  }
75
107
  };
@@ -106,6 +138,8 @@ export const createLocalPostEventSubscriber = (
106
138
 
107
139
  const post = pullFromCache<Amity.InternalPost>(['post', 'get', payload.posts[0].postId])!;
108
140
 
141
+ if (event === 'local.post.deleted') processDeleteChildPost(payload);
142
+
109
143
  callback(post.data);
110
144
  }
111
145
  };
@@ -8,6 +8,7 @@ import { LinkedObject } from '~/utils/linkedObject';
8
8
  import { onPostDeleted } from '~/postRepository/events';
9
9
  import { EnumPostActions } from '../enums';
10
10
  import { onLocalPostDeleted } from '~/postRepository/events/onLocalPostDeleted';
11
+ import { generateCommentSubscriptions } from '../utils';
11
12
 
12
13
  export class GlobalPinnedPostLiveCollectionController extends LiveCollectionController<
13
14
  'pinnedPost',
@@ -71,6 +72,10 @@ export class GlobalPinnedPostLiveCollectionController extends LiveCollectionCont
71
72
  fn: onPostDeleted,
72
73
  action: EnumPostActions.OnPostDeleted,
73
74
  },
75
+ ...generateCommentSubscriptions({
76
+ cacheKey: this.cacheKey,
77
+ resolveId: id => `global#${id}`,
78
+ }),
74
79
  ]);
75
80
  }
76
81
 
@@ -6,6 +6,7 @@ import { LiveCollectionController } from '~/core/liveCollection/LiveCollectionCo
6
6
  import { isNonNullable } from '~/utils';
7
7
  import { LinkedObject } from '~/utils/linkedObject';
8
8
  import { sortByLastCreated } from '~/core/query';
9
+ import { generateCommentSubscriptions } from '../utils';
9
10
 
10
11
  export class PinnedPostLiveCollectionController extends LiveCollectionController<
11
12
  'pinnedPost',
@@ -63,7 +64,12 @@ export class PinnedPostLiveCollectionController extends LiveCollectionController
63
64
 
64
65
  // eslint-disable-next-line class-methods-use-this
65
66
  startSubscription() {
66
- return [] as Amity.Unsubscriber[];
67
+ return this.queryStreamController.subscribeRTE(
68
+ generateCommentSubscriptions({
69
+ cacheKey: this.cacheKey,
70
+ resolveId: id => `${this.query.placement}#${id}`,
71
+ }),
72
+ );
67
73
  }
68
74
 
69
75
  notifyChange({ origin, loading, error }: Amity.LiveCollectionNotifyParams) {
@@ -4,6 +4,7 @@ import { ingestInCache } from '~/cache/api/ingestInCache';
4
4
  import { getResolver } from '~/core/model';
5
5
  import { getActiveClient } from '~/client';
6
6
  import { convertRawUserToInternalUser } from '~/userRepository/utils/convertRawUserToInternalUser';
7
+ import { EnumPostActions } from '../enums';
7
8
 
8
9
  export class PinnedPostQueryStreamController extends QueryStreamController<
9
10
  Amity.PinnedPostPayload,
@@ -64,4 +65,30 @@ export class PinnedPostQueryStreamController extends QueryStreamController<
64
65
  });
65
66
  }
66
67
  }
68
+
69
+ reactor(action: EnumPostActions) {
70
+ return (post: Amity.InternalPost) => {
71
+ const collection = pullFromCache<Amity.PostLiveCollectionCache>(this.cacheKey)?.data;
72
+
73
+ if (!collection) return;
74
+
75
+ if (action === EnumPostActions.OnPostDeleted) {
76
+ collection.data = collection.data.filter(
77
+ referenceId => referenceId !== `global#${post.postId}`,
78
+ );
79
+ }
80
+
81
+ pushToCache(this.cacheKey, collection);
82
+ this.notifyChange({ origin: Amity.LiveDataOrigin.EVENT, loading: false });
83
+ };
84
+ }
85
+
86
+ subscribeRTE(
87
+ createSubscriber: {
88
+ fn: (reactor: (post: Amity.InternalPost) => void) => Amity.Unsubscriber;
89
+ action: EnumPostActions;
90
+ }[],
91
+ ) {
92
+ return createSubscriber.map(subscriber => subscriber.fn(this.reactor(subscriber.action)));
93
+ }
67
94
  }
@@ -3,17 +3,6 @@ import { pullFromCache, pushToCache } from '~/cache/api';
3
3
  import { PostPaginationController } from './PostPaginationController';
4
4
  import { PostQueryStreamController } from './PostQueryStreamController';
5
5
  import { LiveCollectionController } from '~/core/liveCollection/LiveCollectionController';
6
- import {
7
- onPostCreated,
8
- onPostUpdated,
9
- onPostDeleted,
10
- onPostFlagged,
11
- onPostUnflagged,
12
- onPostReactionAdded,
13
- onPostReactionRemoved,
14
- onPostApproved,
15
- onPostDeclined,
16
- } from '~/postRepository/events';
17
6
  import {
18
7
  filterByFeedType,
19
8
  filterByPostDataTypes,
@@ -22,16 +11,9 @@ import {
22
11
  sortByLastCreated,
23
12
  } from '~/core/query';
24
13
  import { isNonNullable } from '~/utils';
25
- import { EnumPostActions } from '../enums';
26
14
  import { LinkedObject } from '~/utils/linkedObject';
27
15
  import { preparePostPayload } from '~/postRepository/utils/payload';
28
- import { convertEventPayload } from '~/utils/event';
29
- import { onCommentCreated, onCommentDeleted } from '~/commentRepository';
30
- import { getPost } from '~/postRepository/internalApi/getPost';
31
- import { onPostUpdatedLocal } from '~/postRepository/events/onPostUpdatedLocal';
32
- import { onLocalPostReactionAdded } from '~/postRepository/events/onLocalPostReactionAdded';
33
- import { onLocalPostReactionRemoved } from '~/postRepository/events/onLocalPostReactionRemoved';
34
- import { onLocalPostDeleted } from '~/postRepository/events/onLocalPostDeleted';
16
+ import { getPostSubscription } from '../utils';
35
17
 
36
18
  export class PostLiveCollectionController extends LiveCollectionController<
37
19
  'post',
@@ -85,61 +67,7 @@ export class PostLiveCollectionController extends LiveCollectionController<
85
67
  }
86
68
 
87
69
  startSubscription() {
88
- return this.queryStreamController.subscribeRTE([
89
- { fn: onPostCreated, action: EnumPostActions.OnPostCreated },
90
- { fn: onPostUpdated, action: EnumPostActions.OnPostUpdated },
91
- { fn: onPostUpdatedLocal, action: EnumPostActions.OnPostUpdated },
92
- { fn: onPostDeleted, action: EnumPostActions.OnPostDeleted },
93
- { fn: onPostFlagged, action: EnumPostActions.OnPostFlagged },
94
- { fn: onPostUnflagged, action: EnumPostActions.OnPostUnflagged },
95
- { fn: onPostApproved, action: EnumPostActions.OnPostApproved },
96
- { fn: onPostDeclined, action: EnumPostActions.OnPostDeclined },
97
- { fn: onPostReactionAdded, action: EnumPostActions.OnPostReactionAdded },
98
- { fn: onPostReactionRemoved, action: EnumPostActions.OnPostReactionRemoved },
99
- { fn: onLocalPostReactionAdded, action: EnumPostActions.OnPostReactionAdded },
100
- { fn: onLocalPostReactionRemoved, action: EnumPostActions.OnPostReactionRemoved },
101
- { fn: onLocalPostDeleted, action: EnumPostActions.OnPostDeleted },
102
- {
103
- fn: convertEventPayload(
104
- (callback: Amity.Listener<Amity.InternalComment>) => {
105
- return onCommentCreated(async (comment: Amity.InternalComment) => {
106
- const currentCollection = pullFromCache<Amity.PostLiveCollectionCache>(
107
- this.cacheKey,
108
- )?.data;
109
-
110
- if (!currentCollection || currentCollection.data.includes(comment.referenceId))
111
- return;
112
-
113
- await getPost(comment.referenceId);
114
- callback(comment);
115
- });
116
- },
117
- 'referenceId',
118
- 'post',
119
- ),
120
- action: EnumPostActions.OnPostUpdated,
121
- },
122
- {
123
- fn: convertEventPayload(
124
- (callback: Amity.Listener<Amity.InternalComment>) => {
125
- return onCommentDeleted(async (comment: Amity.InternalComment) => {
126
- const currentCollection = pullFromCache<Amity.PostLiveCollectionCache>(
127
- this.cacheKey,
128
- )?.data;
129
-
130
- if (!currentCollection || currentCollection.data.includes(comment.referenceId))
131
- return;
132
-
133
- await getPost(comment.referenceId);
134
- callback(comment);
135
- });
136
- },
137
- 'referenceId',
138
- 'post',
139
- ),
140
- action: EnumPostActions.OnPostUpdated,
141
- },
142
- ]);
70
+ return this.queryStreamController.subscribeRTE(getPostSubscription(this.cacheKey));
143
71
  }
144
72
 
145
73
  notifyChange({ origin, loading, error }: Amity.LiveCollectionNotifyParams) {
@@ -23,7 +23,7 @@ export class PostPaginationController extends PaginationController<
23
23
  const options = token ? { ...baseOptions, token } : { ...baseOptions, limit };
24
24
 
25
25
  const { data: queryResponse } = await this.http.get<Amity.PostPayload & Amity.Pagination>(
26
- `/api/v4/posts`,
26
+ `/api/v5/posts`,
27
27
  {
28
28
  params: {
29
29
  ...params,
@@ -0,0 +1,97 @@
1
+ import { pullFromCache } from '~/cache/api';
2
+ import { onCommentCreated, onCommentDeleted } from '~/commentRepository';
3
+ import { getPost } from '~/postRepository/internalApi';
4
+ import {
5
+ onPostCreated,
6
+ onPostUpdated,
7
+ onPostDeleted,
8
+ onPostFlagged,
9
+ onPostUnflagged,
10
+ onPostReactionAdded,
11
+ onPostReactionRemoved,
12
+ onPostApproved,
13
+ onPostDeclined,
14
+ } from '~/postRepository/events';
15
+ import { onLocalPostDeleted } from '~/postRepository/events/onLocalPostDeleted';
16
+ import { onLocalPostReactionAdded } from '~/postRepository/events/onLocalPostReactionAdded';
17
+ import { onLocalPostReactionRemoved } from '~/postRepository/events/onLocalPostReactionRemoved';
18
+ import { onPostUpdatedLocal } from '~/postRepository/events/onPostUpdatedLocal';
19
+ import { EnumPostActions } from '~/postRepository/observers/enums';
20
+ import { convertEventPayload } from '~/utils/event';
21
+ import { onCommentCreatedLocal } from '~/commentRepository/events/onCommentCreatedLocal';
22
+ import { onCommentDeleteLocal } from '~/commentRepository/events/onCommentDeletedLocal';
23
+ import { onCommentReactionAdded, onCommentReactionRemoved } from '~/commentRepository/events';
24
+ import { onLocalCommentReactionAdded } from '~/commentRepository/events/onLocalCommentReactionAdded';
25
+ import { onLocalCommentReactionRemoved } from '~/commentRepository/events/onLocalCommentReactionRemoved';
26
+
27
+ type CommentEventHandler = (callback: Amity.Listener<Amity.InternalComment>) => Amity.Unsubscriber;
28
+
29
+ const commentEventHanlder = (
30
+ callback: Amity.Listener<Amity.InternalComment>,
31
+ eventHandler: CommentEventHandler,
32
+ cacheKey: Amity.CacheKey,
33
+ resolveId?: (id: string) => string,
34
+ ) => {
35
+ return eventHandler(async (comment: Amity.InternalComment) => {
36
+ const currentCollection = pullFromCache<Amity.PinnedPostLiveCollectionCache>(cacheKey)?.data;
37
+
38
+ if (
39
+ !currentCollection ||
40
+ !currentCollection.data.includes(
41
+ resolveId ? resolveId(comment.referenceId) : comment.referenceId,
42
+ )
43
+ )
44
+ return;
45
+
46
+ await getPost(comment.referenceId);
47
+ callback(comment);
48
+ });
49
+ };
50
+
51
+ export const generateCommentSubscriptions = ({
52
+ cacheKey,
53
+ resolveId,
54
+ }: {
55
+ cacheKey: Amity.CacheKey;
56
+ resolveId?: (id: string) => string;
57
+ }) => {
58
+ const eventHandlers = [
59
+ onCommentCreated,
60
+ onCommentDeleted,
61
+ onCommentReactionAdded,
62
+ onCommentReactionRemoved,
63
+ onCommentCreatedLocal,
64
+ onCommentDeleteLocal,
65
+ onLocalCommentReactionAdded,
66
+ onLocalCommentReactionRemoved,
67
+ ];
68
+
69
+ return eventHandlers.map(handler => ({
70
+ fn: convertEventPayload(
71
+ (callback: Amity.Listener<Amity.InternalComment>) =>
72
+ commentEventHanlder(callback, handler, cacheKey, resolveId),
73
+ 'referenceId',
74
+ 'post',
75
+ ),
76
+ action: EnumPostActions.OnPostUpdated,
77
+ }));
78
+ };
79
+
80
+ export const getPostSubscription = (cacheKey: Amity.CacheKey) => {
81
+ return [
82
+ { fn: onPostCreated, action: EnumPostActions.OnPostCreated },
83
+ { fn: onPostUpdated, action: EnumPostActions.OnPostUpdated },
84
+ { fn: onPostUpdatedLocal, action: EnumPostActions.OnPostUpdated },
85
+ { fn: onPostDeleted, action: EnumPostActions.OnPostDeleted },
86
+ { fn: onPostFlagged, action: EnumPostActions.OnPostFlagged },
87
+ { fn: onPostUnflagged, action: EnumPostActions.OnPostUnflagged },
88
+ { fn: onPostApproved, action: EnumPostActions.OnPostApproved },
89
+ { fn: onPostDeclined, action: EnumPostActions.OnPostDeclined },
90
+ { fn: onPostReactionAdded, action: EnumPostActions.OnPostReactionAdded },
91
+ { fn: onPostReactionRemoved, action: EnumPostActions.OnPostReactionRemoved },
92
+ { fn: onLocalPostReactionAdded, action: EnumPostActions.OnPostReactionAdded },
93
+ { fn: onLocalPostReactionRemoved, action: EnumPostActions.OnPostReactionRemoved },
94
+ { fn: onLocalPostDeleted, action: EnumPostActions.OnPostDeleted },
95
+ ...generateCommentSubscriptions({ cacheKey }),
96
+ ];
97
+ };
@@ -1,28 +1,8 @@
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
- };
23
3
 
24
4
  export const preparePostPayload = (payload: Amity.PostPayload): Amity.ProcessedPostPayload => {
25
- const { posts: postsData, postChildren, videoStreamings, ...postPayload } = payload;
5
+ const { posts: postsData, ...postPayload } = payload;
26
6
 
27
7
  // Unpack community payload by mapping payload field to postSetting value.
28
8
  const communitiesWithPostSetting = addPostSetting({ communities: postPayload.communities });
@@ -44,34 +24,18 @@ export const preparePostPayload = (payload: Amity.PostPayload): Amity.ProcessedP
44
24
  mappedCommunityUsers,
45
25
  );
46
26
 
47
- let mappedNewStream: Amity.RawStream[] = [];
48
-
49
27
  // feed type
50
28
  const posts = postsData.map(post => {
51
29
  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
- }
63
30
 
64
31
  return {
65
32
  ...post,
66
- childPosts,
67
33
  feedType,
68
34
  };
69
35
  });
70
36
 
71
37
  return {
72
38
  ...postPayload,
73
- postChildren,
74
- videoStreamings: mappedNewStream,
75
39
  posts,
76
40
  communities: communityWithMembershipStatus,
77
41
  communityUsers: mappedCommunityUsers,
@@ -69,6 +69,7 @@ export const addReaction = async (
69
69
  ...model.data.reactions,
70
70
  [reactionName]: (model.data.reactions[reactionName] ?? 0) + 1,
71
71
  },
72
+ updatedAt: new Date().toISOString(),
72
73
  } as Amity.Models[Amity.ReactableType];
73
74
 
74
75
  if (referenceType === 'comment') {
@@ -72,6 +72,7 @@ export const removeReaction = async (
72
72
  ...model.data.reactions,
73
73
  [reactionName]: Math.max(0, (model.data.reactions[reactionName] ?? 0) - 1),
74
74
  },
75
+ updatedAt: new Date().toISOString(),
75
76
  } as Amity.Models[Amity.ReactableType];
76
77
 
77
78
  if (referenceType === 'comment') {
@@ -21,10 +21,7 @@ import { LinkedObject } from '~/utils/linkedObject';
21
21
  * @async
22
22
  */
23
23
  export const createStream = async (
24
- bundle: Pick<
25
- Amity.InternalStream,
26
- 'title' | 'thumbnailFileId' | 'description' | 'channelEnabled'
27
- > & {
24
+ bundle: Pick<Amity.InternalStream, 'title' | 'thumbnailFileId' | 'description'> & {
28
25
  isSecure?: boolean;
29
26
  },
30
27
  ): Promise<Amity.Cached<Amity.Stream>> => {
@@ -2,4 +2,3 @@ export * from './createStream';
2
2
  export * from './updateStream';
3
3
  export * from './deleteStream';
4
4
  export * from './disposeStream';
5
- export * from './editStream';
@@ -7,9 +7,6 @@ import { LinkedObject } from '~/utils/linkedObject';
7
7
  id: stream.update
8
8
  */
9
9
  /**
10
- * @deprecated this function is deprecated,
11
- * please use {@link Amity.StreamRepository.editStream} instead.
12
- *
13
10
  * ```js
14
11
  * import { updateStream } from '@amityco/ts-sdk'
15
12
  * const updated = await updateStream(streamId, { title: 'foobar' })
@@ -24,13 +21,9 @@ import { LinkedObject } from '~/utils/linkedObject';
24
21
  * @category Stream API
25
22
  * @async
26
23
  */
27
-
28
24
  export const updateStream = async (
29
25
  streamId: Amity.Stream['streamId'],
30
- patch: Patch<
31
- Amity.Stream,
32
- 'title' | 'thumbnailFileId' | 'description' | 'metadata' | 'channelEnabled'
33
- >,
26
+ patch: Patch<Amity.Stream, 'title' | 'thumbnailFileId' | 'description' | 'metadata'>,
34
27
  ): Promise<Amity.Cached<Amity.Stream>> => {
35
28
  const client = getActiveClient();
36
29
  client.log('stream/updateStream', streamId, patch);
@@ -3,5 +3,3 @@ export { onStreamStopped } from './onStreamStopped';
3
3
  export { onStreamRecorded } from './onStreamRecorded';
4
4
  export { onStreamFlagged } from './onStreamFlagged';
5
5
  export { onStreamTerminated } from './onStreamTerminated';
6
- export { onStreamViewerBanned } from './onStreamViewerBanned';
7
- export { onStreamViewerUnbanned } from './onStreamViewerUnbanned';
@@ -22,7 +22,7 @@ import { ingestInCache } from '~/cache/api/ingestInCache';
22
22
  */
23
23
  export const getStream = async (
24
24
  streamId: Amity.Stream['streamId'],
25
- ): Promise<Amity.Cached<Amity.InternalStream>> => {
25
+ ): Promise<Amity.Cached<Amity.Stream>> => {
26
26
  const client = getActiveClient();
27
27
  client.log('stream/getStream', streamId);
28
28
 
@@ -57,13 +57,13 @@ export const getStream = async (
57
57
  */
58
58
  getStream.locally = (
59
59
  streamId: Amity.Stream['streamId'],
60
- ): Amity.Cached<Amity.InternalStream> | undefined => {
60
+ ): Amity.Cached<Amity.Stream> | undefined => {
61
61
  const client = getActiveClient();
62
62
  client.log('stream/getStream', streamId);
63
63
 
64
64
  if (!client.cache) return;
65
65
 
66
- const cached = pullFromCache<Amity.InternalStream>(['stream', 'get', streamId]);
66
+ const cached = pullFromCache<Amity.Stream>(['stream', 'get', streamId]);
67
67
 
68
68
  if (!cached) return;
69
69
 
@@ -8,7 +8,6 @@ import { onStreamTerminated } from '~/streamRepository/events/onStreamTerminated
8
8
  import { LinkedObject } from '~/utils/linkedObject';
9
9
  import { getStream as _getStream } from '../internalApi/getStream';
10
10
  import { onStreamRecorded, onStreamStarted, onStreamStopped } from '../events';
11
- import { onStreamViewerBanned } from '../events/onStreamViewerBanned';
12
11
 
13
12
  /* begin_public_function
14
13
  id: stream.get
@@ -46,7 +45,6 @@ export const getStreamById = (
46
45
  onStreamStopped,
47
46
  onStreamFlagged,
48
47
  onStreamTerminated,
49
- onStreamViewerBanned,
50
48
  ]);
51
49
  };
52
50
  /* end_public_function */
@@ -12,8 +12,6 @@ import {
12
12
  } from '~/streamRepository/events';
13
13
  import { GetStreamsPageController } from '~/streamRepository/observers/getStreams/GetStreamsPageController';
14
14
  import { GetStreamsQueryStreamController } from '~/streamRepository/observers/getStreams/GetStreamsQueryStreamController';
15
- import { onStreamViewerBanned } from '~/streamRepository/events/onStreamViewerBanned';
16
- import { onStreamViewerUnbanned } from '~/streamRepository/events/onStreamViewerUnbanned';
17
15
 
18
16
  export class GetStreamsLiveCollectionController extends LiveCollectionController<
19
17
  'stream',
@@ -79,8 +77,6 @@ export class GetStreamsLiveCollectionController extends LiveCollectionController
79
77
  { fn: onStreamStopped, action: 'onStreamStopped' },
80
78
  { fn: onStreamFlagged, action: 'onStreamFlagged' },
81
79
  { fn: onStreamTerminated, action: 'onStreamTerminated' },
82
- { fn: onStreamViewerBanned, action: 'onStreamViewerBanned' },
83
- { fn: onStreamViewerUnbanned, action: 'onStreamViewerUnbanned' },
84
80
  ]);
85
81
  }
86
82
 
@@ -106,7 +102,7 @@ export class GetStreamsLiveCollectionController extends LiveCollectionController
106
102
  this.queryStreamController.appendToQueryStream(response, direction, refresh);
107
103
  }
108
104
 
109
- private applyFilter = (data: Amity.Stream[]): Amity.Stream[] => {
105
+ private applyFilter = (data: Amity.InternalStream[]): Amity.InternalStream[] => {
110
106
  let streams = filterByPropEquality(data, 'isDeleted', this.query.isDeleted);
111
107
 
112
108
  streams = streams.sort(
@@ -2,7 +2,6 @@ import { markAsRead } from '~/channelRepository/internalApi/markAsRead';
2
2
  import { shallowClone } from '../shallowClone';
3
3
  import { queryCache } from '~/cache/api';
4
4
  import { channelMemberLinkedObject } from './channelMemberLinkedObject';
5
- import { getMyMembership } from '~/channelRepository/observers/getMyMembership';
6
5
 
7
6
  export const channelLinkedObject = (channel: Amity.InternalChannel): Amity.Channel => {
8
7
  let previewMembers: Amity.Membership<'channel'>[] = [];
@@ -24,7 +23,5 @@ export const channelLinkedObject = (channel: Amity.InternalChannel): Amity.Chann
24
23
  return shallowClone(channel, {
25
24
  markAsRead: () => markAsRead(channel.channelInternalId),
26
25
  previewMembers,
27
- myMembership: (callback: Amity.LiveObjectCallback<Amity.Membership<'channel'> | undefined>) =>
28
- getMyMembership(channel.channelId, callback),
29
26
  });
30
27
  };
@@ -3,22 +3,15 @@ import { commentLinkedObject } from '~/utils/linkedObject/commentLinkedObject';
3
3
  import AnalyticsEngine from '../../analytic/service/analytic/AnalyticsEngine';
4
4
  import { userLinkedObject } from './userLinkedObject';
5
5
  import {
6
+ isAmityClipPost,
6
7
  isAmityFilePost,
7
8
  isAmityImagePost,
8
- isAmityLivestreamPost,
9
- isAmityPollPost,
10
9
  isAmityVideoPost,
11
10
  } from '../postTypePredicate';
12
- import { streamLinkedObject } from './streamLinkedObject';
13
- import { isNonNullable } from '..';
11
+ import { shallowClone } from '../shallowClone';
14
12
 
15
13
  export const postLinkedObject = (post: Amity.InternalPost): Amity.Post => {
16
- return {
17
- ...post,
18
- childrenPosts: post.children
19
- .map(childPost => pullFromCache<Amity.InternalPost>(['post', 'get', childPost])?.data)
20
- .filter(isNonNullable)
21
- .map(postLinkedObject),
14
+ return shallowClone(post, {
22
15
  analytics: {
23
16
  markAsViewed: () => {
24
17
  const analyticsEngineInstance = AnalyticsEngine.getInstance();
@@ -76,23 +69,10 @@ export const postLinkedObject = (post: Amity.InternalPost): Amity.Post => {
76
69
  : undefined;
77
70
  },
78
71
 
79
- getLivestreamInfo(): Amity.Stream | undefined {
80
- if (!isAmityLivestreamPost(post)) return;
81
- const cache = pullFromCache<Amity.InternalStream>([
82
- 'stream',
83
- 'get',
84
- post?.data?.streamId,
85
- ])?.data;
86
- if (!cache) return;
87
-
88
- return streamLinkedObject(cache);
89
- },
90
-
91
- getPollInfo(): Amity.Poll | undefined {
92
- if (!isAmityPollPost(post)) return;
93
- const cache = pullFromCache<Amity.Poll>(['poll', 'get', post?.data?.pollId])?.data;
94
- if (!cache) return;
95
- return cache;
72
+ getClipInfo(): Amity.File<'clip'> | undefined {
73
+ return isAmityClipPost(post)
74
+ ? pullFromCache<Amity.File<'clip'>>(['file', 'get', post?.data?.fileId])?.data
75
+ : undefined;
96
76
  },
97
- };
77
+ });
98
78
  };
@@ -1,5 +1,4 @@
1
1
  import { pullFromCache } from '~/cache/api';
2
- import { getLiveChat as _getLiveChat } from '~/streamRepository/internalApi/getLiveChat';
3
2
 
4
3
  export const streamLinkedObject = (stream: Amity.InternalStream): Amity.Stream => {
5
4
  return {
@@ -19,8 +18,5 @@ export const streamLinkedObject = (stream: Amity.InternalStream): Amity.Stream =
19
18
  get user() {
20
19
  return pullFromCache<Amity.User>(['user', 'get', stream.userId])?.data;
21
20
  },
22
- getLiveChat: () => _getLiveChat(stream),
23
- isBanned: !stream.watcherUrl,
24
- watcherUrl: null,
25
21
  };
26
22
  };