aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorShin'ya Ueoka <ueokande@i-beam.org>2017-10-08 18:41:44 +0900
committerShin'ya Ueoka <ueokande@i-beam.org>2017-10-08 19:09:25 +0900
commitb0d2b5328107a9a2018132938fb5a9efcd77fc50 (patch)
treef66bc49efc0d7ca3a6f5af3f7330f10941cbeadd /src
parentf6996a2274f3293d7c5860174dd224b28877e108 (diff)
use mode in console message
Diffstat (limited to 'src')
-rw-r--r--src/background/actions/index.js0
-rw-r--r--src/background/components/background.js2
-rw-r--r--src/console/actions/console.js7
-rw-r--r--src/console/actions/index.js2
-rw-r--r--src/console/components/console.js8
-rw-r--r--src/console/index.js4
-rw-r--r--src/console/reducers/index.js21
-rw-r--r--src/content/index.js2
-rw-r--r--src/shared/messages.js2
9 files changed, 21 insertions, 27 deletions
diff --git a/src/background/actions/index.js b/src/background/actions/index.js
deleted file mode 100644
index e69de29..0000000
--- a/src/background/actions/index.js
+++ /dev/null
diff --git a/src/background/components/background.js b/src/background/components/background.js
index bfe1b3f..0570a5a 100644
--- a/src/background/components/background.js
+++ b/src/background/components/background.js
@@ -48,7 +48,7 @@ export default class BackgroundComponent {
tabActions.openToTab(message.url, sender.tab), sender);
case messages.CONSOLE_BLURRED:
return browser.tabs.sendMessage(sender.tab.id, {
- type: messages.CONSOLE_HIDE,
+ type: messages.CONSOLE_HIDE_COMMAND,
});
case messages.CONSOLE_ENTERED:
return commands.exec(message.text, this.settings).catch((e) => {
diff --git a/src/console/actions/console.js b/src/console/actions/console.js
index 01d9a9b..aacc21a 100644
--- a/src/console/actions/console.js
+++ b/src/console/actions/console.js
@@ -14,9 +14,9 @@ const showError = (text) => {
};
};
-const hide = () => {
+const hideCommand = () => {
return {
- type: actions.CONSOLE_HIDE
+ type: actions.CONSOLE_HIDE_COMMAND,
};
};
@@ -40,5 +40,6 @@ const completionPrev = () => {
};
export {
- showCommand, showError, hide, setCompletions, completionNext, completionPrev
+ showCommand, showError, hideCommand,
+ setCompletions, completionNext, completionPrev
};
diff --git a/src/console/actions/index.js b/src/console/actions/index.js
index a5d03bc..3a6cf07 100644
--- a/src/console/actions/index.js
+++ b/src/console/actions/index.js
@@ -3,7 +3,7 @@ export default {
CONSOLE_SHOW_COMMAND: 'console.show.command',
CONSOLE_SET_COMPLETIONS: 'console.set.completions',
CONSOLE_SHOW_ERROR: 'console.show.error',
- CONSOLE_HIDE: 'console.hide',
+ CONSOLE_HIDE_COMMAND: 'console.hide.command',
CONSOLE_COMPLETION_NEXT: 'console.completion.next',
CONSOLE_COMPLETION_PREV: 'console.completion.prev',
};
diff --git a/src/console/components/console.js b/src/console/components/console.js
index 9023d91..b8431ce 100644
--- a/src/console/components/console.js
+++ b/src/console/components/console.js
@@ -72,14 +72,14 @@ export default class ConsoleComponent {
update() {
let state = this.store.getState();
- if (!this.prevState.commandShown && state.commandShown) {
+ if (this.prevState.mode !== 'command' && state.mode === 'command') {
this.showCommand(state.commandText);
- } else if (!state.commandShown) {
+ } else if (state.mode !== 'command') {
this.hideCommand();
}
- if (state.errorShown) {
- this.setErrorText(state.errorText);
+ if (state.mode === 'error') {
+ this.setErrorText(state.messageText);
this.showError();
} else {
this.hideError();
diff --git a/src/console/index.js b/src/console/index.js
index 7396a96..b07d8e7 100644
--- a/src/console/index.js
+++ b/src/console/index.js
@@ -28,7 +28,7 @@ browser.runtime.onMessage.addListener((action) => {
return store.dispatch(consoleActions.showCommand(action.command));
case messages.CONSOLE_SHOW_ERROR:
return store.dispatch(consoleActions.showError(action.text));
- case messages.CONSOLE_HIDE:
- return store.dispatch(consoleActions.hide(action.command));
+ case messages.CONSOLE_HIDE_COMMAND:
+ return store.dispatch(consoleActions.hideCommand());
}
});
diff --git a/src/console/reducers/index.js b/src/console/reducers/index.js
index ee9c691..78b73b0 100644
--- a/src/console/reducers/index.js
+++ b/src/console/reducers/index.js
@@ -1,9 +1,8 @@
import actions from 'console/actions';
const defaultState = {
- errorShown: false,
- errorText: '',
- commandShown: false,
+ mode: '',
+ messageText: '',
commandText: '',
completions: [],
groupSelection: -1,
@@ -48,25 +47,19 @@ export default function reducer(state = defaultState, action = {}) {
switch (action.type) {
case actions.CONSOLE_SHOW_COMMAND:
return Object.assign({}, state, {
- commandShown: true,
+ mode: 'command',
commandText: action.text,
errorShown: false,
completions: []
});
case actions.CONSOLE_SHOW_ERROR:
return Object.assign({}, state, {
- errorText: action.text,
- errorShown: true,
- commandShown: false,
+ mode: 'error',
+ messageText: action.text,
});
- case actions.CONSOLE_HIDE:
- if (state.errorShown) {
- // keep error message if shown
- return state;
- }
+ case actions.CONSOLE_HIDE_COMMAND:
return Object.assign({}, state, {
- errorShown: false,
- commandShown: false
+ mode: state.mode === 'command' ? '' : state.mode,
});
case actions.CONSOLE_SET_COMPLETIONS:
return Object.assign({}, state, {
diff --git a/src/content/index.js b/src/content/index.js
index adea871..63bbf77 100644
--- a/src/content/index.js
+++ b/src/content/index.js
@@ -40,7 +40,7 @@ const reloadSettings = () => {
browser.runtime.onMessage.addListener((action) => {
switch (action.type) {
- case messages.CONSOLE_HIDE:
+ case messages.CONSOLE_HIDE_COMMAND:
window.focus();
consoleFrames.blur(window.document);
return Promise.resolve();
diff --git a/src/shared/messages.js b/src/shared/messages.js
index 138f0e0..bba730e 100644
--- a/src/shared/messages.js
+++ b/src/shared/messages.js
@@ -8,7 +8,7 @@ export default {
CONSOLE_QUERY_COMPLETIONS: 'console.query.completions',
CONSOLE_SHOW_COMMAND: 'console.show.command',
CONSOLE_SHOW_ERROR: 'console.show.error',
- CONSOLE_HIDE: 'console.hide',
+ CONSOLE_HIDE_COMMAND: 'console.hide.command',
OPEN_URL: 'open.url',