@amityco/ts-sdk 6.11.2-d34866e.0 → 6.11.2-e853528.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.
@@ -0,0 +1,17 @@
1
+ /**
2
+ * ```js
3
+ * import { onChannelMarkerUpdated } from '@amityco/ts-sdk'
4
+ * const dispose = onChannelMarkerUpdated(channelMarker => {
5
+ * // ...
6
+ * })
7
+ * ```
8
+ *
9
+ * Fired when an {@link Amity.ChannelMarker} has been updated
10
+ *
11
+ * @param callback The function to call when the event was fired
12
+ * @returns an {@link Amity.Unsubscriber} function to stop listening
13
+ *
14
+ * @category ChannelMarker Events
15
+ */
16
+ export declare const onChannelMarkerUpdated: (callback: Amity.Listener<Amity.ChannelMarker>) => Amity.Unsubscriber;
17
+ //# sourceMappingURL=onChannelMarkerUpdated.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"onChannelMarkerUpdated.d.ts","sourceRoot":"","sources":["../../../src/marker/events/onChannelMarkerUpdated.ts"],"names":[],"mappings":"AAGA;;;;;;;;;;;;;;GAcG;AACH,eAAO,MAAM,sBAAsB,aACvB,MAAM,QAAQ,CAAC,MAAM,aAAa,CAAC,KAC5C,MAAM,YAaR,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"isPostFlaggedByMe.d.ts","sourceRoot":"","sources":["../../../src/postRepository/api/isPostFlaggedByMe.ts"],"names":[],"mappings":"AAMA;;;;;;;;;;;KAWK;AACL,eAAO,MAAM,iBAAiB,WAAkB,MAAM,IAAI,CAAC,QAAQ,CAAC,KAAG,QAAQ,OAAO,CAarF,CAAC"}
1
+ {"version":3,"file":"isPostFlaggedByMe.d.ts","sourceRoot":"","sources":["../../../src/postRepository/api/isPostFlaggedByMe.ts"],"names":[],"mappings":"AAKA;;;;;;;;;;;KAWK;AACL,eAAO,MAAM,iBAAiB,WAAkB,MAAM,IAAI,CAAC,QAAQ,CAAC,KAAG,QAAQ,OAAO,CASrF,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@amityco/ts-sdk",
3
- "version": "6.11.2-d34866e.0",
3
+ "version": "6.11.2-e853528.0",
4
4
  "license": "CC-BY-ND-4.0",
5
5
  "author": "amity.co <developers@amity.co> (https://amity.co)",
6
6
  "description": "Amity Social Cloud Typescript SDK",
@@ -165,6 +165,7 @@ declare global {
165
165
  'poll.deleted': MakeRequired<Amity.PollPayload, 'polls'>;
166
166
  'local.feedMarker.fetched': { feedMarkers: Amity.FeedMarker[] };
167
167
  'local.channelMarker.fetched': { userEntityMarkers: Amity.ChannelMarker[] };
168
+ 'local.channelMarker.updated': { userEntityMarkers: Amity.ChannelMarker[] };
168
169
  'local.subChannelMarker.fetched': { userFeedMarkers: Amity.SubChannelMarker[] };
169
170
  'local.subChannelMarker.updated': { userFeedMarkers: Amity.SubChannelMarker[] };
170
171
  'local.messageMarker.fetched': MakeRequired<Amity.MessageMarkerPayload, 'contentMarkers'>;
@@ -5,6 +5,7 @@ import {
5
5
  convertSubChannelMarkerResponse,
6
6
  convertUserMarkerResponse,
7
7
  } from '~/utils/marker';
8
+ import { fireEvent } from '~/core/events';
8
9
 
9
10
  /**
10
11
  * ```js
@@ -37,16 +38,22 @@ export const markAsRead = async (channelId: Amity.Channel['channelId']): Promise
37
38
 
38
39
  const cachedAt = client.cache && Date.now();
39
40
 
41
+ const channelMarkers = convertChannelMarkerResponse(userEntityMarkersPayload);
42
+
40
43
  if (client.cache)
41
44
  ingestInCache(
42
45
  {
43
46
  userMarkers: convertUserMarkerResponse(userMarkersPayload),
44
- userEntityMarkers: convertChannelMarkerResponse(userEntityMarkersPayload),
47
+ userEntityMarkers: channelMarkers,
45
48
  userFeedMarkers: convertSubChannelMarkerResponse(userFeedMarkersPayload),
46
49
  ...rest,
47
50
  },
48
51
  { cachedAt },
49
52
  );
50
53
 
54
+ fireEvent('local.channelMarker.updated', {
55
+ userEntityMarkers: channelMarkers,
56
+ });
57
+
51
58
  return true;
52
59
  };
@@ -28,6 +28,7 @@ import { getActiveClient } from '~/client/api/activeClient';
28
28
  import { getChannelMessagePreviewWithUser } from '~/messagePreview/utils';
29
29
  import { isEqual } from '~/utils/isEqual';
30
30
  import { updateChannelCache } from '../utils/updateChannelCache';
31
+ import { onChannelMarkerUpdated } from '~/marker/events/onChannelMarkerUpdated';
31
32
 
32
33
  /* begin_public_function
33
34
  id: channel.get
@@ -98,6 +99,7 @@ export const getChannel = (
98
99
  onChannelMemberUnbanned,
99
100
  onChannelMuted,
100
101
  convertEventPayload(onChannelMarkerFetched, 'entityId', 'channel'),
102
+ convertEventPayload(onChannelMarkerUpdated, 'entityId', 'channel'),
101
103
  convertEventPayload(
102
104
  (callback: Amity.Listener<Amity.Message>) => {
103
105
  const updateMessagePreview = async (message: Amity.Message) => {
@@ -47,6 +47,7 @@ import {
47
47
  handleSubChannelUpdated,
48
48
  } from '~/messagePreview/utils/updateMessagePreviewFromMessage';
49
49
  import { updateChannelCache } from '../utils/updateChannelCache';
50
+ import { onChannelMarkerUpdated } from '~/marker/events/onChannelMarkerUpdated';
50
51
 
51
52
  /* begin_public_function
52
53
  id: channel.query
@@ -232,6 +233,7 @@ export const getChannels = (
232
233
  onChannelMemberAdded(realtimeRouter('onMemberAdded')),
233
234
  onChannelMemberRemoved(realtimeRouter('onMemberRemoved')),
234
235
  convertEventPayload(onChannelMarkerFetched, 'entityId', 'channel')(realtimeRouter('onUpdate')),
236
+ convertEventPayload(onChannelMarkerUpdated, 'entityId', 'channel')(realtimeRouter('onUpdate')),
235
237
  convertEventPayload(
236
238
  (callback: Amity.Listener<Amity.Message>) => {
237
239
  const updateMessagePreview = async (message: Amity.Message) => {
@@ -0,0 +1,34 @@
1
+ import { getActiveClient } from '~/client/api';
2
+ import { createEventSubscriber } from '~/core/events';
3
+
4
+ /**
5
+ * ```js
6
+ * import { onChannelMarkerUpdated } from '@amityco/ts-sdk'
7
+ * const dispose = onChannelMarkerUpdated(channelMarker => {
8
+ * // ...
9
+ * })
10
+ * ```
11
+ *
12
+ * Fired when an {@link Amity.ChannelMarker} has been updated
13
+ *
14
+ * @param callback The function to call when the event was fired
15
+ * @returns an {@link Amity.Unsubscriber} function to stop listening
16
+ *
17
+ * @category ChannelMarker Events
18
+ */
19
+ export const onChannelMarkerUpdated = (
20
+ callback: Amity.Listener<Amity.ChannelMarker>,
21
+ ): Amity.Unsubscriber => {
22
+ const client = getActiveClient();
23
+
24
+ const filter = (payload: Amity.Events['local.channelMarker.updated']) => {
25
+ callback(payload.userEntityMarkers[0]);
26
+ };
27
+
28
+ return createEventSubscriber(
29
+ client,
30
+ 'channelMarker/onChannelMarkerUpdated',
31
+ 'local.channelMarker.updated',
32
+ filter,
33
+ );
34
+ };
@@ -1,5 +1,4 @@
1
1
  import { getActiveClient } from '~/client/api/activeClient';
2
- import { synchronousWSCall } from '~/core/transports';
3
2
 
4
3
  /* begin_public_function
5
4
  id: post.check_flag_by_me
@@ -20,14 +19,10 @@ export const isPostFlaggedByMe = async (postId: Amity.Post['postId']): Promise<b
20
19
  const client = getActiveClient();
21
20
  client.log('post/isPostFlaggedByMe', postId);
22
21
 
23
- const { result, isFlagByMe } =
24
- (await synchronousWSCall<{
25
- result?: boolean;
26
- isFlagByMe?: boolean;
27
- }>(client, 'v3/post.isflagbyme', {
28
- postId,
29
- })) ?? {};
22
+ const {
23
+ data: { result },
24
+ } = await client.http.get(`/api/v3/posts/${postId}/isflagbyme`);
30
25
 
31
- return result ?? isFlagByMe ?? false;
26
+ return result;
32
27
  };
33
28
  /* end_public_function */