Add desktop links wooo!!! (beta smh)
This commit is contained in:
parent
b1d94a29ca
commit
6bd12624b8
4 changed files with 165 additions and 44 deletions
100
index.html
100
index.html
File diff suppressed because one or more lines are too long
|
|
@ -393,29 +393,85 @@ const syncManager = {
|
|||
this._isSyncing = true;
|
||||
|
||||
try {
|
||||
const data = await this.getUserData();
|
||||
const cloudData = await this.getUserData();
|
||||
|
||||
if (cloudData) {
|
||||
const localData = {
|
||||
tracks: (await db.getAll('favorites_tracks')) || [],
|
||||
albums: (await db.getAll('favorites_albums')) || [],
|
||||
artists: (await db.getAll('favorites_artists')) || [],
|
||||
playlists: (await db.getAll('favorites_playlists')) || [],
|
||||
mixes: (await db.getAll('favorites_mixes')) || [],
|
||||
history: (await db.getAll('history_tracks')) || [],
|
||||
userPlaylists: (await db.getAll('user_playlists')) || [],
|
||||
};
|
||||
|
||||
let { library, history, userPlaylists } = cloudData;
|
||||
let needsUpdate = false;
|
||||
|
||||
if (!library) library = {};
|
||||
if (!library.tracks) library.tracks = {};
|
||||
if (!library.albums) library.albums = {};
|
||||
if (!library.artists) library.artists = {};
|
||||
if (!library.playlists) library.playlists = {};
|
||||
if (!library.mixes) library.mixes = {};
|
||||
if (!userPlaylists) userPlaylists = {};
|
||||
if (!history) history = [];
|
||||
|
||||
const mergeItem = (collection, item, type) => {
|
||||
const id = type === 'playlist' ? item.uuid || item.id : item.id;
|
||||
if (!collection[id]) {
|
||||
collection[id] = this._minifyItem(type, item);
|
||||
needsUpdate = true;
|
||||
}
|
||||
};
|
||||
|
||||
localData.tracks.forEach((item) => mergeItem(library.tracks, item, 'track'));
|
||||
localData.albums.forEach((item) => mergeItem(library.albums, item, 'album'));
|
||||
localData.artists.forEach((item) => mergeItem(library.artists, item, 'artist'));
|
||||
localData.playlists.forEach((item) => mergeItem(library.playlists, item, 'playlist'));
|
||||
localData.mixes.forEach((item) => mergeItem(library.mixes, item, 'mix'));
|
||||
|
||||
localData.userPlaylists.forEach((playlist) => {
|
||||
if (!userPlaylists[playlist.id]) {
|
||||
userPlaylists[playlist.id] = {
|
||||
id: playlist.id,
|
||||
name: playlist.name,
|
||||
cover: playlist.cover || null,
|
||||
tracks: playlist.tracks
|
||||
? playlist.tracks.map((t) => this._minifyItem('track', t))
|
||||
: [],
|
||||
createdAt: playlist.createdAt || Date.now(),
|
||||
updatedAt: playlist.updatedAt || Date.now(),
|
||||
numberOfTracks: playlist.tracks ? playlist.tracks.length : 0,
|
||||
images: playlist.images || [],
|
||||
isPublic: playlist.isPublic || false,
|
||||
};
|
||||
needsUpdate = true;
|
||||
}
|
||||
});
|
||||
|
||||
if (history.length === 0 && localData.history.length > 0) {
|
||||
history = localData.history;
|
||||
needsUpdate = true;
|
||||
}
|
||||
|
||||
if (needsUpdate) {
|
||||
await this._updateUserJSON(user.uid, 'library', library);
|
||||
await this._updateUserJSON(user.uid, 'user_playlists', userPlaylists);
|
||||
await this._updateUserJSON(user.uid, 'history', history);
|
||||
}
|
||||
|
||||
if (data) {
|
||||
const convertedData = {
|
||||
favorites_tracks: data.library.tracks
|
||||
? Object.values(data.library.tracks).filter((t) => t && typeof t === 'object')
|
||||
: [],
|
||||
favorites_albums: data.library.albums
|
||||
? Object.values(data.library.albums).filter((a) => a && typeof a === 'object')
|
||||
: [],
|
||||
favorites_artists: data.library.artists
|
||||
? Object.values(data.library.artists).filter((a) => a && typeof a === 'object')
|
||||
: [],
|
||||
favorites_playlists: data.library.playlists
|
||||
? Object.values(data.library.playlists).filter((p) => p && typeof p === 'object')
|
||||
: [],
|
||||
favorites_mixes: data.library.mixes
|
||||
? Object.values(data.library.mixes).filter((m) => m && typeof m === 'object')
|
||||
: [],
|
||||
history_tracks: data.history || [],
|
||||
user_playlists: data.userPlaylists
|
||||
? Object.values(data.userPlaylists).filter((p) => p && typeof p === 'object')
|
||||
: [],
|
||||
favorites_tracks: Object.values(library.tracks).filter((t) => t && typeof t === 'object'),
|
||||
favorites_albums: Object.values(library.albums).filter((a) => a && typeof a === 'object'),
|
||||
favorites_artists: Object.values(library.artists).filter((a) => a && typeof a === 'object'),
|
||||
favorites_playlists: Object.values(library.playlists).filter(
|
||||
(p) => p && typeof p === 'object'
|
||||
),
|
||||
favorites_mixes: Object.values(library.mixes).filter((m) => m && typeof m === 'object'),
|
||||
history_tracks: history,
|
||||
user_playlists: Object.values(userPlaylists).filter((p) => p && typeof p === 'object'),
|
||||
};
|
||||
|
||||
await db.importData(convertedData);
|
||||
|
|
|
|||
1
public/assets/installdesk.svg
Normal file
1
public/assets/installdesk.svg
Normal file
|
|
@ -0,0 +1 @@
|
|||
<svg xmlns="http://www.w3.org/2000/svg" height="24px" viewBox="0 -960 960 960" width="24px" fill="#8E8E96"><path d="M320-120v-80H160q-33 0-56.5-23.5T80-280v-480q0-33 23.5-56.5T160-840h320v80H160v480h640v-120h80v120q0 33-23.5 56.5T800-200H640v80H320Zm360-280L480-600l56-56 104 103v-287h80v287l104-103 56 56-200 200Z"/></svg>
|
||||
|
After Width: | Height: | Size: 323 B |
10
styles.css
10
styles.css
|
|
@ -321,6 +321,16 @@ kbd {
|
|||
transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
|
||||
}
|
||||
|
||||
.sidebar-content {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
height: 100%;
|
||||
}
|
||||
|
||||
.sidebar-nav.main {
|
||||
flex: 1;
|
||||
}
|
||||
|
||||
.main-content {
|
||||
grid-area: main;
|
||||
overflow-y: auto;
|
||||
|
|
|
|||
Loading…
Reference in a new issue