Skip to content

Commit

Permalink
fix(webextension): fix to install
Browse files Browse the repository at this point in the history
  • Loading branch information
azu committed Apr 18, 2021
1 parent 6376a7f commit 61b92fe
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions packages/webextension/app/scripts/install-dialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ async function installHandler({
}

function App() {
const [install, setInstall] = useState<"no" | "yes" | "installing">("no");
const [install, setInstall] = useState<"Install" | "Installed" | "Waiting">("Waiting");
const [scriptURL, setScriptURL] = useState<string>("");
const [scriptContent, setScriptContent] = useState<string>("");
const [metadata, setMetadata] = useState<null | TextlintScriptMetadata>(null);
Expand All @@ -52,12 +52,13 @@ function App() {
scriptURL
}).catch((error) => {
console.error(error);
setInstall("no");
setInstall("Install");
});
setInstall("yes");
setInstall("Installed");
}, [scriptContent, metadata, scriptURL]);
useEffect(() => {
(async function main() {
setInstall("Install");
const url = new URL(location.href);
const script = url.searchParams.get("script");
if (!script) {
Expand All @@ -79,11 +80,12 @@ function App() {
<button
id="js-install-button"
className="install-button"
disabled={install == "no"}
disabled={install !== "Install"}
onClick={onInstall}
>
Install
{install}
</button>
{install === "Installed" ? "Success to install!" : null}
</div>
<div id="metadata" className="metadata">
<h3>Script metadata</h3>
Expand Down

0 comments on commit 61b92fe

Please sign in to comment.