fix(cctv): keep the camera card's bigger view refreshing

An open bigger view now counts as a viewer of the camera's still, so it
keeps refreshing after the layout turns phone and the Cameras sheet is
not the one open. The card releases it in the watcher's cleanup, which
also runs when the card unmounts in the same tick the popup closes.
This commit is contained in:
German Khokhlov committed 2026-11-20 03:35:32 +04:00
1 parent d19ae89630
commit 2c5f9f89f7
5 files changed
+142 -12

No files matched your search

+11 -7
View File
@@ -54,15 +54,19 @@ const big = ref(false);
const onKey = (e) => {
if (e.key === 'Escape') big.value = false;
};
watch(big, (open) => {
if (open) document.addEventListener('keydown', onKey);
else document.removeEventListener('keydown', onKey);
// The cleanup also runs when the card unmounts, even if `big` turned false in
// the same tick and the watcher never saw it.
watch(big, (open, _, onCleanup) => {
if (!open) return;
cctv.showPreviewPopup(true);
document.addEventListener('keydown', onKey);
onCleanup(() => {
cctv.showPreviewPopup(false);
document.removeEventListener('keydown', onKey);
});
});
onMounted(() => cctv.showPreviewCard(true));
onBeforeUnmount(() => {
cctv.showPreviewCard(false);
document.removeEventListener('keydown', onKey);
});
onBeforeUnmount(() => cctv.showPreviewCard(false));
function openPanel() {
if (panels.value['cctv-panel']?.collapsed !== false) chrome.act('toggle', 'cctv-panel');