From 31797ad92ab5252297bebe712f32a4874b2249fd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pierre=20de=20la=20Martini=C3=A8re?= Date: Mon, 9 May 2016 13:17:52 +0200 Subject: [PATCH] Fix search --- src/js/actions/LibraryActions.js | 13 +++++++------ src/js/stores/AppStore.js | 6 +++--- src/js/utils/utils.js | 2 ++ 3 files changed, 12 insertions(+), 9 deletions(-) diff --git a/src/js/actions/LibraryActions.js b/src/js/actions/LibraryActions.js index 3b091566c..9a4a086c6 100644 --- a/src/js/actions/LibraryActions.js +++ b/src/js/actions/LibraryActions.js @@ -2,7 +2,8 @@ import AppDispatcher from '../dispatcher/AppDispatcher'; import AppConstants from '../constants/AppConstants'; import AppActions from './AppActions'; -import app from '../utils/app'; +import app from '../utils/app'; +import utils from '../utils/utils'; import mmd from 'musicmetadata'; import fs from 'fs'; @@ -148,11 +149,11 @@ export default { // 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()) + artist : metadata.artist.map(meta => utils.stripAccents(meta.toLowerCase())), + album : utils.stripAccents(metadata.album.toLowerCase()), + albumartist : metadata.albumartist.map(meta => utils.stripAccents(meta.toLowerCase())), + title : utils.stripAccents(metadata.title.toLowerCase()), + genre : metadata.genre.map(meta => utils.stripAccents(meta.toLowerCase())) } app.db.find({ path: metadata.path }, function (err, docs) { diff --git a/src/js/stores/AppStore.js b/src/js/stores/AppStore.js index 9ab1f4c0d..0e6abf9ff 100644 --- a/src/js/stores/AppStore.js +++ b/src/js/stores/AppStore.js @@ -166,9 +166,9 @@ AppDispatcher.register(function(payload) { if(search != '' && search != undefined) { if(utils.stripAccents(track.loweredMetas.artist.join(', ')).indexOf(search) === -1 - && utils.stripAccents(track.album.toLowerCase()).indexOf(search) === -1 - && utils.stripAccents(track.loweredMetas.genre.join(', ')).toLowerCase().indexOf(search) === -1 - && utils.stripAccents(track.title.toLowerCase().indexOf(search) === -1)) { + && track.loweredMetas.album.indexOf(search) === -1 + && track.loweredMetas.genre.join(', ').indexOf(search) === -1 + && track.loweredMetas.title.indexOf(search) === -1) { continue; diff --git a/src/js/utils/utils.js b/src/js/utils/utils.js index 1ba902581..962d5c74b 100644 --- a/src/js/utils/utils.js +++ b/src/js/utils/utils.js @@ -94,6 +94,8 @@ export default { */ stripAccents(str) { + console.log(str) + var accents = "ÀÁÂÃÄÅÇÈÉÊËÌÍÎÏÒÓÔÕÖÙÚÛÜÝàáâãäåçèéêëìíîïðòóôõöùúûüýÿñ", fixes = "aaaaaaceeeeiiiiooooouuuuyaaaaaaceeeeiiiioooooouuuuyyn", reg = new RegExp("(" + accents.split("").join("|") + ")", "g");