Fix no previous search keywords
This commit is contained in:
parent
0496d7e269
commit
45a65b38db
2 changed files with 9 additions and 13 deletions
|
@ -22,6 +22,12 @@ const postPatternFound = (pattern) => {
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const postNoPrevious = () => {
|
||||||
|
return consoleFrames.postError(
|
||||||
|
window.document,
|
||||||
|
'No previous search keywords');
|
||||||
|
};
|
||||||
|
|
||||||
const find = (string, backwards) => {
|
const find = (string, backwards) => {
|
||||||
let caseSensitive = false;
|
let caseSensitive = false;
|
||||||
let wrapScan = true;
|
let wrapScan = true;
|
||||||
|
@ -50,6 +56,9 @@ const findNext = (currentKeyword, reset, backwards) => {
|
||||||
}
|
}
|
||||||
|
|
||||||
return promise.then((keyword) => {
|
return promise.then((keyword) => {
|
||||||
|
if (!keyword) {
|
||||||
|
return postNoPrevious();
|
||||||
|
}
|
||||||
let found = find(keyword, backwards);
|
let found = find(keyword, backwards);
|
||||||
if (!found) {
|
if (!found) {
|
||||||
window.getSelection().removeAllRanges();
|
window.getSelection().removeAllRanges();
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
import * as findActions from 'content/actions/find';
|
import * as findActions from 'content/actions/find';
|
||||||
import messages from 'shared/messages';
|
import messages from 'shared/messages';
|
||||||
import * as consoleFrames from '../../console-frames';
|
|
||||||
|
|
||||||
export default class FindComponent {
|
export default class FindComponent {
|
||||||
constructor(win, store) {
|
constructor(win, store) {
|
||||||
|
@ -32,23 +31,11 @@ export default class FindComponent {
|
||||||
|
|
||||||
next() {
|
next() {
|
||||||
let state = this.store.getState().find;
|
let state = this.store.getState().find;
|
||||||
if (!state.keyword) {
|
|
||||||
return this.postNoPrevious();
|
|
||||||
}
|
|
||||||
return this.store.dispatch(findActions.next(state.keyword, false));
|
return this.store.dispatch(findActions.next(state.keyword, false));
|
||||||
}
|
}
|
||||||
|
|
||||||
prev() {
|
prev() {
|
||||||
let state = this.store.getState().find;
|
let state = this.store.getState().find;
|
||||||
if (!state.keyword) {
|
|
||||||
return this.postNoPrevious();
|
|
||||||
}
|
|
||||||
return this.store.dispatch(findActions.prev(state.keyword, false));
|
return this.store.dispatch(findActions.prev(state.keyword, false));
|
||||||
}
|
}
|
||||||
|
|
||||||
postNoPrevious() {
|
|
||||||
return consoleFrames.postError(
|
|
||||||
window.document,
|
|
||||||
'No previous search keypards');
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
Reference in a new issue