@mtkruto/node 0.1.126 → 0.1.127

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.
@@ -4,7 +4,7 @@ export type PublicKeys = readonly [bigint, [bigint, bigint]][];
4
4
  export declare const PUBLIC_KEYS: PublicKeys;
5
5
  export declare const INITIAL_DC: DC;
6
6
  export declare const LAYER = 167;
7
- export declare const APP_VERSION = "MTKruto 0.1.126";
7
+ export declare const APP_VERSION = "MTKruto 0.1.127";
8
8
  export declare const DEVICE_MODEL: string;
9
9
  export declare const LANG_CODE: string;
10
10
  export declare const LANG_PACK = "";
@@ -53,7 +53,7 @@ export const PUBLIC_KEYS = Object.freeze([
53
53
  ]);
54
54
  export const INITIAL_DC = "2";
55
55
  export const LAYER = 167;
56
- export const APP_VERSION = "MTKruto 0.1.126";
56
+ export const APP_VERSION = "MTKruto 0.1.127";
57
57
  // @ts-ignore: lib
58
58
  export const DEVICE_MODEL = typeof dntShim.Deno === "undefined" ? typeof navigator === "undefined" ? typeof process === "undefined" ? "Unknown" : process.platform + "-" + process.arch : navigator.userAgent.split(" ")[0] : dntShim.Deno.build.os + "-" + dntShim.Deno.build.arch;
59
59
  export const LANG_CODE = typeof navigator === "undefined" ? "en" : navigator.language.split("-")[0];
