From 2fd0c8ca8637fa0fd57d8fb8fce888317fbac7ea Mon Sep 17 00:00:00 2001 From: Will Crichton Date: Wed, 11 Sep 2024 15:57:34 -0700 Subject: [PATCH] Fix new quest errors, fix Windows errors. Release v0.1.2 (#19) * Fix error when initializing quest. Improve time to show initial state * Improve cross-platform handling of github token * Show errors in filing issues/PRs * Release 0.1.2 --- README.md | 2 +- js/packages/repo-quest/package.json | 2 +- js/packages/repo-quest/src/index.tsx | 53 +++++++++++++++++++++++----- rs/Cargo.lock | 21 ++++++++++- rs/crates/repo-quest/Cargo.toml | 3 +- rs/crates/repo-quest/Tauri.toml | 4 +-- rs/crates/repo-quest/src/github.rs | 38 ++++++++++---------- rs/crates/repo-quest/src/lib.rs | 21 +++++++---- rs/crates/repo-quest/src/quest.rs | 38 ++++++++++++++------ 9 files changed, 132 insertions(+), 50 deletions(-) diff --git a/README.md b/README.md index 31386e3..bc741c2 100644 --- a/README.md +++ b/README.md @@ -28,7 +28,7 @@ We have prebuilt binaries for MacOS (x86-64 and ARM64), Linux (x86-64), and Wind #### Windows -1. Download the installer (either `.msi` or `.exe) for your platform (arm64 for ARM chips, x64 otherwise). +1. Download the installer (either `.msi` or `.exe`) for your platform (arm64 for ARM chips, x64 otherwise). 2. Run the installer. 3. Launch RepoQuest, e.g. by searching for "RepoQuest" in your applications list. diff --git a/js/packages/repo-quest/package.json b/js/packages/repo-quest/package.json index 6b4cbe9..5ade6a9 100644 --- a/js/packages/repo-quest/package.json +++ b/js/packages/repo-quest/package.json @@ -1,6 +1,6 @@ { "name": "repo-quest", - "version": "0.1.1", + "version": "0.1.2", "type": "module", "depot": { "platform": "browser", diff --git a/js/packages/repo-quest/src/index.tsx b/js/packages/repo-quest/src/index.tsx index 1d17661..502f351 100644 --- a/js/packages/repo-quest/src/index.tsx +++ b/js/packages/repo-quest/src/index.tsx @@ -9,6 +9,7 @@ import { events, type QuestConfig, type QuestState, + type Result, type Stage, type StageState, type StateDescriptor, @@ -88,6 +89,17 @@ let ErrorView: React.FC<{ message: string; action: string }> = ({ return null; }; +async function tryAwait( + promise: Promise>, + action: string, + setMessage: (message: ErrorMessage) => void +) { + let result = await promise; + if (result.status === "error") { + setMessage({ action, message: result.error }); + } +} + let GithubLoader = () => ( {token => @@ -114,7 +126,7 @@ let GithubLoader = () => ( ) : ( -
ERROR: {token.value}
+ ) }
@@ -129,7 +141,10 @@ let LoaderEntry = () => { {quest_res => quest_res.status === "ok" ? ( - + ) : ( ) @@ -163,7 +178,10 @@ let InitForm = () => { {quest_res => quest_res.status === "ok" ? ( - + ) : ( ) @@ -229,7 +247,10 @@ let NewQuest = () => { {quest_res => quest_res.status === "ok" ? ( - + ) : ( ) @@ -238,9 +259,12 @@ let NewQuest = () => { ); }; -let QuestView: React.FC<{ quest: QuestConfig }> = ({ quest }) => { +let QuestView: React.FC<{ + quest: QuestConfig; + initialState: StateDescriptor; +}> = ({ quest, initialState }) => { let loader = useContext(Loader.context)!; - let [state, setState] = useState(undefined); + let [state, setState] = useState(initialState); let setTitle = useContext(TitleContext)!; useEffect(() => setTitle(quest.title), [quest.title]); @@ -331,6 +355,7 @@ let StageView: React.FC<{ state: QuestState; }> = ({ index, stage, state }) => { let loader = useContext(Loader.context)!; + let setMessage = useContext(ErrorContext)!; return (
  • @@ -342,7 +367,13 @@ let StageView: React.FC<{