aboutsummaryrefslogtreecommitdiff
path: root/src/console/index.tsx
diff options
context:
space:
mode:
authorShin'ya Ueoka <ueokande@i-beam.org>2022-05-08 13:33:46 +0000
committerGitHub <noreply@github.com>2022-05-08 13:33:46 +0000
commit9279fff1351406a1f6c37c074cc1997e6a9e97e3 (patch)
treecc8e53f783efc5eb737af31bb9dd15c9e6474782 /src/console/index.tsx
parent4468afca7a8c9893f71f7e042b25f6c46ba49678 (diff)
parent2a6d6b0967c6f6e269c3eedf4bd6002aee26b9da (diff)
Merge pull request #1418 from ueokande/await-completions
Await fetching completions done completely
Diffstat (limited to 'src/console/index.tsx')
-rw-r--r--src/console/index.tsx70
1 files changed, 12 insertions, 58 deletions
diff --git a/src/console/index.tsx b/src/console/index.tsx
index 29fa11f..5b97917 100644
--- a/src/console/index.tsx
+++ b/src/console/index.tsx
@@ -1,66 +1,20 @@
-import * as messages from "../shared/messages";
-import Console from "./components/Console";
-import "./index.css";
import React from "react";
import ReactDOM from "react-dom";
import ColorSchemeProvider from "./colorscheme/providers";
import { AppProvider } from "./app/provider";
-import {
- useCommandMode,
- useFindMode,
- useInfoMessage,
- useErrorMessage,
- useHide,
-} from "./app/hooks";
-
-const RootComponent: 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 />;
-};
-
-const App: React.FC = () => (
- <AppProvider>
- <ColorSchemeProvider>
- <RootComponent />
- </ColorSchemeProvider>
- </AppProvider>
-);
+import App from "./App";
+import "./index.css";
window.addEventListener("DOMContentLoaded", () => {
const wrapper = document.getElementById("vimvixen-console");
- ReactDOM.render(<App />, wrapper);
+ ReactDOM.render(
+ <React.StrictMode>
+ <AppProvider>
+ <ColorSchemeProvider>
+ <App />
+ </ColorSchemeProvider>
+ </AppProvider>
+ </React.StrictMode>,
+ wrapper
+ );
});