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",
diff --git a/MyMusicClientSveltePwa/src/lib/pages/Settings.svelte b/MyMusicClientSveltePwa/src/lib/pages/Settings.svelte
index 5e899c0..e350967 100644
--- a/MyMusicClientSveltePwa/src/lib/pages/Settings.svelte
+++ b/MyMusicClientSveltePwa/src/lib/pages/Settings.svelte
@@ -1,3 +1,69 @@
-
- Configure settings here.
-
\ No newline at end of file
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
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
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() {
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 });
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);
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 {