Skip to content

Commit

Permalink
Fix search
Browse files Browse the repository at this point in the history
  • Loading branch information
martpie committed May 9, 2016
1 parent 5f2b3c4 commit 31797ad
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 9 deletions.
13 changes: 7 additions & 6 deletions src/js/actions/LibraryActions.js
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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) {
Expand Down
6 changes: 3 additions & 3 deletions src/js/stores/AppStore.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
2 changes: 2 additions & 0 deletions src/js/utils/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,8 @@ export default {
*/
stripAccents(str) {

console.log(str)

var accents = "ÀÁÂÃÄÅÇÈÉÊËÌÍÎÏÒÓÔÕÖÙÚÛÜÝàáâãäåçèéêëìíîïðòóôõöùúûüýÿñ",
fixes = "aaaaaaceeeeiiiiooooouuuuyaaaaaaceeeeiiiioooooouuuuyyn",
reg = new RegExp("(" + accents.split("").join("|") + ")", "g");
Expand Down

0 comments on commit 31797ad

Please sign in to comment.