@amityco/ts-sdk 6.4.2-045209e.0 → 6.4.2-66daf4a.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.
@@ -20,7 +20,7 @@ export declare const markReadEngineOnLoginHandler: () => () => void;
20
20
  * @category Channel API
21
21
  * @async
22
22
  */
23
- export declare const startReading: (subChannelId: Amity.SubChannel['subChannelId']) => Promise<boolean> | undefined;
23
+ export declare const startReading: (subChannelId: Amity.SubChannel['subChannelId']) => Promise<boolean>;
24
24
  /**
25
25
  * ```js
26
26
  * import { stopReading } from '@amityco/ts-sdk'
@@ -1 +1 @@
1
- {"version":3,"file":"markReadEngine.d.ts","sourceRoot":"","sources":["../../../src/subChannelRepository/utils/markReadEngine.ts"],"names":[],"mappings":"AAiDA;;;;;GAKG;AACH,eAAO,MAAM,4BAA4B,kBAYxC,CAAC;AAgDF;;;;;;;;;;;;;;GAcG;AACH,eAAO,MAAM,YAAY,iBAAkB,MAAM,UAAU,CAAC,cAAc,CAAC,iCAS1E,CAAC;AAOF;;;;;;;;;;;;;;GAcG;AACH,eAAO,MAAM,WAAW,iBAAkB,MAAM,UAAU,CAAC,cAAc,CAAC,qBAIzE,CAAC"}
1
+ {"version":3,"file":"markReadEngine.d.ts","sourceRoot":"","sources":["../../../src/subChannelRepository/utils/markReadEngine.ts"],"names":[],"mappings":"AAiDA;;;;;GAKG;AACH,eAAO,MAAM,4BAA4B,kBAYxC,CAAC;AAgDF;;;;;;;;;;;;;;GAcG;AACH,eAAO,MAAM,YAAY,iBAAwB,MAAM,UAAU,CAAC,cAAc,CAAC,qBAchF,CAAC;AAOF;;;;;;;;;;;;;;GAcG;AACH,eAAO,MAAM,WAAW,iBAAkB,MAAM,UAAU,CAAC,cAAc,CAAC,qBAIzE,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@amityco/ts-sdk",
3
- "version": "6.4.2-045209e.0",
3
+ "version": "6.4.2-66daf4a.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",
@@ -193,3 +193,12 @@ export const stopUnreadSync = () => {
193
193
  setMarkerSyncEvents([]);
194
194
  unRegisterEventListeners();
195
195
  };
196
+
197
+ /**
198
+ * @deprecated Please use `startUnreadSync` instead
199
+ */
200
+ export const stopUnreadSyncing = () => {
201
+ console.warn('`stopUnreadSyncing` has been deprecated, please use `stopUnreadSync` instead');
202
+
203
+ return stopUnreadSync();
204
+ };
@@ -125,7 +125,9 @@ export const createMqttTransport = (endpoint: string): Amity.MqttClient => {
125
125
  },
126
126
  subscribe(topic: string, callback?: Amity.Listener<ASCError | void>): Amity.Unsubscriber {
127
127
  const callbackWrapper = (error: Error, granted: ISubscriptionGrant[]) => {
128
- if (error || granted[0].qos === QOS_FAILURE_CODE) {
128
+ // In MQTT.js, when you subscribe to a topic with QoS 0, the granted parameter
129
+ // in the callback will typically be empty or undefined
130
+ if (error || granted[0]?.qos === QOS_FAILURE_CODE) {
129
131
  const ascError = error
130
132
  ? new ASCError(error.message, Amity.ClientError.UNKNOWN_ERROR, Amity.ErrorLevel.ERROR)
131
133
  : // TODO throw the actual error, once BE can tell us the actual error code
@@ -135,7 +137,7 @@ export const createMqttTransport = (endpoint: string): Amity.MqttClient => {
135
137
  console.warn(`Failed to subscribe to topic ${topic}`, ascError);
136
138
  callback?.(ascError);
137
139
  } else {
138
- console.log(`Subscribed to topic ${granted[0].topic}`);
140
+ console.log(`Subscribed to topic ${topic}`);
139
141
  callback?.();
140
142
  }
141
143
  };
@@ -25,12 +25,12 @@ const getReadingSubChannels = () => {
25
25
  /**
26
26
  * call start reading API with reading list
27
27
  */
28
- const startReadingFromReadingList = () => {
28
+ const startReadingFromReadingList = async () => {
29
29
  const isReadingSubChannelIds = getReadingSubChannels();
30
30
 
31
31
  if (isReadingSubChannelIds.length === 0) {
32
32
  // no subChannel that require to call start reading API
33
- return;
33
+ return false;
34
34
  }
35
35
 
36
36
  return startReadingAPI(isReadingSubChannelIds);
@@ -128,7 +128,7 @@ const disposeAll = () => {
128
128
  * @category Channel API
129
129
  * @async
130
130
  */
131
- export const startReading = (subChannelId: Amity.SubChannel['subChannelId']) => {
131
+ export const startReading = async (subChannelId: Amity.SubChannel['subChannelId']) => {
132
132
  isReadingMap[subChannelId] = true;
133
133
 
134
134
  if (disposers.length === 0) {
@@ -136,7 +136,12 @@ export const startReading = (subChannelId: Amity.SubChannel['subChannelId']) =>
136
136
  registerTopicSubscribers(subChannelId);
137
137
  }
138
138
 
139
- return startReadingFromReadingList();
139
+ try {
140
+ return await startReadingFromReadingList();
141
+ } catch (e) {
142
+ isReadingMap[subChannelId] = false;
143
+ return false;
144
+ }
140
145
  };
141
146
  /* end_public_function */
142
147