mirror of
https://github.com/PR0M3TH3AN/bitvid.git
synced 2026-11-10 23:01:10 +00:00
Preserve modal infrastructure across playback cleanup
This commit is contained in:
1 parent
eb1dfc194f
commit
f6a41e7220
1 file changed
+26
-15
@@ -4454,10 +4454,18 @@ class Application {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Cleanup resources on unload or modal close.
|
* Cleanup resources on unload or modal close.
|
||||||
|
*
|
||||||
|
* When `preserveModals` is true the modal infrastructure is kept alive so the
|
||||||
|
* next playback session can reuse the existing controllers without
|
||||||
|
* reinitializing DOM bindings.
|
||||||
*/
|
*/
|
||||||
async cleanup({ preserveSubscriptions = false, preserveObservers = false } = {}) {
|
async cleanup({
|
||||||
|
preserveSubscriptions = false,
|
||||||
|
preserveObservers = false,
|
||||||
|
preserveModals = false,
|
||||||
|
} = {}) {
|
||||||
this.log(
|
this.log(
|
||||||
`[cleanup] Requested (preserveSubscriptions=${preserveSubscriptions}, preserveObservers=${preserveObservers})`
|
`[cleanup] Requested (preserveSubscriptions=${preserveSubscriptions}, preserveObservers=${preserveObservers}, preserveModals=${preserveModals})`
|
||||||
);
|
);
|
||||||
// Serialise teardown so overlapping calls (e.g. close button spam) don't
|
// Serialise teardown so overlapping calls (e.g. close button spam) don't
|
||||||
// race each other and clobber a fresh playback setup.
|
// race each other and clobber a fresh playback setup.
|
||||||
@@ -4472,7 +4480,7 @@ class Application {
|
|||||||
|
|
||||||
const runCleanup = async () => {
|
const runCleanup = async () => {
|
||||||
this.log(
|
this.log(
|
||||||
`[cleanup] Begin (preserveSubscriptions=${preserveSubscriptions}, preserveObservers=${preserveObservers})`
|
`[cleanup] Begin (preserveSubscriptions=${preserveSubscriptions}, preserveObservers=${preserveObservers}, preserveModals=${preserveModals})`
|
||||||
);
|
);
|
||||||
try {
|
try {
|
||||||
this.cancelPendingViewLogging();
|
this.cancelPendingViewLogging();
|
||||||
@@ -4547,20 +4555,22 @@ class Application {
|
|||||||
|
|
||||||
this.teardownModalCommentSubscription({ resetUi: false });
|
this.teardownModalCommentSubscription({ resetUi: false });
|
||||||
|
|
||||||
if (this.modalManager) {
|
if (!preserveModals) {
|
||||||
try {
|
if (this.modalManager) {
|
||||||
this.modalManager.teardown();
|
try {
|
||||||
} catch (error) {
|
this.modalManager.teardown();
|
||||||
devLogger.warn("[cleanup] Modal teardown failed:", error);
|
} catch (error) {
|
||||||
|
devLogger.warn("[cleanup] Modal teardown failed:", error);
|
||||||
|
}
|
||||||
|
this.modalManager = null;
|
||||||
}
|
}
|
||||||
this.modalManager = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (this.bootstrapper) {
|
if (this.bootstrapper) {
|
||||||
try {
|
try {
|
||||||
this.bootstrapper.teardown();
|
this.bootstrapper.teardown();
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
devLogger.warn("[cleanup] Bootstrap teardown failed:", error);
|
devLogger.warn("[cleanup] Bootstrap teardown failed:", error);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -5211,6 +5221,7 @@ class Application {
|
|||||||
await this.cleanup({
|
await this.cleanup({
|
||||||
preserveSubscriptions: true,
|
preserveSubscriptions: true,
|
||||||
preserveObservers: true,
|
preserveObservers: true,
|
||||||
|
preserveModals: true,
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user