mirror of
https://github.com/koel/koel
synced 2024-11-12 23:47:09 +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?
|
// This may cause a minor problem if the request fails somehow, but do we care?
|
||||||
song.liked = !song.liked;
|
song.liked = !song.liked;
|
||||||
|
|
||||||
if (song.liked) {
|
song.liked ? this.add(song) : this.remove(song);
|
||||||
this.add(song);
|
|
||||||
} else {
|
|
||||||
this.remove(song);
|
|
||||||
}
|
|
||||||
|
|
||||||
http.post('interaction/like', { song: song.id }, () => cb && cb());
|
http.post('interaction/like', { song: song.id }, () => cb && cb());
|
||||||
},
|
},
|
||||||
|
|
|
@ -218,9 +218,7 @@ export default {
|
||||||
* @return {Object} The queued song.
|
* @return {Object} The queued song.
|
||||||
*/
|
*/
|
||||||
set current(song) {
|
set current(song) {
|
||||||
this.state.current = song;
|
return this.state.current = song;
|
||||||
|
|
||||||
return this.current;
|
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -229,6 +227,6 @@ export default {
|
||||||
* @return {Array.<Object>} The shuffled array of song objects
|
* @return {Array.<Object>} The shuffled array of song objects
|
||||||
*/
|
*/
|
||||||
shuffle() {
|
shuffle() {
|
||||||
return (this.all = shuffle(this.all));
|
return this.all = shuffle(this.all);
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
|
@ -96,11 +96,7 @@ export default {
|
||||||
getLength(songs, toHis) {
|
getLength(songs, toHis) {
|
||||||
const duration = songs.reduce((length, song) => length + song.length, 0);
|
const duration = songs.reduce((length, song) => length + song.length, 0);
|
||||||
|
|
||||||
if (toHis) {
|
return toHis ? secondsToHis(duration) : duration;
|
||||||
return secondsToHis(duration);
|
|
||||||
}
|
|
||||||
|
|
||||||
return duration;
|
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -395,7 +391,7 @@ export default {
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Called when the application is tore down.
|
* Called when the application is torn down.
|
||||||
* Reset stuff.
|
* Reset stuff.
|
||||||
*/
|
*/
|
||||||
teardown() {
|
teardown() {
|
||||||
|
|
|
@ -77,9 +77,7 @@ export default {
|
||||||
* @return {Object}
|
* @return {Object}
|
||||||
*/
|
*/
|
||||||
set current(user) {
|
set current(user) {
|
||||||
this.state.current = user;
|
return this.state.current = user;
|
||||||
|
|
||||||
return this.current;
|
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in a new issue