desktop: fix "object has been destoryed" error

This commit is contained in:
Abdullah Atta
2023-06-23 11:51:01 +05:00
parent 99808293a7
commit eb35d41321
3 changed files with 25 additions and 2 deletions

View File

@@ -12,7 +12,7 @@
"@trpc/client": "^10.29.1",
"@trpc/server": "^10.29.1",
"diary": "^0.3.1",
"electron-trpc": "^0.5.0",
"electron-trpc": "^0.5.2",
"electron-updater": "^5.3.0",
"icojs": "^0.17.1",
"typed-emitter": "^2.1.0",

View File

@@ -15,7 +15,7 @@
"@trpc/client": "^10.29.1",
"@trpc/server": "^10.29.1",
"diary": "^0.3.1",
"electron-trpc": "^0.5.0",
"electron-trpc": "^0.5.2",
"electron-updater": "^5.3.0",
"icojs": "^0.17.1",
"typed-emitter": "^2.1.0",

View File

@@ -0,0 +1,23 @@
diff --git a/node_modules/electron-trpc/dist/main.mjs b/node_modules/electron-trpc/dist/main.mjs
index 379cf3b..2644e5d 100644
--- a/node_modules/electron-trpc/dist/main.mjs
+++ b/node_modules/electron-trpc/dist/main.mjs
@@ -221,9 +221,16 @@ class G {
i(this, c).includes(r) || (i(this, c).push(r), I(this, T, W).call(this, r));
}
detachWindow(r) {
+
y(this, c, i(this, c).filter((n) => n !== r));
- for (const [n, t] of i(this, u).entries())
- n.startsWith(`${r.webContents.id}-`) && (t.unsubscribe(), i(this, u).delete(n));
+ for (const [n, t] of i(this, u).entries()) {
+ try {
+ n.startsWith(`${r.webContents.id}-`) && (t.unsubscribe(), i(this, u).delete(n));
+ } catch(e) {
+ console.error(e);
+ // ignore
+ }
+ }
}
}
c = new WeakMap(), u = new WeakMap(), T = new WeakSet(), W = function(r) {