aboutsummaryrefslogtreecommitdiff
path: root/src/content/components/top-content
diff options
context:
space:
mode:
Diffstat (limited to 'src/content/components/top-content')
-rw-r--r--src/content/components/top-content/follow-controller.js21
-rw-r--r--src/content/components/top-content/index.js11
2 files changed, 18 insertions, 14 deletions
diff --git a/src/content/components/top-content/follow-controller.js b/src/content/components/top-content/follow-controller.js
index 7570cf8..38869e6 100644
--- a/src/content/components/top-content/follow-controller.js
+++ b/src/content/components/top-content/follow-controller.js
@@ -1,4 +1,4 @@
-import * as followActions from 'content/actions/follow';
+import * as followControllerActions from 'content/actions/follow-controller';
import messages from 'shared/messages';
import HintKeyProducer from 'content/hint-key-producer';
@@ -19,12 +19,17 @@ export default class FollowController {
this.producer = null;
messages.onMessage(this.onMessage.bind(this));
+
+ store.subscribe(() => {
+ this.update();
+ });
}
onMessage(message, sender) {
switch (message.type) {
case messages.FOLLOW_START:
- return this.store.dispatch(followActions.enable(message.newTab));
+ return this.store.dispatch(
+ followControllerActions.enable(message.newTab));
case messages.FOLLOW_RESPONSE_COUNT_TARGETS:
return this.create(message.count, sender);
case messages.FOLLOW_KEY_PRESS:
@@ -34,7 +39,7 @@ export default class FollowController {
update() {
let prevState = this.state;
- this.state = this.store.getState().follow;
+ this.state = this.store.getState().followController;
if (!prevState.enabled && this.state.enabled) {
this.count();
@@ -49,7 +54,7 @@ export default class FollowController {
let shown = this.keys.filter(key => key.startsWith(this.state.keys));
if (shown.length === 1) {
this.activate();
- this.store.dispatch(followActions.disable());
+ this.store.dispatch(followControllerActions.disable());
}
broadcastMessage(this.win, {
@@ -69,18 +74,18 @@ export default class FollowController {
switch (key) {
case 'Enter':
this.activate();
- this.store.dispatch(followActions.disable());
+ this.store.dispatch(followControllerActions.disable());
break;
case 'Escape':
- this.store.dispatch(followActions.disable());
+ this.store.dispatch(followControllerActions.disable());
break;
case 'Backspace':
case 'Delete':
- this.store.dispatch(followActions.backspace());
+ this.store.dispatch(followControllerActions.backspace());
break;
default:
if (DEFAULT_HINT_CHARSET.includes(key)) {
- this.store.dispatch(followActions.keyPress(key));
+ this.store.dispatch(followControllerActions.keyPress(key));
}
break;
}
diff --git a/src/content/components/top-content/index.js b/src/content/components/top-content/index.js
index c4a8461..5124f83 100644
--- a/src/content/components/top-content/index.js
+++ b/src/content/components/top-content/index.js
@@ -9,17 +9,18 @@ export default class TopContent {
constructor(win, store) {
this.win = win;
- this.children = [
- new CommonComponent(win, store),
- new FollowController(win, store),
- ];
this.store = store;
this.prevBlacklist = undefined;
+ new CommonComponent(win, store); // eslint-disable-line no-new
+ new FollowController(win, store); // eslint-disable-line no-new
+
// TODO make component
consoleFrames.initialize(this.win.document);
messages.onMessage(this.onMessage.bind(this));
+
+ this.store.subscribe(() => this.update());
}
update() {
@@ -28,8 +29,6 @@ export default class TopContent {
this.disableIfBlack(blacklist);
this.prevBlacklist = blacklist;
}
-
- this.children.forEach(c => c.update());
}
disableIfBlack(blacklist) {