@@ -2277,7 +2277,7 @@ export class Client extends ClientAbstract {
2277
2277
  let chats = __classPrivateFieldGet(this, _Client_instances, "m", _Client_getLoadedChats).call(this, listId);
2278
2278
  if (params?.after) {
2279
2279
  chats = chats
2280
- .filter((v) => v.id < params.after.id);
2280
+ .filter((v) => v.order < params.after.order);
2281
2281
  }
2282
2282
  if (chats.length < limit) {
2283
2283
  d("have only %d chats but %d more is needed", chats.length, limit - chats.length);
@@ -2715,7 +2715,7 @@ async function _Client_setMyInfo(info) {
2715
2715
  if (!(dialogs instanceof types.messages.Dialogs) && !(dialogs instanceof types.messages.DialogsSlice)) {
2716
2716
  UNREACHABLE();
2717
2717
  }
2718
- if (dialogs.dialogs.length == 0) {
2718
+ if (dialogs.dialogs.length < limit) {
2719
2719
  await this.storage.setHasAllChats(listId, true);
2720
2720
  }
2721
2721
  const chats = __classPrivateFieldGet(this, _Client_instances, "m", _Client_getChatList).call(this, listId);
@@ -208,9 +208,14 @@ export class Storage {
208
208
  if (offsetId == 0) {
209
209
  offsetId = Infinity;
210
210
  }
211
+ ++limit;
211
212
  const messages = new Array();
212
213
  for await (const [_, buffer] of await this.getMany({ start: KPARTS_MESSAGE(chatId, 0), end: KPARTS_MESSAGE(chatId, offsetId) }, { limit, reverse: true })) {
213
- messages.push(await this.getTLObject(buffer));
214
+ const message = await this.getTLObject(buffer);
215
+ if ("id" in message && message.id == offsetId) {
216
+ continue;
217
+ }
218
+ messages.push(message);
214
219
  }
215
220
  return messages;
216
221
  }
@@ -297,33 +297,24 @@ export async function constructMessage(message_, getEntity, getMessage, getStick
297
297
  message.forwardSenderName = message_.fwd_from.from_name;
298
298
  message.forwardId = message_.fwd_from.channel_post;
299
299
  message.forwardSignature = message_.fwd_from.post_author;
300
- message.forwardDate = new Date(message_.date * 1000);
300
+ message.forwardDate = new Date(message_.fwd_from.date * 1000);
301
301
  if (message_.fwd_from.from_id instanceof types.PeerUser) {
302
302
  const entity = await getEntity(message_.fwd_from.from_id);
303
303
  if (entity) {
304
304
  message.forwardFrom = constructUser(entity);
305
305
  }
306
- else {
307
- UNREACHABLE();
308
- }
309
306
  }
310
307
  else if (message_.fwd_from.from_id instanceof types.PeerChat) {
311
308
  const entity = await getEntity(message_.fwd_from.from_id);
312
309
  if (entity) {
313
310
  message.forwardFromChat = constructChatP(entity);
314
311
  }
315
- else {
316
- UNREACHABLE();
317
- }
318
312
  }
319
313
  else if (message_.fwd_from.from_id instanceof types.PeerChannel) {
320
314
  const entity = await getEntity(message_.fwd_from.from_id);
321
315
  if (entity) {
322
316
  message.forwardFromChat = constructChatP(entity);
323
317
  }
324
- else {
325
- UNREACHABLE();
326
- }
327
318
  }
328
319
  }
329
320
  if (message_.media) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mtkruto/node",
3
- "version": "0.1.126",
3
+ "version": "0.1.127",
4
4
  "description": "MTKruto for Node.js",
5
5
  "author": "Roj <rojvv@icloud.com>",
6
6
  "repository": {
@@ -4,7 +4,7 @@ export type PublicKeys = readonly [bigint, [bigint, bigint]][];
4
4
  export declare const PUBLIC_KEYS: PublicKeys;
5
5
  export declare const INITIAL_DC: DC;
6
6
  export declare const LAYER = 167;
7
- export declare const APP_VERSION = "MTKruto 0.1.126";
7
+ export declare const APP_VERSION = "MTKruto 0.1.127";
8
8
  export declare const DEVICE_MODEL: string;
9
9
  export declare const LANG_CODE: string;
10
10
  export declare const LANG_PACK = "";
@@ -79,7 +79,7 @@ exports.PUBLIC_KEYS = Object.freeze([
79
79
  ]);
80
80
  exports.INITIAL_DC = "2";
81
81
  exports.LAYER = 167;
82
- exports.APP_VERSION = "MTKruto 0.1.126";
82
+ exports.APP_VERSION = "MTKruto 0.1.127";
83
83
  // @ts-ignore: lib
84
84
  exports.DEVICE_MODEL = typeof dntShim.Deno === "undefined" ? typeof navigator === "undefined" ? typeof process === "undefined" ? "Unknown" : process.platform + "-" + process.arch : navigator.userAgent.split(" ")[0] : dntShim.Deno.build.os + "-" + dntShim.Deno.build.arch;
85
85
  exports.LANG_CODE = typeof navigator === "undefined" ? "en" : navigator.language.split("-")[0];
@@ -2282,7 +2282,7 @@ class Client extends _1_client_abstract_js_1.ClientAbstract {
2282
2282
  let chats = __classPrivateFieldGet(this, _Client_instances, "m", _Client_getLoadedChats).call(this, listId);
2283
2283
  if (params?.after) {
2284
2284
  chats = chats
2285
- .filter((v) => v.id < params.after.id);
2285
+ .filter((v) => v.order < params.after.order);
2286
2286
  }
2287
2287
  if (chats.length < limit) {
2288
2288
  d("have only %d chats but %d more is needed", chats.length, limit - chats.length);
@@ -2721,7 +2721,7 @@ async function _Client_setMyInfo(info) {
2721
2721
  if (!(dialogs instanceof _2_tl_js_1.types.messages.Dialogs) && !(dialogs instanceof _2_tl_js_1.types.messages.DialogsSlice)) {
2722
2722
  (0, _1_utilities_js_1.UNREACHABLE)();
2723
2723
  }
2724
- if (dialogs.dialogs.length == 0) {
2724
+ if (dialogs.dialogs.length < limit) {
2725
2725
  await this.storage.setHasAllChats(listId, true);
2726
2726
  }
2727
2727
  const chats = __classPrivateFieldGet(this, _Client_instances, "m", _Client_getChatList).call(this, listId);
@@ -211,9 +211,14 @@ class Storage {
211
211
  if (offsetId == 0) {
212
212
  offsetId = Infinity;
213
213
  }
214
+ ++limit;
214
215
  const messages = new Array();
215
216
  for await (const [_, buffer] of await this.getMany({ start: KPARTS_MESSAGE(chatId, 0), end: KPARTS_MESSAGE(chatId, offsetId) }, { limit, reverse: true })) {
216
- messages.push(await this.getTLObject(buffer));
217
+ const message = await this.getTLObject(buffer);
218
+ if ("id" in message && message.id == offsetId) {
219
+ continue;
220
+ }
221
+ messages.push(message);
217
222
  }
218
223
  return messages;
219
224
  }
@@ -300,33 +300,24 @@ async function constructMessage(message_, getEntity, getMessage, getStickerSetNa
300
300
  message.forwardSenderName = message_.fwd_from.from_name;
301
301
  message.forwardId = message_.fwd_from.channel_post;
302
302
  message.forwardSignature = message_.fwd_from.post_author;
303
- message.forwardDate = new Date(message_.date * 1000);
303
+ message.forwardDate = new Date(message_.fwd_from.date * 1000);
304
304
  if (message_.fwd_from.from_id instanceof _2_tl_js_1.types.PeerUser) {
305
305
  const entity = await getEntity(message_.fwd_from.from_id);
306
306
  if (entity) {
307
307
  message.forwardFrom = (0, _1_user_js_1.constructUser)(entity);
308
308
  }
309
- else {
310
- (0, _1_utilities_js_1.UNREACHABLE)();
311
- }
312
309
  }
313
310
  else if (message_.fwd_from.from_id instanceof _2_tl_js_1.types.PeerChat) {
314
311
  const entity = await getEntity(message_.fwd_from.from_id);
315
312
  if (entity) {
316
313
  message.forwardFromChat = (0, _1_chat_p_js_1.constructChatP)(entity);
317
314
  }
318
- else {
319
- (0, _1_utilities_js_1.UNREACHABLE)();
320
- }
321
315
  }
322
316
  else if (message_.fwd_from.from_id instanceof _2_tl_js_1.types.PeerChannel) {
323
317
  const entity = await getEntity(message_.fwd_from.from_id);
324
318
  if (entity) {
325
319
  message.forwardFromChat = (0, _1_chat_p_js_1.constructChatP)(entity);
326
320
  }
327
- else {
328
- (0, _1_utilities_js_1.UNREACHABLE)();
329
- }
330
321
  }
331
322
  }
332
323
  if (message_.media) {