mirror of
https://github.com/JuLi0n21/pwa-player.git
synced 2026-04-19 15:30:05 +00:00
add localstorage for last connected baseurl
This commit is contained in:
@@ -18,6 +18,17 @@ export const useUserStore = defineStore('userStore', () => {
|
||||
return user ? JSON.parse(user) : null;
|
||||
}
|
||||
|
||||
|
||||
function setBaseUrl(url: string) {
|
||||
localStorage.setItem('baseUrl', url);
|
||||
baseUrl.value = url;
|
||||
}
|
||||
|
||||
function loadBaseUrl(): string | null {
|
||||
const url = localStorage.getItem('baseUrl');
|
||||
return url;
|
||||
}
|
||||
|
||||
function setUser(user: Me | null) {
|
||||
User.value = user;
|
||||
saveUser(user)
|
||||
@@ -142,6 +153,7 @@ export const useUserStore = defineStore('userStore', () => {
|
||||
}
|
||||
|
||||
setUser(loadUser());
|
||||
baseUrl.value = loadBaseUrl();
|
||||
|
||||
return { fetchSong, fetchActiveSearch, fetchSearchArtist, fetchCollections, fetchCollection, fetchRecent, fetchFavorites, fetchMe, userId, baseUrl, proxyUrl, User, setUser }
|
||||
return { fetchSong, fetchActiveSearch, fetchSearchArtist, fetchCollections, fetchCollection, fetchRecent, fetchFavorites, fetchMe, userId, baseUrl, proxyUrl, User, setUser, setBaseUrl }
|
||||
})
|
||||
|
||||
@@ -50,7 +50,7 @@ async function getMe() {
|
||||
|
||||
console.log("active user: ", data.name)
|
||||
userStore.setUser(data);
|
||||
userStore.baseUrl = data.endpoint;
|
||||
userStore.setBaseUrl(data.endpoint);
|
||||
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user