Types src/content

This commit is contained in:
Shin'ya Ueoka 2019-05-02 14:08:51 +09:00
parent 992b3ac65d
commit d01db82c0d
62 changed files with 1411 additions and 468 deletions

View file

@ -1,15 +1,17 @@
import * as findActions from 'content/actions/find';
import messages from 'shared/messages';
import * as findActions from '../../actions/find';
import * as messages from '../../../shared/messages';
import MessageListener from '../../MessageListener';
export default class FindComponent {
constructor(win, store) {
this.win = win;
private store: any;
constructor(store: any) {
this.store = store;
messages.onMessage(this.onMessage.bind(this));
new MessageListener().onWebMessage(this.onMessage.bind(this));
}
onMessage(message) {
onMessage(message: messages.Message) {
switch (message.type) {
case messages.CONSOLE_ENTER_FIND:
return this.start(message.text);
@ -20,22 +22,25 @@ export default class FindComponent {
}
}
start(text) {
start(text: string) {
let state = this.store.getState().find;
if (text.length === 0) {
return this.store.dispatch(findActions.next(state.keyword, true));
return this.store.dispatch(
findActions.next(state.keyword as string, true));
}
return this.store.dispatch(findActions.next(text, true));
}
next() {
let state = this.store.getState().find;
return this.store.dispatch(findActions.next(state.keyword, false));
return this.store.dispatch(
findActions.next(state.keyword as string, false));
}
prev() {
let state = this.store.getState().find;
return this.store.dispatch(findActions.prev(state.keyword, false));
return this.store.dispatch(
findActions.prev(state.keyword as string, false));
}
}