build: v1.5.2; fix: spotify favorites playlist not showing in Favorites page until the refresh button is clicked (closes #21); refactor: favorites logic
This commit is contained in:
@@ -1,22 +0,0 @@
|
||||
import { socket } from '@/utils/socket'
|
||||
|
||||
let favoritesData = {}
|
||||
let cached = false
|
||||
|
||||
export function getFavoritesData() {
|
||||
if (cached) {
|
||||
return favoritesData
|
||||
} else {
|
||||
socket.emit('get_favorites_data')
|
||||
|
||||
return new Promise((resolve, reject) => {
|
||||
socket.on('init_favorites', data => {
|
||||
favoritesData = data
|
||||
cached = true
|
||||
|
||||
socket.off('init_favorites')
|
||||
resolve(data)
|
||||
})
|
||||
})
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user