From adc6a5175c0d8b83e45b9e8d99109c1605ad29ac Mon Sep 17 00:00:00 2001 From: Shin'ya Ueoka Date: Sun, 10 Sep 2017 17:51:25 +0900 Subject: content commands as action/reducer --- src/content/index.js | 50 ++++---------------------------------------------- 1 file changed, 4 insertions(+), 46 deletions(-) (limited to 'src/content') diff --git a/src/content/index.js b/src/content/index.js index 4fba516..314dfea 100644 --- a/src/content/index.js +++ b/src/content/index.js @@ -1,54 +1,12 @@ import '../console/console-frame.scss'; -import * as scrolls from './scrolls'; -import * as histories from './histories'; -import * as actions from '../shared/actions'; import * as consoleFrames from '../console/frames'; -import actionTypes from '../actions'; -import Follow from './follow'; +import actions from '../actions'; +import contentReducer from '../reducers/content'; consoleFrames.initialize(window.document); browser.runtime.onMessage.addListener((action) => { - switch (action.type) { - case actions.CMD_OPEN: - return consoleFrames.showCommand(''); - case actions.CMD_TABS_OPEN: - if (action.alter) { - // alter url - return consoleFrames.showCommand('open ' + window.location.href); - } else { - return consoleFrames.showCommand('open '); - } - case actions.CMD_BUFFER: - return consoleFrames.showCommand('buffer '); - case actions.SCROLL_LINES: - scrolls.scrollLines(window, action.count); - break; - case actions.SCROLL_PAGES: - scrolls.scrollPages(window, action.count); - break; - case actions.SCROLL_TOP: - scrolls.scrollTop(window); - break; - case actions.SCROLL_BOTTOM: - scrolls.scrollBottom(window); - break; - case actions.SCROLL_LEFT: - scrolls.scrollLeft(window); - break; - case actions.SCROLL_RIGHT: - scrolls.scrollRight(window); - break; - case actions.FOLLOW_START: - new Follow(window.document, action.newTab); - break; - case actions.HISTORY_PREV: - histories.prev(window); - break; - case actions.HISTORY_NEXT: - histories.next(window); - break; - } + contentReducer(undefined, action); return Promise.resolve(); }); @@ -72,7 +30,7 @@ window.addEventListener("keypress", (e) => { browser.runtime.onMessage.addListener((action) => { switch (action.type) { - case actionTypes.CONSOLE_HIDE: + case actions.CONSOLE_HIDE: window.focus(); return consoleFrames.blur(window.document); case 'vimvixen.command.enter': -- cgit v1.2.3