Fix Notification components possible memory leaks (#650)

Dispose subscriptions and timeouts when
the components are removed from the DOM
This commit is contained in:
Jaime Baez 2022-09-09 14:40:35 +02:00 committed by GitHub
parent cc79ff1ca3
commit b6d025da09
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 96 additions and 11 deletions

View file

@ -1,25 +1,21 @@
<script lang="ts">
import { ImmichNotification, notificationController } from './notification';
import { notificationController } from './notification';
import { fade } from 'svelte/transition';
import NotificationCard from './notification-card.svelte';
import { flip } from 'svelte/animate';
import { quintOut } from 'svelte/easing';
let notificationList: ImmichNotification[] = [];
notificationController.notificationList.subscribe((list) => {
notificationList = list;
});
const { notificationList } = notificationController;
</script>
{#if notificationList.length > 0}
{#if $notificationList.length > 0}
<section
transition:fade={{ duration: 250 }}
id="notification-list"
class="absolute right-5 top-[80px] z-[99999999]"
>
{#each notificationList as notificationInfo (notificationInfo.id)}
{#each $notificationList as notificationInfo (notificationInfo.id)}
<div animate:flip={{ duration: 250, easing: quintOut }}>
<NotificationCard {notificationInfo} />
</div>