From c51deecd2b6816c2b2e4c7d73117bc9e5edfbb67 Mon Sep 17 00:00:00 2001 From: DutchJavaDev Date: Sun, 21 Sep 2025 14:07:25 +0200 Subject: [PATCH 1/8] did not know this was a bug... --- .../src/lib/scripts/routeService.js | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/MyMusicClientSveltePwa/src/lib/scripts/routeService.js b/MyMusicClientSveltePwa/src/lib/scripts/routeService.js index d591a9f..d93ed07 100644 --- a/MyMusicClientSveltePwa/src/lib/scripts/routeService.js +++ b/MyMusicClientSveltePwa/src/lib/scripts/routeService.js @@ -8,10 +8,10 @@ import { getSearchParameters, createSearchParameters, searchQuery } from "../scr const componentsPathMap = new Map([ ["/404", NotFound], - ["/Home", Home], + ["/home", Home], ["/", Home], - ["/Playlists", Playlists], - ["/Settings", Settings], + ["/playlists", Playlists], + ["/settings", Settings], ]); const NotFoundRoutePath = "/404"; @@ -47,7 +47,10 @@ export function initializeRouteService() { // Sets the current route and updates the component and parameters accordingly // If the route does not exist, it sets the NotFound component and parameters -export function navigateTo(newRoute, parameters = null) { +export function navigateTo(_newRoute, parameters = null) { + + let newRoute = _newRoute.toLowerCase(); + if (!componentsPathMap.has(newRoute)) { component.set(componentsPathMap.get(NotFoundRoutePath)); componentParams.set({ page: newRoute }); From 30fdcf32b2d26b8a0fa0522ba5f2b2dec6346361 Mon Sep 17 00:00:00 2001 From: DutchJavaDev Date: Sun, 21 Sep 2025 14:57:50 +0200 Subject: [PATCH 2/8] base settings --- .../src/lib/pages/Settings.svelte | 71 ++++++++++++++++++- 1 file changed, 68 insertions(+), 3 deletions(-) diff --git a/MyMusicClientSveltePwa/src/lib/pages/Settings.svelte b/MyMusicClientSveltePwa/src/lib/pages/Settings.svelte index 5e899c0..4b1109d 100644 --- a/MyMusicClientSveltePwa/src/lib/pages/Settings.svelte +++ b/MyMusicClientSveltePwa/src/lib/pages/Settings.svelte @@ -1,3 +1,68 @@ -
- Configure settings here. -
\ No newline at end of file + + + +
+
+ + +
+
+ + +
+
+ + +
+ +
+ +
+ + + +
+ +
+ +
+ + From de9d681229333f69c17cabb4c466d10609ccf396 Mon Sep 17 00:00:00 2001 From: DutchJavaDev Date: Sun, 21 Sep 2025 14:58:00 +0200 Subject: [PATCH 3/8] bypasscache --- MyMusicClientSveltePwa/src/lib/scripts/api.js | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/MyMusicClientSveltePwa/src/lib/scripts/api.js b/MyMusicClientSveltePwa/src/lib/scripts/api.js index b013249..2287737 100644 --- a/MyMusicClientSveltePwa/src/lib/scripts/api.js +++ b/MyMusicClientSveltePwa/src/lib/scripts/api.js @@ -2,6 +2,8 @@ const baseApiUrl = import.meta.env.VITE_BASE_API_URL; const staticImageUrl = import.meta.env.VITE_STATIC_IMAGE_URL; const staticAudioUrl = import.meta.env.VITE_STATIC_AUDIO_URL; +import { getConfiguration } from "./storageService"; + export async function fetchPlaylists() { try { const response = await fetch(`${baseApiUrl}/playlist`); @@ -59,9 +61,23 @@ export async function fetchPlaylistSongs(playlistId) { } export function getImageUrl(path) { + + var config = getConfiguration(); + + if(config.byPassCache){ + return `${staticImageUrl}/${path}?cb=${new Date().getMilliseconds()}`; + } + return `${staticImageUrl}/${path}`; } export function getPlaybackUrl(source_id) { + + var config = getConfiguration(); + + if(config.byPassCache){ + return `${staticAudioUrl}/${source_id}.opus?cb=${new Date().getMilliseconds()}`; + } + return `${staticAudioUrl}/${source_id}.opus`; // Assuming all audio files are in .opus format } \ No newline at end of file From 67c2311f521c2390a9f958a20f613190b3af0eff Mon Sep 17 00:00:00 2001 From: DutchJavaDev Date: Sun, 21 Sep 2025 14:59:55 +0200 Subject: [PATCH 4/8] update interval time --- .../src/lib/scripts/playlistService.js | 25 ++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) diff --git a/MyMusicClientSveltePwa/src/lib/scripts/playlistService.js b/MyMusicClientSveltePwa/src/lib/scripts/playlistService.js index 7d4f2f7..e36a801 100644 --- a/MyMusicClientSveltePwa/src/lib/scripts/playlistService.js +++ b/MyMusicClientSveltePwa/src/lib/scripts/playlistService.js @@ -1,11 +1,12 @@ import { writable } from "svelte/store"; -import { getCachedPlaylists, setPlaylists, setPlaylistSongs, getCachedPlaylistSongs } from "./storageService"; +import { getCachedPlaylists, setPlaylists, setPlaylistSongs, getCachedPlaylistSongs, appConfiguration, getConfiguration } from "./storageService"; import { fetchPlaylists, fetchPlaylistSongs, fetchNewPlaylist, fetchNewPlaylistSongs } from "./api"; export const playlistsStore = writable([]); -const updateInterval = 1000 * 3; // 3 seconds +let updateInterval; let isUpdating = false; +let intervalId; // Check storage for stored playlists, if empty fetch from API export async function initializePlaylistService() { @@ -22,12 +23,30 @@ export async function initializePlaylistService() { } } - setInterval(() => { + updateInterval = getConfiguration().fetchTimer * 1000; // Need to multiply by 1000 to get milliseconds + // Subscribe to configuration changes + // If fetchTimer is updated, clear the old interval and set a new one + + appConfiguration.subscribe(config => { + if (intervalId) { + clearInterval(intervalId); + } + updateInterval = config.fetchTimer * 1000; // Need to multiply by 1000 to get milliseconds + + console.log("Update interval set to:", updateInterval, "ms"); + + intervalId = setInterval(() => { + if (isUpdating) return; // Prevent multiple updates at the same time + isUpdating = true; + backgroundUpdate(); + isUpdating = false; + }, updateInterval); + }); } async function backgroundUpdate() { From 05ed53d787f7c07697050901ae056a35851047f8 Mon Sep 17 00:00:00 2001 From: DutchJavaDev Date: Sun, 21 Sep 2025 15:00:08 +0200 Subject: [PATCH 5/8] update sleeptimer --- MyMusicClientSveltePwa/src/lib/scripts/sleeptimerService.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/MyMusicClientSveltePwa/src/lib/scripts/sleeptimerService.js b/MyMusicClientSveltePwa/src/lib/scripts/sleeptimerService.js index c34527a..3143e9d 100644 --- a/MyMusicClientSveltePwa/src/lib/scripts/sleeptimerService.js +++ b/MyMusicClientSveltePwa/src/lib/scripts/sleeptimerService.js @@ -1,5 +1,6 @@ // @ts-nocheck import { writable, get } from "svelte/store"; +import { getConfiguration } from "./storageService"; export let timeLeft = writable(0); export let isTimerEnabled = writable(false); @@ -21,7 +22,9 @@ if (get(isTimerEnabled)) { return; } -const totalMinutes = 30; // Default to 30 minutes if no time is provided +const config = getConfiguration(); + +const totalMinutes = config.sleepTimer; // Default to 30 minutes if no time is provided let remainingMinutes = totalMinutes; timeLeft.set(remainingMinutes); From 5df4043333227c3e93d6274ac8ff860c9bbc4c3b Mon Sep 17 00:00:00 2001 From: DutchJavaDev Date: Sun, 21 Sep 2025 15:00:16 +0200 Subject: [PATCH 6/8] store default config --- .../src/lib/scripts/storageService.js | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/MyMusicClientSveltePwa/src/lib/scripts/storageService.js b/MyMusicClientSveltePwa/src/lib/scripts/storageService.js index a16c539..53941b7 100644 --- a/MyMusicClientSveltePwa/src/lib/scripts/storageService.js +++ b/MyMusicClientSveltePwa/src/lib/scripts/storageService.js @@ -1,3 +1,5 @@ +import { get, writable } from "svelte/store"; + // @ts-ignore const storageType = "localStorage"; const PlaylistsKey = "cachedPlaylists"; @@ -7,6 +9,14 @@ const CurrentPlaylistIdKey = "currentPlaylistId"; const CurrentSongIndexKey = "currentSongIndex"; const CurrentShuffeldPlaylistKey = "currentShuffledPlaylist"; const CurrentSongTimeKey = "currentSongTime"; +const ConfigKey = "appConfig"; + +export let appConfiguration = writable(getConfiguration()); + +export function setConfiguration(config) { + appConfiguration.set(config); + setItem(ConfigKey, config); +} export function setPlaylists(playlists) { setItem(PlaylistsKey, playlists); @@ -73,6 +83,13 @@ export function getCurrentSongTime() { return getItem(CurrentSongTimeKey) || 0; } +export function getConfiguration() { + return getItem(ConfigKey) || { sleepTimer: 15, // minutes + fetchTimer: 3, // seconds + byPassCache: false + }; +} + export function clearStorage() { if (storageAvailable(storageType)) { try { From 571e6e18dc89a12497eee84607220e9993af7bd1 Mon Sep 17 00:00:00 2001 From: DutchJavaDev Date: Sun, 21 Sep 2025 15:22:15 +0200 Subject: [PATCH 7/8] future me --- MyMusicClientSveltePwa/src/lib/pages/Settings.svelte | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/MyMusicClientSveltePwa/src/lib/pages/Settings.svelte b/MyMusicClientSveltePwa/src/lib/pages/Settings.svelte index 4b1109d..e350967 100644 --- a/MyMusicClientSveltePwa/src/lib/pages/Settings.svelte +++ b/MyMusicClientSveltePwa/src/lib/pages/Settings.svelte @@ -47,7 +47,8 @@
- + +
From 1a2c57986f9b9197a631697d47fe2af1a4981fdd Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Sun, 21 Sep 2025 13:22:47 +0000 Subject: [PATCH 8/8] chore: bump version --- MyMusicClientSveltePwa/package-lock.json | 4 ++-- MyMusicClientSveltePwa/package.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/MyMusicClientSveltePwa/package-lock.json b/MyMusicClientSveltePwa/package-lock.json index 46ffc3d..3d2dd6a 100644 --- a/MyMusicClientSveltePwa/package-lock.json +++ b/MyMusicClientSveltePwa/package-lock.json @@ -1,12 +1,12 @@ { "name": "mymusicclientsveltepwa", - "version": "0.1.9", + "version": "0.1.10", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "mymusicclientsveltepwa", - "version": "0.1.9", + "version": "0.1.10", "dependencies": { "@sveltestrap/sveltestrap": "^7.1.0" }, diff --git a/MyMusicClientSveltePwa/package.json b/MyMusicClientSveltePwa/package.json index c048954..7024519 100644 --- a/MyMusicClientSveltePwa/package.json +++ b/MyMusicClientSveltePwa/package.json @@ -1,7 +1,7 @@ { "name": "mymusicclientsveltepwa", "private": true, - "version": "0.1.9", + "version": "0.1.10", "type": "module", "scripts": { "dev": "vite --host",