@mtcute/core 0.12.0 → 0.12.2

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.
@@ -50,6 +50,14 @@ type TelegramClientOptions = ((PartialOnly<Omit<BaseTelegramClientOptions, 'stor
50
50
  }) | {
51
51
  client: ITelegramClient;
52
52
  }) & {
53
+ /**
54
+ * If true, all API calls will be wrapped with `tl.invokeWithoutUpdates`,
55
+ * effectively disabling the server-sent events for the clients.
56
+ * May be useful in some cases.
57
+ *
58
+ * @default false
59
+ */
60
+ disableUpdates?: boolean;
53
61
  updates?: Omit<ParsedUpdateHandlerParams, 'onUpdate'>;
54
62
  /**
55
63
  * If `true`, the updates that were handled by some {@link Conversation}
@@ -254,20 +254,22 @@ export class TelegramClient extends EventEmitter {
254
254
  this.log = this._client.log;
255
255
  // @ts-expect-error codegen
256
256
  this.storage = this._client.storage;
257
- const skipConversationUpdates = opts.skipConversationUpdates ?? true;
258
- const { messageGroupingInterval } = opts.updates ?? {};
259
- this._client.onUpdate(makeParsedUpdateHandler({
260
- messageGroupingInterval,
261
- onUpdate: (update) => {
262
- if (Conversation.handleUpdate(this._client, update) && skipConversationUpdates)
263
- return;
264
- this.emit('update', update);
265
- this.emit(update.name, update.data);
266
- },
267
- onRawUpdate: (update, peers) => {
268
- this.emit('raw_update', update, peers);
269
- },
270
- }));
257
+ if (!opts.disableUpdates) {
258
+ const skipConversationUpdates = opts.skipConversationUpdates ?? true;
259
+ const { messageGroupingInterval } = opts.updates ?? {};
260
+ this._client.onUpdate(makeParsedUpdateHandler({
261
+ messageGroupingInterval,
262
+ onUpdate: (update) => {
263
+ if (Conversation.handleUpdate(this._client, update) && skipConversationUpdates)
264
+ return;
265
+ this.emit('update', update);
266
+ this.emit(update.name, update.data);
267
+ },
268
+ onRawUpdate: (update, peers) => {
269
+ this.emit('raw_update', update, peers);
270
+ },
271
+ }));
272
+ }
271
273
  }
272
274
  withParams(params) {
273
275
  return withParams(this, params);