Merge branch 'master' into compilation

This commit is contained in:
An Phan 2016-05-05 18:39:13 +08:00
commit 667175c23d
8 changed files with 33 additions and 110 deletions

View file

@ -165,6 +165,10 @@
justify-content: center;
margin-top: 8px;
}
span:first-child {
flex: 0 0 28px;
}
}
> section {

View file

@ -73,7 +73,7 @@
}
@media only screen and(max-width: 768px) {
flex: 0;
flex: auto;
width: 64px;
margin-top: 8px;
}

View file

@ -44,17 +44,9 @@ export default {
// This may cause a minor problem if the request fails somehow, but do we care?
song.liked = !song.liked;
if (song.liked) {
this.add(song);
} else {
this.remove(song);
}
song.liked ? this.add(song) : this.remove(song);
http.post('interaction/like', { song: song.id }, () => {
if (cb) {
cb();
}
});
http.post('interaction/like', { song: song.id }, () => cb && cb());
},
/**
@ -94,11 +86,7 @@ export default {
each(songs, song => song.liked = true);
this.add(songs);
http.post('interaction/batch/like', { songs: map(songs, 'id') }, () => {
if (cb) {
cb();
}
});
http.post('interaction/batch/like', { songs: map(songs, 'id') }, () => cb && cb());
},
/**
@ -108,15 +96,9 @@ export default {
* @param {?Function} cb
*/
unlike(songs, cb = null) {
// Don't wait for the HTTP response to update the status, just set them to Unliked right away.
// This may cause a minor problem if the request fails somehow, but do we care?
each(songs, song => song.liked = false);
this.remove(songs);
http.post('interaction/batch/unlike', { songs: map(songs, 'id') }, () => {
if (cb) {
cb();
}
});
http.post('interaction/batch/unlike', { songs: map(songs, 'id') }, () => cb && cb());
},
};

View file

@ -89,9 +89,7 @@ export default {
this.getSongs(playlist);
this.add(playlist);
if (cb) {
cb();
}
cb && cb();
});
},
@ -106,10 +104,7 @@ export default {
http.delete(`playlist/${playlist.id}`, {}, () => {
this.remove(playlist);
if (cb) {
cb();
}
cb && cb();
});
},
@ -128,11 +123,7 @@ export default {
return;
}
http.put(`playlist/${playlist.id}/sync`, { songs: map(playlist.songs, 'id') }, () => {
if (cb) {
cb();
}
});
http.put(`playlist/${playlist.id}/sync`, { songs: map(playlist.songs, 'id') }, () => cb && cb());
},
/**
@ -145,11 +136,7 @@ export default {
removeSongs(playlist, songs, cb = null) {
playlist.songs = difference(playlist.songs, songs);
http.put(`playlist/${playlist.id}/sync`, { songs: map(playlist.songs, 'id') }, () => {
if (cb) {
cb();
}
});
http.put(`playlist/${playlist.id}/sync`, { songs: map(playlist.songs, 'id') }, () => cb && cb());
},
/**
@ -161,10 +148,6 @@ export default {
update(playlist, cb = null) {
NProgress.start();
http.put(`playlist/${playlist.id}`, { name: playlist.name }, () => {
if (cb) {
cb();
}
});
http.put(`playlist/${playlist.id}`, { name: playlist.name }, () => cb && cb());
},
};

View file

@ -157,10 +157,7 @@ export default {
clear(cb = null) {
this.all = [];
this.current = null;
if (cb) {
cb();
}
cb && cb();
},
/**
@ -221,9 +218,7 @@ export default {
* @return {Object} The queued song.
*/
set current(song) {
this.state.current = song;
return this.current;
return this.state.current = song;
},
/**
@ -232,6 +227,6 @@ export default {
* @return {Array.<Object>} The shuffled array of song objects
*/
shuffle() {
return (this.all = shuffle(this.all));
return this.all = shuffle(this.all);
},
};

View file

@ -50,9 +50,7 @@ export default {
window.useLastfm = this.state.useLastfm = data.useLastfm;
if (successCb) {
successCb();
}
successCb && successCb();
}, errorCb);
},

View file

@ -109,11 +109,7 @@ export default {
getLength(songs, toHis) {
const duration = songs.reduce((length, song) => length + song.length, 0);
if (toHis) {
return secondsToHis(duration);
}
return duration;
return toHis ? secondsToHis(duration) : duration;
},
/**
@ -171,9 +167,7 @@ export default {
song.album.playCount += song.playCount - oldCount;
song.artist.playCount += song.playCount - oldCount;
if (cb) {
cb();
}
cb && cb();
});
},
@ -199,9 +193,7 @@ export default {
getInfo(song, cb = null) {
// Check if the song's info has been retrieved before.
if (song.infoRetrieved) {
if (cb) {
cb();
}
cb && cb();
return;
}
@ -242,9 +234,7 @@ export default {
song.infoRetrieved = true;
if (cb) {
cb();
}
cb && cb();
});
},
@ -259,11 +249,7 @@ export default {
return;
}
http.post(`${song.id}/scrobble/${song.playStartTime}`, () => {
if (cb) {
cb();
}
});
http.post(`${song.id}/scrobble/${song.playStartTime}`, () => cb && cb());
},
/**
@ -285,14 +271,8 @@ export default {
}, response => {
each(response.data, song => this.syncUpdatedSong(song));
if (successCb) {
successCb();
}
}, () => {
if (errorCb) {
errorCb();
}
});
successCb && successCb();
}, () => errorCb && errorCb());
},
/**
@ -424,7 +404,7 @@ export default {
},
/**
* Called when the application is tore down.
* Called when the application is torn down.
* Reset stuff.
*/
teardown() {

View file

@ -77,9 +77,7 @@ export default {
* @return {Object}
*/
set current(user) {
this.state.current = user;
return this.current;
return this.state.current = user;
},
/**
@ -105,11 +103,7 @@ export default {
*/
login(email, password, successCb = null, errorCb = null) {
NProgress.start();
http.post('me', { email, password }, () => {
if (successCb) {
successCb();
}
}, errorCb);
http.post('me', { email, password }, () => successCb && successCb(), errorCb);
},
/**
@ -118,11 +112,7 @@ export default {
* @param {Function} cb The callback.
*/
logout(cb = null) {
http.delete('me', {}, () => {
if (cb) {
cb();
}
});
http.delete('me', {}, () => cb && cb());
},
/**
@ -141,10 +131,7 @@ export default {
email: this.current.email
}, () => {
this.setAvatar();
if (cb) {
cb();
}
cb && cb();
}
);
},
@ -166,9 +153,7 @@ export default {
this.setAvatar(user);
this.all.unshift(user);
if (cb) {
cb();
}
cb && cb();
});
},
@ -188,9 +173,7 @@ export default {
this.setAvatar(user);
user.password = '';
if (cb) {
cb();
}
cb && cb();
});
},
@ -228,9 +211,7 @@ export default {
/**
* Brian May enters the stage.
*/
if (cb) {
cb();
}
cb && cb();
});
},
};