koel/resources/assets/js/stores/shared.js
2015-12-20 20:17:35 +08:00

33 lines
750 B
JavaScript

import http from '../services/http';
import { assign } from 'lodash';
export default {
state: {
songs: [],
albums: [],
artists: [],
favorites: [],
queued: [],
interactions: [],
users: [],
settings: [],
currentUser: null,
playlists: [],
useLastfm: false,
},
init(cb = null) {
http.get('data', {}, data => {
assign(this.state, data);
// If this is a new user, initialize his preferences to be an empty object.
if (!this.state.currentUser.preferences) {
this.state.currentUser.preferences = {};
}
if (cb) {
cb();
}
});
},
};