Skip to content
This repository was archived by the owner on Jun 28, 2021. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/components/SearchAutocomplete/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,13 +51,13 @@ class SearchAutocomplete extends Component {
const chapterId = captures[1];
const ayahNum = captures[2];
const chapter = this.props.chapters[chapterId];
matches.push([chapter.name.simple, chapter.chapterNumber + (ayahNum ? `/${ayahNum}` : '')]);
matches.push([chapter.nameSimple, chapter.chapterNumber + (ayahNum ? `/${ayahNum}` : '')]);
} else if (value.length >= 2) {
const escaped = value.replace(/[-\\^$*+?.()|[\]{}]/g, '\\$&');

Object.keys(this.props.chapters).forEach((chapterId) => {
const chapter = this.props.chapters[chapterId];
if (RegExp(escaped, 'i').test(chapter.name.simple.replace(/['-]/g, ''))) {
if (RegExp(escaped, 'i').test(chapter.nameSimple.replace(/['-]/g, ''))) {
matches.push([chapter.nameSimple, chapter.chapterNumber]);
} else if (RegExp(escaped, 'i').test(chapter.nameArabic)) {
matches.push([chapter.nameArabic, chapter.chapterNumber]);
Expand Down Expand Up @@ -154,7 +154,7 @@ class SearchAutocomplete extends Component {
onKeyDown={event => this.handleItemKeyDown(event, item)}
>
<div className={styles.link}>
<a href={item.href} tabIndex="-1">{item.href}</a>
<a href={item.href} tabIndex="-1">{item.ayah}</a>
</div>
<div className={styles.text}>
<a href={item.href} tabIndex="-1" dangerouslySetInnerHTML={{ __html: item.text }} />
Expand Down
20 changes: 11 additions & 9 deletions src/components/Verse/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,19 +26,21 @@ const Share = Loadable({
class Verse extends Component {
// TODO: Should this belong here?
componentDidMount() {
const { verse, audio } = this.props;

this.props.loadAudio({
chapterId: verse.chapterId,
verseId: verse.id,
verseKey: verse.verseKey,
audio
});
const { verse, audio, isSearched } = this.props;

if (!isSearched) {
this.props.loadAudio({
chapterId: verse.chapterId,
verseId: verse.id,
verseKey: verse.verseKey,
audio
});
}
}

// TODO: Should this belong here?
componentWillReceiveProps(nextProps) {
if (this.props.audio !== nextProps.audio) {
if (!this.props.isSearched && this.props.audio !== nextProps.audio) {
const { verse, audio } = nextProps;

this.props.loadAudio({
Expand Down
2 changes: 1 addition & 1 deletion src/redux/actions/suggest.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {
export function suggest(query, lang = 'en') {
return {
types: [SUGGEST, SUGGEST_SUCCESS, SUGGEST_FAIL],
promise: client => client.get('/v2/suggest', { params: { q: query, l: lang } }),
promise: client => client.get('/api/v3/suggest', { params: { q: query, l: lang } }),
query
};
}
Expand Down