Skip to content

Commit

Permalink
Remove unnecessary MutationObserver when creating BlockingWaitDialog
Browse files Browse the repository at this point in the history
  • Loading branch information
tfedor committed Nov 19, 2024
1 parent 03e1e85 commit ffb4755
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 20 deletions.
29 changes: 10 additions & 19 deletions src/js/Core/Modals/BlockingWaitDialog.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,30 +17,21 @@ export default class BlockingWaitDialog {
}

async update(): Promise<void> {
if (this.modalComponent) {
this.modalComponent.status = this.statusFn();
} else {
const observer = new MutationObserver(() => {
const target = document.querySelector<HTMLDivElement>("#" + this.modalId);
if (target) {
this.modalComponent = new BlockingWaitModal({
target,
props: {
status: this.statusFn()
}
});
observer.disconnect();
}
});
observer.observe(document.body, {
childList: true
});

if (!this.modalComponent) {
await SteamFacade.showBlockingWaitDialog(
this.title,
`<div id="${this.modalId}"></div>`
);

const target = document.querySelector<HTMLDivElement>("#" + this.modalId);
if (target) {
this.modalComponent = new BlockingWaitModal({target});
} else {
throw new Error("Failed to create blocking wait dialog");
}
}

this.modalComponent.status = this.statusFn();
}

dismiss(): void {
Expand Down
5 changes: 4 additions & 1 deletion src/js/Core/Modals/BlockingWaitModal.svelte
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
<svelte:options accessors />

<script lang="ts">
export let status: string|string[];
import {__wait} from "@Strings/_strings";
import {L} from "@Core/Localization/Localization";
export let status: string|string[] = L(__wait);
</script>


Expand Down

0 comments on commit ffb4755

Please sign in to comment.