Merge branch 'master' into edit

This commit is contained in:
An Phan 2016-03-01 00:52:56 +08:00
commit 3dadb7d741
3 changed files with 14 additions and 11 deletions

View file

@ -2,19 +2,14 @@ import Vue from 'vue';
/**
* Responsible for all HTTP requests.
*
* IMPORTANT:
* If the user has a good enough connection to stream music, he or she shouldn't
* encounter any HTTP errors. That's why Koel doesn't handle HTTP errors.
* After all, even if there were errors, how bad can it be?
*/
export default {
request(method, url, data, successCb = null, errorCb = null) {
return Vue.http[method](url, data).then(successCb, errorCb);
return Vue.http[method](url, data).then(successCb).catch(errorCb);
},
get(url, data = {}, successCb = null, errorCb = null) {
return this.request('get', url, data, successCb, errorCb);
get(url, successCb = null, errorCb = null) {
return this.request('get', url, {}, successCb, errorCb);
},
post(url, data, successCb = null, errorCb = null) {

View file

@ -30,7 +30,9 @@ export default {
init(successCb = null, errorCb = null) {
this.reset();
http.get('data', data => {
http.get('data', response => {
var data = response.data;
assign(this.state, data);
// If this is a new user, initialize his preferences to be an empty object.
@ -47,7 +49,11 @@ export default {
settingStore.init(this.state.settings);
window.useLastfm = this.state.useLastfm = data.useLastfm;
}, successCb, errorCb);
if (successCb) {
successCb();
}
}, errorCb);
},
reset() {

View file

@ -180,7 +180,9 @@ export default {
return;
}
http.get(`${song.id}/info`, data => {
http.get(`${song.id}/info`, response => {
var data = response.data;
song.lyrics = data.lyrics;
// If the artist image is not in a nice form, don't use it.