Remove update propagation

jh-changes
Shin'ya Ueoka 7 years ago
parent c4996ef5d8
commit 24c7369451
  1. 0
      src/background/actions/settings.js
  2. 4
      src/console/components/completion.js
  3. 4
      src/console/components/console.js
  4. 12
      src/console/index.js
  5. 3
      src/content/components/common/follow.js
  6. 9
      src/content/components/common/index.js
  7. 3
      src/content/components/common/input.js
  8. 3
      src/content/components/common/keymapper.js
  9. 15
      src/content/components/frame-content.js
  10. 4
      src/content/components/top-content/follow-controller.js
  11. 9
      src/content/components/top-content/index.js
  12. 14
      src/content/index.js

@ -3,6 +3,10 @@ export default class Completion {
this.wrapper = wrapper; this.wrapper = wrapper;
this.store = store; this.store = store;
this.prevState = {}; this.prevState = {};
store.subscribe(() => {
this.update();
});
} }
update() { update() {

@ -17,6 +17,10 @@ export default class ConsoleComponent {
this.hideCommand(); this.hideCommand();
this.hideMessage(); this.hideMessage();
store.subscribe(() => {
this.update();
});
} }
onBlur() { onBlur() {

@ -7,14 +7,11 @@ import { createStore } from 'shared/store';
import * as consoleActions from 'console/actions/console'; import * as consoleActions from 'console/actions/console';
const store = createStore(reducers); const store = createStore(reducers);
let completionComponent = null;
let consoleComponent = null;
window.addEventListener('load', () => { window.addEventListener('load', () => {
let wrapper = document.querySelector('#vimvixen-console-completion'); let wrapper = document.querySelector('#vimvixen-console-completion');
completionComponent = new CompletionComponent(wrapper, store); new CompletionComponent(wrapper, store); // eslint-disable-line no-new
new ConsoleComponent(document.body, store); // eslint-disable-line no-new
consoleComponent = new ConsoleComponent(document.body, store);
}); });
const onMessage = (message) => { const onMessage = (message) => {
@ -30,11 +27,6 @@ const onMessage = (message) => {
} }
}; };
store.subscribe(() => {
completionComponent.update();
consoleComponent.update();
});
browser.runtime.onMessage.addListener(onMessage); browser.runtime.onMessage.addListener(onMessage);
window.addEventListener('message', (event) => { window.addEventListener('message', (event) => {
onMessage(JSON.parse(event.data)); onMessage(JSON.parse(event.data));

@ -39,9 +39,6 @@ export default class Follow {
messages.onMessage(this.onMessage.bind(this)); messages.onMessage(this.onMessage.bind(this));
} }
update() {
}
key(key) { key(key) {
if (Object.keys(this.hints).length === 0) { if (Object.keys(this.hints).length === 0) {
return false; return false;

@ -14,21 +14,12 @@ export default class Common {
input.onKey(key => keymapper.key(key)); input.onKey(key => keymapper.key(key));
this.store = store; this.store = store;
this.children = [
follow,
input,
keymapper,
];
this.reloadSettings(); this.reloadSettings();
messages.onMessage(this.onMessage.bind(this)); messages.onMessage(this.onMessage.bind(this));
} }
update() {
this.children.forEach(c => c.update());
}
onMessage(message) { onMessage(message) {
switch (message.type) { switch (message.type) {
case messages.SETTINGS_CHANGED: case messages.SETTINGS_CHANGED:

@ -28,9 +28,6 @@ export default class InputComponent {
target.addEventListener('keyup', this.onKeyUp.bind(this)); target.addEventListener('keyup', this.onKeyUp.bind(this));
} }
update() {
}
onKey(cb) { onKey(cb) {
this.onKeyListeners.push(cb); this.onKeyListeners.push(cb);
} }

@ -7,9 +7,6 @@ export default class KeymapperComponent {
this.store = store; this.store = store;
} }
update() {
}
key(key) { key(key) {
this.store.dispatch(inputActions.keyPress(key)); this.store.dispatch(inputActions.keyPress(key));

@ -1,16 +1,3 @@
import CommonComponent from './common'; import CommonComponent from './common';
export default class FrameContent { export default CommonComponent;
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));
}
}

@ -19,6 +19,10 @@ export default class FollowController {
this.producer = null; this.producer = null;
messages.onMessage(this.onMessage.bind(this)); messages.onMessage(this.onMessage.bind(this));
store.subscribe(() => {
this.update();
});
} }
onMessage(message, sender) { onMessage(message, sender) {

@ -9,13 +9,12 @@ export default class TopContent {
constructor(win, store) { constructor(win, store) {
this.win = win; this.win = win;
this.children = [
new CommonComponent(win, store),
new FollowController(win, store),
];
this.store = store; this.store = store;
this.prevBlacklist = undefined; this.prevBlacklist = undefined;
new CommonComponent(win, store); // eslint-disable-line no-new
new FollowController(win, store); // eslint-disable-line no-new
// TODO make component // TODO make component
consoleFrames.initialize(this.win.document); consoleFrames.initialize(this.win.document);
@ -28,8 +27,6 @@ export default class TopContent {
this.disableIfBlack(blacklist); this.disableIfBlack(blacklist);
this.prevBlacklist = blacklist; this.prevBlacklist = blacklist;
} }
this.children.forEach(c => c.update());
} }
disableIfBlack(blacklist) { disableIfBlack(blacklist) {

@ -6,12 +6,8 @@ import FrameContentComponent from './components/frame-content';
const store = createStore(reducers); const store = createStore(reducers);
let rootComponent = window.self === window.top if (window.self === window.top) {
? new TopContentComponent(window, store) new TopContentComponent(window, store); // eslint-disable-line no-new
: new FrameContentComponent(window, store); } else {
new FrameContentComponent(window, store); // eslint-disable-line no-new
store.subscribe(() => { }
rootComponent.update();
});
rootComponent.update();