fix(ui): improve StackIcon reactivity and add debugging
- Replace onMount/onDestroy with $effect rune for better reactivity - Add console logging to trace context changes - Log when setPlaybackContext/clearPlaybackContext are called - Log when StackIcon receives context updates This will help debug why stack icon might not appear immediately. To test: 1. Open browser console 2. Click a track in an album 3. Check logs for '[PlaybackContext]' and '[StackIcon]' 4. Verify context is being set and icon is receiving updates cp
This commit is contained in:
1 parent
b6001b0203
commit
3851fecd92
2 files changed
+19
-10
No files matched your search
@@ -1,7 +1,6 @@
|
||||
<script lang="ts">
|
||||
import { Layers } from 'lucide-svelte';
|
||||
import { subscribe, getCurrentContext, getContextDisplayInfo } from '$lib/stores/playbackContextStore';
|
||||
import { onMount, onDestroy } from 'svelte';
|
||||
|
||||
interface Props {
|
||||
size?: number;
|
||||
@@ -13,17 +12,19 @@
|
||||
let context = $state(getCurrentContext());
|
||||
let displayInfo = $state(context ? getContextDisplayInfo() : null);
|
||||
|
||||
let unsubscribe: (() => void) | null = null;
|
||||
|
||||
onMount(() => {
|
||||
unsubscribe = subscribe(() => {
|
||||
context = getCurrentContext();
|
||||
displayInfo = context ? getContextDisplayInfo() : null;
|
||||
// Subscribe to context changes with $effect
|
||||
$effect(() => {
|
||||
const unsubscribe = subscribe(() => {
|
||||
const newContext = getCurrentContext();
|
||||
const newDisplayInfo = newContext ? getContextDisplayInfo() : null;
|
||||
console.log('[StackIcon] Context changed:', { newContext, newDisplayInfo });
|
||||
context = newContext;
|
||||
displayInfo = newDisplayInfo;
|
||||
});
|
||||
});
|
||||
|
||||
onDestroy(() => {
|
||||
unsubscribe?.();
|
||||
return () => {
|
||||
unsubscribe();
|
||||
};
|
||||
});
|
||||
</script>
|
||||
|
||||
@@ -31,6 +32,9 @@
|
||||
<div class="stack-icon-wrapper {className}" title="Playing from: {displayInfo}">
|
||||
<Layers size={size} strokeWidth={2} />
|
||||
</div>
|
||||
{:else}
|
||||
<!-- Debug: Icon should be hidden -->
|
||||
<!-- <span style="font-size: 10px; color: red;">No context</span> -->
|
||||
{/if}
|
||||
|
||||
<style>
|
||||
|
||||
Reference in new issue
Block a user