clear the ServiceWorker cache on logout (#854)

* Update authProvider.js

This fixes https://github.com/navidrome/navidrome/issues/613 : clears the ServiceWorker cache on logout. Based on this code: https://developer.mozilla.org/en-US/docs/Web/API/CacheStorage/keys . Seems to work on macOS and iOS, but please test on other platforms.

* Format code with `prettier`

Co-authored-by: Deluan <deluan@navidrome.org>
This commit is contained in:
certuna 2021-03-21 19:34:10 +01:00 committed by GitHub
parent 9fb55d4025
commit 1ea3d005e8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -59,6 +59,7 @@ const authProvider = {
logout: () => {
stopEventStream()
removeItems()
clearServiceWorkerCache()
return Promise.resolve()
},
@ -97,6 +98,12 @@ const removeItems = () => {
localStorage.removeItem('subsonic-token')
}
const clearServiceWorkerCache = () => {
caches.keys().then(function (keyList) {
for (let key of keyList) caches.delete(key)
})
}
const generateSubsonicSalt = () => {
const h = md5(uuidv4())
return h.slice(0, 6)