From 651f8641774fe6f88593643a6c4678b0671fb159 Mon Sep 17 00:00:00 2001 From: Paul Miller Date: Thu, 11 May 2023 16:21:16 -0500 Subject: [PATCH 1/3] if already approved or self-hosting skip the waitlist asker --- .env | 1 + src/state/megaStore.tsx | 24 ++++++++++++++++-------- 2 files changed, 17 insertions(+), 8 deletions(-) diff --git a/.env b/.env index 90a0a87..e1671f1 100644 --- a/.env +++ b/.env @@ -11,3 +11,4 @@ VITE_PROXY="wss://p.mutinywallet.com" VITE_ESPLORA="https://mutinynet.com/api" VITE_LSP="https://signet-lsp.mutinywallet.com" VITE_RGS="https://rgs.mutinynet.com/snapshot/" +# VITE_SELFHOSTED="true" \ No newline at end of file diff --git a/src/state/megaStore.tsx b/src/state/megaStore.tsx index cd3c14f..d71884b 100644 --- a/src/state/megaStore.tsx +++ b/src/state/megaStore.tsx @@ -12,6 +12,7 @@ const MegaStoreContext = createContext(); type UserStatus = undefined | "new_here" | "waitlisted" | "approved" | "paid" export type MegaStore = [{ + already_approved?: boolean, waitlist_id?: string; mutiny_wallet?: MutinyWallet; deleting: boolean; @@ -36,6 +37,7 @@ export type MegaStore = [{ export const Provider: ParentComponent = (props) => { const [state, setState] = createStore({ + already_approved: import.meta.env.VITE_SELFHOSTED === "true" || localStorage.getItem("already_approved") === "true", waitlist_id: localStorage.getItem("waitlist_id"), mutiny_wallet: undefined as MutinyWallet | undefined, deleting: false, @@ -52,14 +54,22 @@ export const Provider: ParentComponent = (props) => { const actions = { async fetchUserStatus(): Promise { + if (state.already_approved) { + console.log("welcome back!") + return "approved" + } + if (!state.waitlist_id) { return "new_here" } + try { const res = await fetch(`https://waitlist.mutiny-waitlist.workers.dev/waitlist/${state.waitlist_id}`) const data = await res.json(); if (data.approval_date) { + // Remember them so we don't have to check every time + localStorage.setItem("already_approved", "true") return "approved" } else { return "waitlisted" @@ -123,15 +133,13 @@ export const Provider: ParentComponent = (props) => { onMount(() => { actions.fetchUserStatus().then(status => { setState({ user_status: status }) - }) - }) - // Only load node manager when status is approved - createEffect(() => { - if (state.user_status === "approved" && !state.mutiny_wallet && !state.deleting) { - console.log("running setup node manager...") - actions.setupMutinyWallet().then(() => console.log("node manager setup done")) - } + // Only load node manager when status is approved + if (state.user_status === "approved" && !state.mutiny_wallet && !state.deleting) { + console.log("running setup node manager...") + actions.setupMutinyWallet().then(() => console.log("node manager setup done")) + } + }) }) // Be reactive to changes in waitlist_id From 8985f37eb6900377e4d0606cf37700a9aa2b1157 Mon Sep 17 00:00:00 2001 From: Paul Miller Date: Thu, 11 May 2023 16:59:31 -0500 Subject: [PATCH 2/3] remove .env file --- .env | 14 -------------- 1 file changed, 14 deletions(-) delete mode 100644 .env diff --git a/.env b/.env deleted file mode 100644 index e1671f1..0000000 --- a/.env +++ /dev/null @@ -1,14 +0,0 @@ -# LOCALHOST REGTEST - -# VITE_NETWORK="regtest" -# VITE_PROXY="wss://p.mutinywallet.com" -# VITE_ESPLORA="http://localhost:3003" - -#SIGNET - -VITE_NETWORK="signet" -VITE_PROXY="wss://p.mutinywallet.com" -VITE_ESPLORA="https://mutinynet.com/api" -VITE_LSP="https://signet-lsp.mutinywallet.com" -VITE_RGS="https://rgs.mutinynet.com/snapshot/" -# VITE_SELFHOSTED="true" \ No newline at end of file From b833f771535429346a4ffb2fee8b403012c14d18 Mon Sep 17 00:00:00 2001 From: Paul Miller Date: Thu, 11 May 2023 17:10:15 -0500 Subject: [PATCH 3/3] add example env --- .env.example | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 .env.example diff --git a/.env.example b/.env.example new file mode 100644 index 0000000..1ea9911 --- /dev/null +++ b/.env.example @@ -0,0 +1,14 @@ +# LOCALHOST REGTEST + +# VITE_NETWORK="regtest" +# VITE_PROXY="wss://p.mutinywallet.com" +# VITE_ESPLORA="http://localhost:3003" + +#SIGNET + +VITE_NETWORK="signet" +VITE_PROXY="wss://p.mutinywallet.com" +VITE_ESPLORA="https://mutinynet.com/api" +VITE_LSP="https://signet-lsp.mutinywallet.com" +VITE_RGS="https://rgs.mutinynet.com/snapshot/" +VITE_SELFHOSTED="true" \ No newline at end of file