A music player that connects to your cloud/distributed storage.
5
fork

Configure Feed

Select the types of activity you want to include in your feed.

Improve forwardCompatibility

+27 -10
+27 -10
src/Javascript/Brain/index.js
··· 71 71 72 72 73 73 async function forwardCompatibility() { 74 - const secretKey = await fromCache("AUTH_SECRET_KEY") 75 - if (secretKey) { 76 - await toCache("SECRET_KEY", secretKey) 77 - await removeCache("AUTH_SECRET_KEY") 78 - } 74 + // TODO: Future, check version to migrate 75 + if (await fromCache("MIGRATED")) return 76 + 77 + await moveOldDbValue({ oldName: "AUTH_SECRET_KEY", newName: "SECRET_KEY" }) 78 + await moveOldDbValue({ oldName: "AUTH_ENCLOSED_DATA", newName: "ENCLOSED_DATA" }) 79 79 80 80 const method = await fromCache("AUTH_METHOD") 81 - if (method) { 81 + 82 + if (method === "LOCAL") { 83 + await moveOldDbValue({ oldName: "AUTH_ANONYMOUS_favourites.json", newName: "SYNC_LOCAL_favourites.json", parseJSON: true }) 84 + await moveOldDbValue({ oldName: "AUTH_ANONYMOUS_playlists.json", newName: "SYNC_LOCAL_playlists.json", parseJSON: true }) 85 + await moveOldDbValue({ oldName: "AUTH_ANONYMOUS_progress.json", newName: "SYNC_LOCAL_progress.json", parseJSON: true }) 86 + await moveOldDbValue({ oldName: "AUTH_ANONYMOUS_settings.json", newName: "SYNC_LOCAL_settings.json", parseJSON: true }) 87 + await moveOldDbValue({ oldName: "AUTH_ANONYMOUS_sources.json", newName: "SYNC_LOCAL_sources.json", parseJSON: true }) 88 + await moveOldDbValue({ oldName: "AUTH_ANONYMOUS_tracks.json", newName: "SYNC_LOCAL_tracks.json", parseJSON: true }) 89 + 90 + await removeCache("AUTH_METHOD") 91 + 92 + } else if (method) { 82 93 await toCache("SYNC_METHOD", method) 83 94 await removeCache("AUTH_METHOD") 95 + 84 96 } 85 97 86 - const enclosedData = await fromCache("AUTH_ENCLOSED_DATA") 87 - if (enclosedData) { 88 - await toCache("ENCLOSED_DATA", enclosedData) 89 - await removeCache("AUTH_ENCLOSED_DATA") 98 + await toCache("MIGRATED", "3.3.0") 99 + } 100 + 101 + 102 + async function moveOldDbValue({ oldName, newName, parseJSON }) { 103 + const value = await fromCache(oldName) 104 + if (value) { 105 + await toCache(newName, parseJSON ? JSON.parse(value) : value) 106 + await removeCache(oldName) 90 107 } 91 108 } 92 109