Skip to content

Commit 5d151a3

Browse files
committed
searching for artist name containing single quote fails #109
1 parent 51392f8 commit 5d151a3

10 files changed

+48
-1
lines changed

AlbumArtScreen.js

+2
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ import AlbumArt from './AlbumArt';
2929
import MPDConnection from './MPDConnection';
3030
import { StyleManager, bgColor } from './Styles';
3131
import UPnPManager from './UPnPManager';
32+
import SeachUtil from './SeachUtil';
3233

3334
class MissingModal extends React.Component {
3435
state = {
@@ -55,6 +56,7 @@ class MissingModal extends React.Component {
5556

5657
search = (text) => {
5758
if (text.length > 0) {
59+
text = SeachUtil.convert(text);
5860
let filtered = this.state.fullset.filter((item) => {
5961
return item.name.toLowerCase().indexOf(text.toLowerCase()) > -1;
6062
});

AlbumsScreen.js

+2
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ import NewPlaylistModal from './NewPlaylistModal';
3131
import Config from './Config';
3232
import { StyleManager } from './Styles';
3333
import Base64 from './Base64';
34+
import SeachUtil from './SeachUtil';
3435

3536
export default class AlbumsScreen extends React.Component {
3637
static navigationOptions = ({ navigation }) => {
@@ -181,6 +182,7 @@ export default class AlbumsScreen extends React.Component {
181182

182183
search = (text) => {
183184
if (text.length > 0) {
185+
text = SeachUtil.convert(text);
184186
let filtered = this.state.fullset.filter((album) => {
185187
return album.name.toLowerCase().indexOf(text.toLowerCase()) > -1;
186188
});

ArtistsScreen.js

+4
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ import AlbumArt from './AlbumArt';
3131
import Config from './Config';
3232
import { StyleManager } from './Styles';
3333
import NewPlaylistModal from './NewPlaylistModal';
34+
import SeachUtil from './SeachUtil';
3435

3536
class AlbumListItem extends React.PureComponent {
3637
constructor(props) {
@@ -400,6 +401,7 @@ export default class ArtistsScreen extends React.Component {
400401

401402
search = (text) => {
402403
if (text.length > 0) {
404+
text = SeachUtil.convert(text);
403405
let filtered = this.state.fullset.filter((artist) => {
404406
return artist.name.toLowerCase().indexOf(text.toLowerCase()) > -1;
405407
});
@@ -411,6 +413,7 @@ export default class ArtistsScreen extends React.Component {
411413

412414
searchGenres = (text) => {
413415
if (text.length > 0) {
416+
text = SeachUtil.convert(text);
414417
let filtered = this.state.genresFullset.filter((genre) => {
415418
return genre.name.toLowerCase().indexOf(text.toLowerCase()) > -1;
416419
});
@@ -422,6 +425,7 @@ export default class ArtistsScreen extends React.Component {
422425

423426
searchAlbums = (text) => {
424427
if (text.length > 0) {
428+
text = SeachUtil.convert(text);
425429
let filtered = this.state.albumsFullset.filter((album) => {
426430
return album.name.toLowerCase().indexOf(text.toLowerCase()) > -1;
427431
});

FilesScreen.js

+2
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ import Base64 from './Base64';
3131
import NewPlaylistModal from './NewPlaylistModal';
3232
import { StyleManager } from './Styles';
3333
import Config from './Config';
34+
import SeachUtil from './SeachUtil';
3435

3536
export default class FilesScreen extends React.Component {
3637
static navigationOptions = ({ navigation }) => {
@@ -255,6 +256,7 @@ export default class FilesScreen extends React.Component {
255256

256257
search = (text) => {
257258
if (text.length > 0) {
259+
text = SeachUtil.convert(text);
258260
let filtered = this.state.fullset.filter((file) => {
259261
if (file.dir) {
260262
return file.dir.toLowerCase().indexOf(text.toLowerCase()) > -1;

NewPlaylistModal.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ import React from 'react';
1919
import { Text, View, Modal, FlatList, TouchableOpacity, ActivityIndicator, Appearance } from 'react-native';
2020
import { SearchBar, Input, Button } from "@rneui/themed";
2121
import Icon from 'react-native-vector-icons/Ionicons';
22-
import FAIcon from 'react-native-vector-icons/FontAwesome';
22+
import SeachUtil from './SeachUtil';
2323

2424
import MPDConnection from './MPDConnection';
2525
import { StyleManager } from './Styles';
@@ -69,6 +69,7 @@ export default class NewPlaylistModal extends React.Component {
6969

7070
search = (text) => {
7171
if (text.length > 0) {
72+
text = SeachUtil.convert(text);
7273
let filtered = this.state.fullset.filter((playlist) => {
7374
return playlist.toLowerCase().indexOf(text.toLowerCase()) > -1;
7475
});

PlaylistDetails.js

+2
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ import { ActionSheetCustom as ActionSheet } from 'react-native-actionsheet';
2626

2727
import MPDConnection from './MPDConnection';
2828
import { StyleManager } from './Styles';
29+
import SeachUtil from './SeachUtil';
2930

3031
export default class PlaylistDetails extends React.Component {
3132
static navigationOptions = ({ navigation }) => {
@@ -94,6 +95,7 @@ export default class PlaylistDetails extends React.Component {
9495

9596
search = (text) => {
9697
if (text.length > 0) {
98+
text = SeachUtil.convert(text);
9799
let filtered = this.state.fullset.filter((entry) => {
98100
return entry.title.toLowerCase().indexOf(text.toLowerCase()) > -1;
99101
});

PlaylistEditor.js

+2
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ import ActionButton from 'react-native-action-button';
2626
import MPDConnection from './MPDConnection';
2727
import NewPlaylistModal from './NewPlaylistModal';
2828
import { StyleManager } from './Styles';
29+
import SeachUtil from './SeachUtil';
2930

3031
class AddStreamURLModal extends React.Component {
3132
state = {
@@ -139,6 +140,7 @@ export default class PlaylistEditor extends React.Component {
139140

140141
search = (text) => {
141142
if (text.length > 0) {
143+
text = SeachUtil.convert(text);
142144
let filtered = this.state.fullset.filter((playlist) => {
143145
return playlist.toLowerCase().indexOf(text.toLowerCase()) > -1;
144146
});

SeachUtil.js

+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
/*
2+
* The MIT License (MIT)
3+
*
4+
* Copyright (c) 2023 Richard Backhouse
5+
*
6+
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"),
7+
* to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense,
8+
* and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
9+
*
10+
* The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
11+
*
12+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
13+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
14+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
15+
* DEALINGS IN THE SOFTWARE.
16+
*/
17+
18+
export default {
19+
convert: function(text) {
20+
let newtext = text.replace(/./g, (char) => {
21+
const charCode = char.charCodeAt(0);
22+
if (charCode === 8216 || charCode === 8217) return '\'';
23+
if (charCode === 8220 || charCode === 8221) return '"';
24+
return char;
25+
});
26+
return newtext;
27+
}
28+
}

SongsScreen.js

+2
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ import Base64 from './Base64';
3232
import AlbumArt from './AlbumArt';
3333
import NewPlaylistModal from './NewPlaylistModal';
3434
import { StyleManager } from './Styles';
35+
import SeachUtil from './SeachUtil';
3536

3637
export default class SongsScreen extends React.Component {
3738
static navigationOptions = ({ navigation }) => {
@@ -150,6 +151,7 @@ export default class SongsScreen extends React.Component {
150151

151152
search = (text) => {
152153
if (text.length > 0) {
154+
text = SeachUtil.convert(text);
153155
let filtered = this.state.fullset.filter((song) => {
154156
return song.title.toLowerCase().indexOf(text.toLowerCase()) > -1;
155157
});

UPnPBrowseScreen.js

+2
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ import { StyleManager } from './Styles';
2929
import Config from './Config';
3030
import UPnPManager from './UPnPManager';
3131
import AudioStreamManager from './AudioStreamManager';
32+
import SeachUtil from './SeachUtil';
3233

3334
export default class UPnPBrowseScreen extends React.Component {
3435
static navigationOptions = ({ navigation }) => {
@@ -128,6 +129,7 @@ export default class UPnPBrowseScreen extends React.Component {
128129

129130
search = (text) => {
130131
if (text.length > 0) {
132+
text = SeachUtil.convert(text);
131133
let filtered = this.state.fullset.filter((item) => {
132134
return item.title.toLowerCase().indexOf(text.toLowerCase()) > -1;
133135
});

0 commit comments

Comments
 (0)