diff options
Diffstat (limited to 'src/content')
-rw-r--r-- | src/content/components/common/follow.js | 3 | ||||
-rw-r--r-- | src/content/components/common/index.js | 9 | ||||
-rw-r--r-- | src/content/components/common/input.js | 3 | ||||
-rw-r--r-- | src/content/components/common/keymapper.js | 3 | ||||
-rw-r--r-- | src/content/components/frame-content.js | 15 | ||||
-rw-r--r-- | src/content/components/top-content/follow-controller.js | 4 | ||||
-rw-r--r-- | src/content/components/top-content/index.js | 9 | ||||
-rw-r--r-- | src/content/index.js | 14 |
8 files changed, 13 insertions, 47 deletions
diff --git a/src/content/components/common/follow.js b/src/content/components/common/follow.js index 4eeaaa2..19c31eb 100644 --- a/src/content/components/common/follow.js +++ b/src/content/components/common/follow.js @@ -39,9 +39,6 @@ export default class Follow { messages.onMessage(this.onMessage.bind(this)); } - update() { - } - key(key) { if (Object.keys(this.hints).length === 0) { return false; diff --git a/src/content/components/common/index.js b/src/content/components/common/index.js index 5f5531b..4c2c1df 100644 --- a/src/content/components/common/index.js +++ b/src/content/components/common/index.js @@ -14,21 +14,12 @@ export default class Common { input.onKey(key => keymapper.key(key)); this.store = store; - this.children = [ - follow, - input, - keymapper, - ]; this.reloadSettings(); messages.onMessage(this.onMessage.bind(this)); } - update() { - this.children.forEach(c => c.update()); - } - onMessage(message) { switch (message.type) { case messages.SETTINGS_CHANGED: diff --git a/src/content/components/common/input.js b/src/content/components/common/input.js index ef5af29..8b1d35d 100644 --- a/src/content/components/common/input.js +++ b/src/content/components/common/input.js @@ -28,9 +28,6 @@ export default class InputComponent { target.addEventListener('keyup', this.onKeyUp.bind(this)); } - update() { - } - onKey(cb) { this.onKeyListeners.push(cb); } diff --git a/src/content/components/common/keymapper.js b/src/content/components/common/keymapper.js index 44d8212..1da3c0d 100644 --- a/src/content/components/common/keymapper.js +++ b/src/content/components/common/keymapper.js @@ -7,9 +7,6 @@ export default class KeymapperComponent { this.store = store; } - update() { - } - key(key) { this.store.dispatch(inputActions.keyPress(key)); diff --git a/src/content/components/frame-content.js b/src/content/components/frame-content.js index 46786d2..ca999ba 100644 --- a/src/content/components/frame-content.js +++ b/src/content/components/frame-content.js @@ -1,16 +1,3 @@ import CommonComponent from './common'; -export default class FrameContent { - - constructor(win, store) { - this.children = [new CommonComponent(win, store)]; - } - - update() { - this.children.forEach(c => c.update()); - } - - onMessage(message, sender) { - this.children.forEach(c => c.onMessage(message, sender)); - } -} +export default CommonComponent; diff --git a/src/content/components/top-content/follow-controller.js b/src/content/components/top-content/follow-controller.js index 7570cf8..a87ecc7 100644 --- a/src/content/components/top-content/follow-controller.js +++ b/src/content/components/top-content/follow-controller.js @@ -19,6 +19,10 @@ export default class FollowController { this.producer = null; messages.onMessage(this.onMessage.bind(this)); + + store.subscribe(() => { + this.update(); + }); } onMessage(message, sender) { diff --git a/src/content/components/top-content/index.js b/src/content/components/top-content/index.js index c4a8461..f6afbfa 100644 --- a/src/content/components/top-content/index.js +++ b/src/content/components/top-content/index.js @@ -9,13 +9,12 @@ 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); @@ -28,8 +27,6 @@ export default class TopContent { this.disableIfBlack(blacklist); this.prevBlacklist = blacklist; } - - this.children.forEach(c => c.update()); } disableIfBlack(blacklist) { diff --git a/src/content/index.js b/src/content/index.js index 77249f8..97a8b30 100644 --- a/src/content/index.js +++ b/src/content/index.js @@ -6,12 +6,8 @@ import FrameContentComponent from './components/frame-content'; const store = createStore(reducers); -let rootComponent = window.self === window.top - ? new TopContentComponent(window, store) - : new FrameContentComponent(window, store); - -store.subscribe(() => { - rootComponent.update(); -}); - -rootComponent.update(); +if (window.self === window.top) { + new TopContentComponent(window, store); // eslint-disable-line no-new +} else { + new FrameContentComponent(window, store); // eslint-disable-line no-new +} |