Compare commits
1 Commits
main
...
offline-mo
| Author | SHA1 | Date | |
|---|---|---|---|
| 347438928a |
@@ -1,18 +1,18 @@
|
|||||||
import { writable, get } from 'svelte/store';
|
import { writable } from 'svelte/store';
|
||||||
import { browser } from '$app/environment';
|
import { browser } from '$app/environment';
|
||||||
|
import { SvelteSet } from 'svelte/reactivity';
|
||||||
|
|
||||||
export const currentStream = writable({});
|
export const currentStream = writable({});
|
||||||
export const currentSongIndex = writable(null);
|
export const currentSongIndex = writable(null);
|
||||||
|
|
||||||
export const favoritedStreams = writable(
|
export const favoritedStreams = new SvelteSet(
|
||||||
new Set(JSON.parse((browser && localStorage.getItem('favoritedStreams')) || '[]'))
|
JSON.parse((browser && localStorage.getItem('favoritedStreams')) || '[]')
|
||||||
);
|
);
|
||||||
|
$effect.root(() => {
|
||||||
if (browser) {
|
$effect(() => {
|
||||||
favoritedStreams.subscribe((val) => {
|
localStorage.setItem('favoritedStreams', JSON.stringify(Array.from(favoritedStreams)));
|
||||||
localStorage.setItem('favoritedStreams', JSON.stringify(Array.from(val)));
|
});
|
||||||
});
|
});
|
||||||
}
|
|
||||||
|
|
||||||
export const tagList = [
|
export const tagList = [
|
||||||
'acoustic',
|
'acoustic',
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { untrack } from 'svelte';
|
import { untrack } from 'svelte';
|
||||||
import { goto } from '$app/navigation';
|
import { goto } from '$app/navigation';
|
||||||
import { currentStream, favoritedStreams } from '$lib/stores.js';
|
import { currentStream, favoritedStreams } from '$lib/stores.svelte.js';
|
||||||
import { hashColor, shorthandCode, formatSecondsToHms, formatDate } from '$lib/utils.js';
|
import { hashColor, shorthandCode, formatSecondsToHms, formatDate } from '$lib/utils.js';
|
||||||
import TagSelect from './TagSelect.svelte';
|
import TagSelect from './TagSelect.svelte';
|
||||||
|
|
||||||
@@ -40,10 +40,9 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
function updateFavorites(stream) {
|
function updateFavorites(stream) {
|
||||||
$favoritedStreams.has(stream['id'])
|
favoritedStreams.has(stream['id'])
|
||||||
? $favoritedStreams.delete(stream['id'])
|
? favoritedStreams.delete(stream['id'])
|
||||||
: $favoritedStreams.add(stream['id']);
|
: favoritedStreams.add(stream['id']);
|
||||||
$favoritedStreams = $favoritedStreams; // for reactivity
|
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
@@ -57,7 +56,7 @@
|
|||||||
|
|
||||||
<ul class="stream-list">
|
<ul class="stream-list">
|
||||||
{#each streams as stream}
|
{#each streams as stream}
|
||||||
{@const favorited = $favoritedStreams.has(stream['id'])}
|
{@const favorited = favoritedStreams.has(stream['id'])}
|
||||||
{@const current = $currentStream['id'] === stream['id']}
|
{@const current = $currentStream['id'] === stream['id']}
|
||||||
<li
|
<li
|
||||||
hidden={!displayedStreams.includes(stream) || (favoritesOnly && !favorited)}
|
hidden={!displayedStreams.includes(stream) || (favoritesOnly && !favorited)}
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import Select from 'svelte-select';
|
import Select from 'svelte-select';
|
||||||
import { tagList } from '$lib/stores.js';
|
import { tagList } from '$lib/stores.svelte.js';
|
||||||
|
|
||||||
let { checked = $bindable([]), remainingTags = [], listOpen = $bindable() } = $props();
|
let { checked = $bindable([]), remainingTags = [], listOpen = $bindable() } = $props();
|
||||||
let items = $state(tagList.map((x) => ({ value: x, label: x })));
|
let items = $state(tagList.map((x) => ({ value: x, label: x })));
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
<script>
|
<script>
|
||||||
import { currentStream } from '$lib/stores.js';
|
import { currentStream } from '$lib/stores.svelte.js';
|
||||||
|
|
||||||
currentStream.set({});
|
currentStream.set({});
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
@@ -5,7 +5,7 @@
|
|||||||
import MetadataEditor from './MetadataEditor.svelte';
|
import MetadataEditor from './MetadataEditor.svelte';
|
||||||
import Player from './Player.svelte';
|
import Player from './Player.svelte';
|
||||||
import { dev } from '$app/environment';
|
import { dev } from '$app/environment';
|
||||||
import { currentStream, updateCurrentStream } from '$lib/stores.js';
|
import { currentStream, updateCurrentStream } from '$lib/stores.svelte.js';
|
||||||
|
|
||||||
let { data } = $props();
|
let { data } = $props();
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { page } from '$app/stores';
|
import { page } from '$app/stores';
|
||||||
import { tagList } from '$lib/stores.js';
|
import { tagList } from '$lib/stores.svelte.js';
|
||||||
|
|
||||||
let { original = $bindable() } = $props();
|
let { original = $bindable() } = $props();
|
||||||
|
|
||||||
|
|||||||
@@ -24,7 +24,7 @@
|
|||||||
currentStream,
|
currentStream,
|
||||||
getSongAtTime,
|
getSongAtTime,
|
||||||
updateCurrentSong
|
updateCurrentSong
|
||||||
} from '$lib/stores.js';
|
} from '$lib/stores.svelte.js';
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
src: any;
|
src: any;
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
<script>
|
<script>
|
||||||
import { currentStream, currentSongIndex } from '$lib/stores.js';
|
import { currentStream, currentSongIndex } from '$lib/stores.svelte.js';
|
||||||
import { shorthandCode, formatTrackTime, formatDate } from '$lib/utils.js';
|
import { shorthandCode, formatTrackTime, formatDate } from '$lib/utils.js';
|
||||||
import { jumpToTrack } from './Player.svelte';
|
import { jumpToTrack } from './Player.svelte';
|
||||||
import { Carta } from 'carta-md';
|
import { Carta } from 'carta-md';
|
||||||
|
|||||||
Reference in New Issue
Block a user