aboutsummaryrefslogtreecommitdiff
path: root/src/console/actions
diff options
context:
space:
mode:
authorShin'ya Ueoka <ueokande@i-beam.org>2018-07-08 21:20:49 +0900
committerGitHub <noreply@github.com>2018-07-08 21:20:49 +0900
commit37840c2abb02948d36cdcfaab9063f3ea67fdb6b (patch)
tree2662c396dea1761f57ed508616d2c76389aba5f9 /src/console/actions
parent9f64b19bef06328999a5ed602ba89867402b9d5c (diff)
parent43beccfe0f323e2363fe97bdb6bc0d71558fda47 (diff)
Merge pull request #429 from ueokande/use-official-redux
Use official redux
Diffstat (limited to 'src/console/actions')
-rw-r--r--src/console/actions/console.js30
1 files changed, 27 insertions, 3 deletions
diff --git a/src/console/actions/console.js b/src/console/actions/console.js
index f80045f..3713a76 100644
--- a/src/console/actions/console.js
+++ b/src/console/actions/console.js
@@ -1,3 +1,4 @@
+import messages from 'shared/messages';
import actions from 'console/actions';
const hide = () => {
@@ -34,11 +35,30 @@ const showInfo = (text) => {
};
const hideCommand = () => {
+ window.top.postMessage(JSON.stringify({
+ type: messages.CONSOLE_UNFOCUS,
+ }), '*');
return {
type: actions.CONSOLE_HIDE_COMMAND,
};
};
+const enterCommand = async(text) => {
+ await browser.runtime.sendMessage({
+ type: messages.CONSOLE_ENTER_COMMAND,
+ text,
+ });
+ return hideCommand(text);
+};
+
+const enterFind = (text) => {
+ window.top.postMessage(JSON.stringify({
+ type: messages.CONSOLE_ENTER_FIND,
+ text,
+ }), '*');
+ return hideCommand();
+};
+
const setConsoleText = (consoleText) => {
return {
type: actions.CONSOLE_SET_CONSOLE_TEXT,
@@ -46,11 +66,15 @@ const setConsoleText = (consoleText) => {
};
};
-const setCompletions = (completionSource, completions) => {
+const getCompletions = async(text) => {
+ let completions = await browser.runtime.sendMessage({
+ type: messages.CONSOLE_QUERY_COMPLETIONS,
+ text,
+ });
return {
type: actions.CONSOLE_SET_COMPLETIONS,
- completionSource,
completions,
+ completionSource: text,
};
};
@@ -68,5 +92,5 @@ const completionPrev = () => {
export {
hide, showCommand, showFind, showError, showInfo, hideCommand, setConsoleText,
- setCompletions, completionNext, completionPrev
+ enterCommand, enterFind, getCompletions, completionNext, completionPrev
};