adds “save all state” utility
This commit is contained in:
@@ -13,6 +13,7 @@
|
||||
} from '$lib/context/audio-internals';
|
||||
import { user_preferences } from '$lib/context/user-preferences';
|
||||
import type { PlayerElement } from '$lib/types/types';
|
||||
import { load_podcast_state } from '$lib/utility/use-state';
|
||||
import { onMount } from 'svelte';
|
||||
|
||||
// readonly values
|
||||
@@ -40,10 +41,7 @@
|
||||
$: muted = $audio_muted;
|
||||
$: current_time = $audio_start_at;
|
||||
|
||||
onMount(() => {
|
||||
episode_progress.load_all();
|
||||
user_preferences.load();
|
||||
});
|
||||
onMount(load_podcast_state);
|
||||
</script>
|
||||
|
||||
<audio
|
||||
|
||||
@@ -2,3 +2,4 @@ export { default as AudioLoader } from '$lib/components/audio-loader.svelte';
|
||||
export * from '$lib/context/audio';
|
||||
export * from '$lib/context/episode-progress';
|
||||
export * from '$lib/context/user-preferences';
|
||||
export * from '$lib/utility';
|
||||
|
||||
@@ -0,0 +1,2 @@
|
||||
export * from './seconds-to-timestamp';
|
||||
export * from './use-state';
|
||||
@@ -0,0 +1,12 @@
|
||||
import { episode_progress } from '$lib/context/episode-progress';
|
||||
import { user_preferences } from '$lib/context/user-preferences';
|
||||
|
||||
export function save_podcast_state() {
|
||||
episode_progress.save_all();
|
||||
user_preferences.save();
|
||||
}
|
||||
|
||||
export function load_podcast_state() {
|
||||
episode_progress.load_all();
|
||||
user_preferences.load();
|
||||
}
|
||||
@@ -1,5 +1,11 @@
|
||||
<script lang="ts">
|
||||
import { audio, episode_progress, user_preferences, type AudioLoadData } from '$lib';
|
||||
import {
|
||||
audio,
|
||||
episode_progress,
|
||||
save_podcast_state,
|
||||
user_preferences,
|
||||
type AudioLoadData,
|
||||
} from '$lib';
|
||||
|
||||
const sources = {
|
||||
syntax: {
|
||||
@@ -24,6 +30,7 @@
|
||||
<a href="/another-page">Another Page</a>
|
||||
<button type="button" on:click={episode_progress.save_all}>Save progress</button>
|
||||
<button type="button" on:click={user_preferences.save}>Save preferences</button>
|
||||
<button type="button" on:click={save_podcast_state}>Save state (all)</button>
|
||||
|
||||
<h5>Load Audio</h5>
|
||||
<button
|
||||
|
||||
Reference in New Issue
Block a user