From e76ca380f733b515c31297a285d8bea44e074a1b Mon Sep 17 00:00:00 2001 From: Shin'ya Ueoka Date: Fri, 10 May 2019 22:27:20 +0900 Subject: Make addon-enabled as a clean architecture --- src/content/components/top-content/index.ts | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) (limited to 'src/content/components/top-content/index.ts') diff --git a/src/content/components/top-content/index.ts b/src/content/components/top-content/index.ts index ac95ea9..101edca 100644 --- a/src/content/components/top-content/index.ts +++ b/src/content/components/top-content/index.ts @@ -5,15 +5,15 @@ import * as consoleFrames from '../../console-frames'; import * as messages from '../../../shared/messages'; import MessageListener from '../../MessageListener'; import * as scrolls from '../../scrolls'; +import AddonEnabledUseCase from '../../usecases/AddonEnabledUseCase'; + +let addonEnabledUseCase = new AddonEnabledUseCase(); export default class TopContent { private win: Window; - private store: any; - constructor(win: Window, store: any) { this.win = win; - this.store = store; new CommonComponent(win, store); // eslint-disable-line no-new new FollowController(win, store); // eslint-disable-line no-new @@ -36,14 +36,11 @@ export default class TopContent { } onBackgroundMessage(message: messages.Message) { - let addonState = this.store.getState().addon; + let addonEnabled = addonEnabledUseCase.getEnabled(); switch (message.type) { case messages.ADDON_ENABLED_QUERY: - return Promise.resolve({ - type: messages.ADDON_ENABLED_RESPONSE, - enabled: addonState.enabled, - }); + return Promise.resolve(addonEnabled); case messages.TAB_SCROLL_TO: return scrolls.scrollTo(message.x, message.y, false); } -- cgit v1.2.3