From 65ddd365e407989f3c1722a3ba811492b32e692f Mon Sep 17 00:00:00 2001
From: Shin'ya Ueoka <ueokande@i-beam.org>
Date: Wed, 24 Nov 2021 13:18:03 +0000
Subject: Use React.StrictMode

---
 src/console/App.tsx | 51 +++++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 51 insertions(+)
 create mode 100644 src/console/App.tsx

(limited to 'src/console/App.tsx')

diff --git a/src/console/App.tsx b/src/console/App.tsx
new file mode 100644
index 0000000..6b45418
--- /dev/null
+++ b/src/console/App.tsx
@@ -0,0 +1,51 @@
+import * as messages from "../shared/messages";
+import Console from "./components/Console";
+import React from "react";
+import {
+  useCommandMode,
+  useFindMode,
+  useInfoMessage,
+  useErrorMessage,
+  useHide,
+} from "./app/hooks";
+
+const App: React.FC = () => {
+  const hide = useHide();
+  const { show: showCommand } = useCommandMode();
+  const { show: showFind } = useFindMode();
+  const { show: showError } = useErrorMessage();
+  const { show: showInfo } = useInfoMessage();
+
+  React.useEffect(() => {
+    const onMessage = async (message: any): Promise<any> => {
+      const msg = messages.valueOf(message);
+      switch (msg.type) {
+        case messages.CONSOLE_SHOW_COMMAND:
+          showCommand(msg.command);
+          break;
+        case messages.CONSOLE_SHOW_FIND:
+          showFind();
+          break;
+        case messages.CONSOLE_SHOW_ERROR:
+          showError(msg.text);
+          break;
+        case messages.CONSOLE_SHOW_INFO:
+          showInfo(msg.text);
+          break;
+        case messages.CONSOLE_HIDE:
+          hide();
+          break;
+      }
+    };
+
+    browser.runtime.onMessage.addListener(onMessage);
+    const port = browser.runtime.connect(undefined, {
+      name: "vimvixen-console",
+    });
+    port.onMessage.addListener(onMessage);
+  }, []);
+
+  return <Console />;
+};
+
+export default App;
-- 
cgit v1.2.3

