aboutsummaryrefslogtreecommitdiff
path: root/src/reducers
diff options
context:
space:
mode:
Diffstat (limited to 'src/reducers')
-rw-r--r--src/reducers/background.js8
-rw-r--r--src/reducers/command.js10
-rw-r--r--src/reducers/index.js6
3 files changed, 14 insertions, 10 deletions
diff --git a/src/reducers/background.js b/src/reducers/background.js
index 7a279c9..ba934fd 100644
--- a/src/reducers/background.js
+++ b/src/reducers/background.js
@@ -2,7 +2,7 @@ import * as tabs from '../background/tabs';
import * as consoleActions from '../actions/console';
import actions from '../actions';
-const doCompletion = (command, keywords, sender) => {
+const doCompletion = (command, keywords, tabId) => {
if (command === 'buffer') {
return tabs.getCompletions(keywords).then((tabs) => {
let items = tabs.map((tab) => {
@@ -18,18 +18,18 @@ const doCompletion = (command, keywords, sender) => {
items: items
};
return browser.tabs.sendMessage(
- sender,
+ tabId,
consoleActions.setCompletions([completions]));
});
}
return Promise.resolve();
};
-export default function reducer(state, action = {}, sender) {
+export default function reducer(state, action = {}, sendToTab) {
// TODO hide sender object
switch (action.type) {
case actions.BACKGROUND_REQUEST_COMPLETIONS:
- return doCompletion(action.command, action.keywords, sender.tab.id);
+ return doCompletion(action.command, action.keywords, sendToTab.id);
default:
return Promise.resolve();
}
diff --git a/src/reducers/command.js b/src/reducers/command.js
index 7e03593..b645e29 100644
--- a/src/reducers/command.js
+++ b/src/reducers/command.js
@@ -1,23 +1,23 @@
import * as tabs from '../background/tabs';
import actions from '../actions';
-const cmdBuffer = (sender, arg) => {
+const cmdBuffer = (tab, arg) => {
if (isNaN(arg)) {
- return tabs.selectByKeyword(sender.tab, arg);
+ return tabs.selectByKeyword(tab, arg);
} else {
let index = parseInt(arg, 10) - 1;
return tabs.selectAt(index);
}
}
-export default function reducer(state, action, sender) {
+export default function reducer(state, action, sendToTab) {
switch (action.type) {
case actions.COMMAND_OPEN_URL:
- return browser.tabs.update(sender.tab.id, { url: action.url });
+ return browser.tabs.update(sendToTab.id, { url: action.url });
case actions.COMMAND_TABOPEN_URL:
return browser.tabs.create({ url: action.url });
case actions.COMMAND_BUFFER:
- return cmdBuffer(sender, action.keywords);
+ return cmdBuffer(sendToTab, action.keywords);
default:
return Promise.resolve();
}
diff --git a/src/reducers/index.js b/src/reducers/index.js
index d49af7d..6cc1a31 100644
--- a/src/reducers/index.js
+++ b/src/reducers/index.js
@@ -1,7 +1,11 @@
+import inputReducer from '../reducers/input';
+
const defaultState = {
+ input: inputReducer(undefined, {})
};
-export default function reducer(state = defaultState/*, action = {}*/) {
+export default function reducer(state = defaultState, action = {}) {
return Object.assign({}, state, {
+ input: inputReducer(state.input, action)
});
}