mirror of
https://github.com/koel/koel
synced 2024-09-20 06:11:53 +00:00
Optimization
This commit is contained in:
parent
c288968173
commit
5f70dee097
1 changed files with 5 additions and 1 deletions
|
@ -9,6 +9,7 @@ import userStore from './user';
|
|||
export default {
|
||||
stub,
|
||||
albums: [],
|
||||
cache: {},
|
||||
|
||||
state: {
|
||||
songs: [stub],
|
||||
|
@ -28,6 +29,9 @@ export default {
|
|||
|
||||
// Keep a back reference to the album
|
||||
song.album = album;
|
||||
|
||||
// Cache the song, so that byId() is faster
|
||||
this.cache[song.id] = song;
|
||||
});
|
||||
|
||||
return songs.concat(album.songs);
|
||||
|
@ -93,7 +97,7 @@ export default {
|
|||
* @return {Object}
|
||||
*/
|
||||
byId(id) {
|
||||
return _.find(this.state.songs, { id });
|
||||
return this.cache[id];
|
||||
},
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in a new issue