mirror of
https://github.com/koel/koel
synced 2024-11-10 06:34:14 +00:00
More code optimization
This commit is contained in:
parent
80900f17cb
commit
f8c7233cd9
4 changed files with 6 additions and 18 deletions
|
@ -44,11 +44,7 @@ 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 }, () => cb && cb());
|
||||
},
|
||||
|
|
|
@ -218,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;
|
||||
},
|
||||
|
||||
/**
|
||||
|
@ -229,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);
|
||||
},
|
||||
};
|
||||
|
|
|
@ -96,11 +96,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;
|
||||
},
|
||||
|
||||
/**
|
||||
|
@ -395,7 +391,7 @@ export default {
|
|||
},
|
||||
|
||||
/**
|
||||
* Called when the application is tore down.
|
||||
* Called when the application is torn down.
|
||||
* Reset stuff.
|
||||
*/
|
||||
teardown() {
|
||||
|
|
|
@ -77,9 +77,7 @@ export default {
|
|||
* @return {Object}
|
||||
*/
|
||||
set current(user) {
|
||||
this.state.current = user;
|
||||
|
||||
return this.current;
|
||||
return this.state.current = user;
|
||||
},
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in a new issue