diff --git a/src/js/actions/LibraryActions.js b/src/js/actions/LibraryActions.js index 4b016d83a..c6d2ad2c9 100644 --- a/src/js/actions/LibraryActions.js +++ b/src/js/actions/LibraryActions.js @@ -17,7 +17,7 @@ const dialog = electron.remote.dialog; export default { refreshTracks: function() { - app.db.find({}).sort({ 'lArtist': 1, 'year': 1, 'album': 1, 'disk': 1, 'track.no': 1 }).exec(function (err, tracks) { + app.db.find({}).sort({ 'loweredMetas.artist': 1, 'year': 1, 'loweredMetas.album': 1, 'disk.no': 1, 'track.no': 1 }).exec(function (err, tracks) { if (err) throw err; else { AppDispatcher.dispatch({ @@ -127,19 +127,30 @@ export default { forloop(i + 1); if(err) console.warn('An error occured while reading ' + file + ' id3 tags: ' + err); - delete metadata.picture; - fs.realpath(file, (err, realpath) => { if(err) console.warn(err); - metadata.path = realpath - metadata.lArtist = metadata.artist.length === 0 ? ['unknown artist'] : metadata.artist[0].toLowerCase(); + // We don't want it + delete metadata.picture; + + // File path + metadata.path = realpath; + // Unknown metas if(metadata.artist.length === 0) metadata.artist = ['Unknown artist']; if(metadata.album === null || metadata.album === '') metadata.album = 'Unknown'; if(metadata.title === null || metadata.title === '') metadata.title = path.parse(file).base; - if(metadata.duration == '') metadata.duration = 0; + if(metadata.duration == '') metadata.duration = 0; // .wav problem + + // Formated metas for sorting + metadata.loweredMetas = { + artist : metadata.artist.map(meta => meta.toLowerCase()), + album : metadata.album.toLowerCase(), + albumartist : metadata.albumartist.map(meta => meta.toLowerCase()), + title : metadata.title.toLowerCase(), + genre : metadata.genre.map(meta => meta.toLowerCase()) + } app.db.find({ path: metadata.path }, function (err, docs) { if(err) console.warn(err); diff --git a/src/js/stores/AppStore.js b/src/js/stores/AppStore.js index 380f569f1..2d4575530 100644 --- a/src/js/stores/AppStore.js +++ b/src/js/stores/AppStore.js @@ -35,11 +35,11 @@ var AppStore = objectAssign({}, EventEmitter.prototype, { oldPlaylist : null, // Playlist backup oldPlaylistCursor : null, // The last cursor backup (to roll stuff back, e.g. unshuffle) playerStatus : 'stop', // Player status - notifications : [], // The array of notifications + notifications : [], // The array of notifications refreshingLibrary : false, // If the app is currently refreshing the app repeat : false, // the current repeat state (one, all, false) shuffle : false, // If shuffle mode is enabled - refreshProgress : 0, // Progress of the refreshing library + refreshProgress : 0, // Progress of the refreshing library getStore: function() { return { @@ -70,6 +70,7 @@ var AppStore = objectAssign({}, EventEmitter.prototype, { export default AppStore; + /* |-------------------------------------------------------------------------- | Dispatcher Listener @@ -149,9 +150,9 @@ AppDispatcher.register(function(payload) { if(search != '' && search != undefined) { - if(track.lArtist.indexOf(search) === -1 + if(track.loweredMetas.artist.join(', ').indexOf(search) === -1 && track.album.toLowerCase().indexOf(search) === -1 - && track.genre.join(', ').toLowerCase().indexOf(search) === -1 + && track.loweredMetas.genre.join(', ').toLowerCase().indexOf(search) === -1 && track.title.toLowerCase().indexOf(search) === -1) { continue;