mirror of
https://github.com/hensm/fx_cast.git
synced 2026-06-12 18:39:58 +00:00
Fix onDestroy not called for Popup component
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { afterUpdate, onMount, tick } from "svelte";
|
import { afterUpdate, onDestroy, onMount, tick } from "svelte";
|
||||||
|
|
||||||
import messaging, { Message, Port } from "../../messaging";
|
import messaging, { Message, Port } from "../../messaging";
|
||||||
import options, { Options } from "../../lib/options";
|
import options, { Options } from "../../lib/options";
|
||||||
@@ -131,15 +131,15 @@
|
|||||||
window.addEventListener("contextmenu", onContextMenu);
|
window.addEventListener("contextmenu", onContextMenu);
|
||||||
browser.menus.onClicked.addListener(onMenuClicked);
|
browser.menus.onClicked.addListener(onMenuClicked);
|
||||||
browser.menus.onShown.addListener(onMenuShown);
|
browser.menus.onShown.addListener(onMenuShown);
|
||||||
|
});
|
||||||
|
|
||||||
return () => {
|
onDestroy(() => {
|
||||||
port?.disconnect();
|
port?.disconnect();
|
||||||
resizeObserver.disconnect();
|
resizeObserver.disconnect();
|
||||||
|
|
||||||
window.addEventListener("contextmenu", onContextMenu);
|
window.removeEventListener("contextmenu", onContextMenu);
|
||||||
browser.menus.onClicked.removeListener(onMenuClicked);
|
browser.menus.onClicked.removeListener(onMenuClicked);
|
||||||
browser.menus.onShown.removeListener(onMenuShown);
|
browser.menus.onShown.removeListener(onMenuShown);
|
||||||
};
|
|
||||||
});
|
});
|
||||||
|
|
||||||
afterUpdate(async () => {
|
afterUpdate(async () => {
|
||||||
|
|||||||
@@ -12,5 +12,8 @@ browser.runtime.getPlatformInfo().then(platformInfo => {
|
|||||||
|
|
||||||
const target = document.getElementById("root");
|
const target = document.getElementById("root");
|
||||||
if (target) {
|
if (target) {
|
||||||
new Popup({ target });
|
const popup = new Popup({ target });
|
||||||
|
window.addEventListener("unload", () => {
|
||||||
|
popup.$destroy();
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user