@pmate/chat-sdk 0.12.0-next.21 → 0.12.0-next.22
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.
|
@@ -144,8 +144,10 @@ export class ChatSession {
|
|
|
144
144
|
refreshReading() { this.assertOpen(); this.reading.refresh(); }
|
|
145
145
|
synchronizeReading(cursor, profileId) { this.assertOpen(); return this.reading.synchronize(cursor, profileId); }
|
|
146
146
|
/** Explicit text-history acknowledgement; unheard audio stays unread. */
|
|
147
|
-
markRead(threadId, messages = []) { this.assertOpen(); return this.reading.markRead(threadId, messages)
|
|
148
|
-
|
|
147
|
+
markRead(threadId, messages = []) { this.assertOpen(); return this.reading.markRead(threadId, messages).then(next => { if (this.withdrawn)
|
|
148
|
+
throw new Error("CHAT_ACCESS_REVOKED"); return next; }); }
|
|
149
|
+
updateReading(transform) { this.assertOpen(); return this.reading.update(transform).then(next => { if (this.withdrawn)
|
|
150
|
+
throw new Error("CHAT_ACCESS_REVOKED"); return next; }); }
|
|
149
151
|
assertOpen() { if (this.withdrawn)
|
|
150
152
|
throw new Error("CHAT_ACCESS_REVOKED"); if (this.closed)
|
|
151
153
|
throw new Error("CHAT_SESSION_CLOSED"); }
|
|
@@ -170,6 +172,7 @@ export class ChatSession {
|
|
|
170
172
|
await this.sender.confirm(page.messages.map(message => message.id));
|
|
171
173
|
if (this.initializing && !this.readingStarted && page.complete)
|
|
172
174
|
await this.startReading();
|
|
175
|
+
this.assertOpen();
|
|
173
176
|
const edge = this.historyEdges.get(threadId);
|
|
174
177
|
if (!options.before && page.complete && (!edge || edge.version !== page.resetVersion))
|
|
175
178
|
this.rememberHistoryEdge(threadId, page);
|
|
@@ -230,6 +233,7 @@ export class ChatSession {
|
|
|
230
233
|
return { messages: pages.reverse().flat(), hasEarlier: false, complete: true, resetVersion: version };
|
|
231
234
|
}
|
|
232
235
|
catch (error) {
|
|
236
|
+
this.assertOpen();
|
|
233
237
|
if ([401, 403].includes(error?.status ?? 0))
|
|
234
238
|
throw error;
|
|
235
239
|
if (String(error).includes("MESSAGE_PROJECTION_CHANGED"))
|
|
@@ -243,7 +247,8 @@ export class ChatSession {
|
|
|
243
247
|
}
|
|
244
248
|
sendMessage(threadId, input) {
|
|
245
249
|
this.assertOpen();
|
|
246
|
-
return this.sender.enqueue(threadId, input)
|
|
250
|
+
return this.sender.enqueue(threadId, input).then(next => { if (this.withdrawn)
|
|
251
|
+
throw new Error("CHAT_ACCESS_REVOKED"); return next; });
|
|
247
252
|
}
|
|
248
253
|
async getReaders(threadId, messageId, page = {}, signal) {
|
|
249
254
|
this.assertOpen();
|
|
@@ -269,7 +274,7 @@ export class ChatSession {
|
|
|
269
274
|
}
|
|
270
275
|
if (!threadId)
|
|
271
276
|
throw new Error("INVALID_READING_THREAD");
|
|
272
|
-
return event === "played" ? this.reading.recordExplicit(threadId, ids) : this.reading.recordVisible(threadId, ids);
|
|
277
|
+
return (event === "played" ? this.reading.recordExplicit(threadId, ids) : this.reading.recordVisible(threadId, ids)).then(next => { this.assertOpen(); return next; });
|
|
273
278
|
}
|
|
274
279
|
/** Bridge transports can delegate social events without maintaining clients. */
|
|
275
280
|
async handleReach(event) {
|
package/package.json
CHANGED