Browse Source

try to fix caching again

painor 4 years ago
parent
commit
63f83e2f74
3 changed files with 18 additions and 5 deletions
  1. 11 3
      gramjs/Utils.ts
  2. 6 1
      gramjs/events/NewMessage.ts
  3. 1 1
      package.json

+ 11 - 3
gramjs/Utils.ts

@@ -150,9 +150,17 @@ export function _getEntityPair(entityId: number, entities: Map<number, Entity>,
                                getInputPeerFunction: any = getInputPeer): [Entity?, Api.TypeInputPeer?] {
 
     const entity = entities.get(entityId);
-    let inputEntity = cache.get(entityId);
-    if (!inputEntity) {
-        inputEntity = getInputPeerFunction(inputEntity);
+    let inputEntity;
+    try {
+        inputEntity = cache.get(entityId);
+
+    } catch (e) {
+        try {
+            inputEntity = getInputPeerFunction(inputEntity);
+
+        } catch (e) {
+
+        }
     }
     return [entity, inputEntity]
 

+ 6 - 1
gramjs/events/NewMessage.ts

@@ -143,6 +143,11 @@ export class NewMessageEvent extends EventCommon {
     _setClient(client: TelegramClient) {
         super._setClient(client);
         const m = this.message;
-        m._finishInit(client, this.message._entities, undefined);
+        try {
+            // todo make sure this never fails
+            m._finishInit(client, this.message._entities, undefined);
+        } catch (e) {
+
+        }
     }
 }

+ 1 - 1
package.json

@@ -1,6 +1,6 @@
 {
   "name": "telegram",
-  "version": "1.5.9",
+  "version": "1.5.11",
   "description": "NodeJS MTProto API Telegram client library,",
   "main": "index.js",
   "types": "index.d.ts",