fix: resolve infinite loop in home settings subscription
- Remove immediate listener call in subscribe() to prevent effect loop - Use onMount instead of $effect for subscriptions to avoid reactive tracking - Combine onMount callbacks in HomeView
This commit is contained in:
1 parent
3f863b5b40
commit
99c157d100
3 files changed
+12
-10
No files matched your search
@@ -1,4 +1,5 @@
|
||||
<script lang="ts">
|
||||
import { onMount } from 'svelte';
|
||||
import { ChevronUp, ChevronDown, RotateCcw } from 'lucide-svelte';
|
||||
import Modal from './Modal.svelte';
|
||||
import {
|
||||
@@ -23,8 +24,8 @@
|
||||
let settings = $state<HomeSettings>(getSettings());
|
||||
let customGreetingInput = $state(settings.greeting.customText || '');
|
||||
|
||||
// Subscribe to settings changes
|
||||
$effect(() => {
|
||||
// Subscribe to settings changes (use onMount to avoid reactive tracking)
|
||||
onMount(() => {
|
||||
const unsubscribe = subscribe(() => {
|
||||
settings = getSettings();
|
||||
customGreetingInput = settings.greeting.customText || '';
|
||||
|
||||
@@ -60,13 +60,6 @@
|
||||
// Computed greeting
|
||||
const greetingText = $derived(getGreetingText(userName));
|
||||
|
||||
// Subscribe to home settings changes
|
||||
$effect(() => {
|
||||
const unsubscribe = subscribeHomeSettings(() => {
|
||||
homeSettings = getSettings();
|
||||
});
|
||||
return unsubscribe;
|
||||
});
|
||||
|
||||
// Check if a section is visible
|
||||
function isSectionVisible(sectionId: HomeSectionId): boolean {
|
||||
@@ -120,7 +113,15 @@
|
||||
);
|
||||
|
||||
onMount(() => {
|
||||
// Subscribe to home settings changes
|
||||
const unsubscribe = subscribeHomeSettings(() => {
|
||||
homeSettings = getSettings();
|
||||
});
|
||||
|
||||
// Load home data
|
||||
loadHome();
|
||||
|
||||
return unsubscribe;
|
||||
});
|
||||
|
||||
function handleArtistImageError(artistId: number) {
|
||||
|
||||
Reference in new issue
Block a user