[FIX] devtools: fix apps patching and reload

This commit fixes issues introduced in the previous fix for the apps
methods patching and also fixes the status of the profiler tracing
on reload.
This commit is contained in:
Julien Carion (juca)
2023-04-27 12:57:57 +02:00
committed by Géry Debongnie
parent 9cc0f88e02
commit fe31f93c94
2 changed files with 18 additions and 3 deletions
@@ -509,7 +509,10 @@ export const store = reactive({
this.eventsTree = []; this.eventsTree = [];
this.activeRecorder = false; this.activeRecorder = false;
evalFunctionInWindow("toggleEventsRecording", [false, 0]); evalFunctionInWindow("toggleEventsRecording", [false, 0]);
this.traceRenderings = false;
evalFunctionInWindow("toggleTracing", [false]); evalFunctionInWindow("toggleTracing", [false]);
this.traceSubscriptions = false;
evalFunctionInWindow("toggleSubscriptionTracing", [false]);
}, },
// Triggers manually the rendering of the selected component // Triggers manually the rendering of the selected component
@@ -46,6 +46,9 @@
this.appsPatched = false; this.appsPatched = false;
this.destroyPatched = false; this.destroyPatched = false;
this.patchAppsSetMethods(); this.patchAppsSetMethods();
if (this.apps.size > 0) {
this.patchAppMethods();
}
this.recordEvents = false; this.recordEvents = false;
this.traceRenderings = false; this.traceRenderings = false;
this.traceSubscriptions = false; this.traceSubscriptions = false;
@@ -241,13 +244,22 @@
return; return;
} }
let app = this.apps.values().next().value; let app = this.apps.values().next().value;
if (!app) { const self = this;
return; if (app.root) {
this.patchDestroyMethod(app.root);
} else {
const originalMount = app.constructor.prototype.mount;
app.constructor.prototype.mount = async function (...args) {
const result = await originalMount.call(this, ...args);
const root = this.root;
self.patchDestroyMethod(root);
app.constructor.prototype.mount = originalMount;
return result;
};
} }
const originalFlush = app.scheduler.constructor.prototype.flush; const originalFlush = app.scheduler.constructor.prototype.flush;
let inFlush = false; let inFlush = false;
let _render = false; let _render = false;
const self = this;
app.scheduler.constructor.prototype.flush = function () { app.scheduler.constructor.prototype.flush = function () {
// Used to know when a render is triggered inside the flush method or not // Used to know when a render is triggered inside the flush method or not
inFlush = true; inFlush = true;