aboutsummaryrefslogtreecommitdiff
path: root/src/content/components/top-content/index.js
blob: c3189018dc2dc47f6bb32b584da31da9b0235cbf (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
import CommonComponent from '../common';
import FollowController from './follow-controller';
import * as consoleFrames from '../../console-frames';
import messages from 'shared/messages';

export default class TopContent {

  constructor(win, store) {
    this.win = win;
    this.children = [
      new CommonComponent(win, store),
      new FollowController(win, store),
    ];

    // TODO make component
    consoleFrames.initialize(window.document);

    messages.onMessage(this.onMessage.bind(this));
  }

  update() {
    this.children.forEach(c => c.update());
  }

  onMessage(message) {
    switch (message.type) {
    case messages.CONSOLE_HIDE_COMMAND:
      this.win.focus();
      consoleFrames.blur(window.document);
      return Promise.resolve();
    }
  }
}