-
Notifications
You must be signed in to change notification settings - Fork 4
feat(PE-8241): Persist settings in local storage #799
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 8 commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
5040c06
fix(hyperbeam): add hyperbeam url to dev settings
atticusofsparta aaa866e
fix(settings): update settings to persist in local storage
atticusofsparta c99e299
fix(useANT): update useANT to use aoNetwork
atticusofsparta 9bd1952
fix(sdk): use latest alpha
atticusofsparta 345a7ec
fix(merge): merge origin hyperbeam config
atticusofsparta 3e8cea3
fix(build): fix types
atticusofsparta d667f32
fix(hyperbeamUrl): add hb url to configs and persist setting
atticusofsparta b87c1c6
Merge remote-tracking branch 'origin/develop' into PE-8241-hyperbeam-…
atticusofsparta 95e4e93
fix(settings): update settings page with hyperbeam URL and fix other …
atticusofsparta a794cbb
Update src/hooks/useSyncSettings/useSyncSettings.tsx
atticusofsparta d713079
fix(settings): use consistent storage key
atticusofsparta ca26d18
fix(sync settings): remove unnecessary conditional
atticusofsparta 4966765
fix(placeholders): set example hyperbeam url as placeholder
atticusofsparta cb514dd
fix(storage key): use main storage key only for syncing settings
atticusofsparta 7aecf55
fix(comments): remove old comments
atticusofsparta File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -26,7 +26,14 @@ const Panel = Collapse.Panel; | |
|
|
||
| function NetworkSettings() { | ||
| const [ | ||
| { gateway, aoNetwork, arioProcessId, arioContract, turboNetwork }, | ||
| { | ||
| gateway, | ||
| aoNetwork, | ||
| arioProcessId, | ||
| arioContract, | ||
| turboNetwork, | ||
| hyperbeamUrl, | ||
| }, | ||
| dispatchGlobalState, | ||
| ] = useGlobalState(); | ||
| const [{ wallet }] = useWalletState(); | ||
|
|
@@ -57,6 +64,11 @@ function NetworkSettings() { | |
| const [validTurboPaymentUrl, setValidTurboPaymentUrl] = | ||
| useState<boolean>(true); | ||
|
|
||
| const [newHyperbeamUrl, setNewHyperbeamUrl] = useState<string>( | ||
| hyperbeamUrl || '', | ||
| ); | ||
| const [validHyperbeamUrl, setValidHyperbeamUrl] = useState<boolean>(true); | ||
|
|
||
| function reset() { | ||
| // gateway | ||
| setNewGateway(NETWORK_DEFAULTS.ARWEAVE.HOST); | ||
|
|
@@ -78,6 +90,13 @@ function NetworkSettings() { | |
| setNewTurboPaymentUrl(NETWORK_DEFAULTS.TURBO.PAYMENT_URL); | ||
| setValidTurboPaymentUrl(true); | ||
| updateTurboNetwork(NETWORK_DEFAULTS.TURBO); | ||
| // hyperbeam network | ||
| setNewHyperbeamUrl(NETWORK_DEFAULTS.AO.ARIO.HYPERBEAM_URL || ''); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: formatting seems off
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nope thats how prettier wants it. |
||
| setValidHyperbeamUrl(true); | ||
| dispatchGlobalState({ | ||
| type: 'setHyperbeamUrl', | ||
| payload: NETWORK_DEFAULTS.AO.ARIO.HYPERBEAM_URL || undefined, | ||
| }); | ||
| } | ||
|
|
||
| useEffect(() => { | ||
|
|
@@ -94,6 +113,11 @@ function NetworkSettings() { | |
| setValidSuAddress(true); | ||
| }, [aoNetwork.ARIO]); | ||
|
|
||
| useEffect(() => { | ||
| setNewHyperbeamUrl(hyperbeamUrl || ''); | ||
| setValidHyperbeamUrl(true); | ||
| }, [hyperbeamUrl]); | ||
|
|
||
| async function updateGateway(gate: string) { | ||
| try { | ||
| if (!isValidGateway(gate)) { | ||
|
|
@@ -567,6 +591,67 @@ function NetworkSettings() { | |
| </div> | ||
| } | ||
| /> | ||
| <span className="flex w-fit whitespace-nowrap items-center bg-primary-thin rounded-t-md px-4 py-1 border-x-2 border-t-2 border-primary text-md text-primary font-semibold mt-2 gap-4 justify-center"> | ||
| Hyperbeam URL:{' '} | ||
| <span className="text-white pl-2 flex"> | ||
| {hyperbeamUrl || ''} | ||
| </span> | ||
| {!hyperbeamUrl && ( | ||
| <span className="text-red-500 font-bold">DISABLED</span> | ||
| )} | ||
| </span> | ||
|
|
||
| <Input | ||
| className="bg-background justify-center items-center" | ||
| placeholder="Enter custom Hyperbeam URL" | ||
dtfiedler marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| value={newHyperbeamUrl} | ||
| onChange={(e) => { | ||
| setValidHyperbeamUrl(isValidURL(e.target.value.trim())); | ||
| setNewHyperbeamUrl(e.target.value.trim()); | ||
| }} | ||
| onClear={() => setNewHyperbeamUrl('')} | ||
| onPressEnter={(e) => | ||
| dispatchGlobalState({ | ||
| type: 'setHyperbeamUrl', | ||
| payload: e.currentTarget.value.trim(), | ||
| }) | ||
| } | ||
| variant="outlined" | ||
| status={validHyperbeamUrl ? '' : 'error'} | ||
| addonAfter={ | ||
| <div className="flex flex-row" style={{ gap: '5px' }}> | ||
| <button | ||
| disabled={!validHyperbeamUrl} | ||
| className="bg-primary text-black h-full flex w-fit p-1 rounded-sm text-xs" | ||
| onClick={() => | ||
| dispatchGlobalState({ | ||
| type: 'setHyperbeamUrl', | ||
| payload: newHyperbeamUrl.trim(), | ||
| }) | ||
| } | ||
| > | ||
| Set Hyperbeam URL | ||
| </button> | ||
| <button | ||
| className="bg-primary-thin text-white h-full flex w-fit p-1 rounded-sm text-xs" | ||
| onClick={() => { | ||
| setNewHyperbeamUrl( | ||
| NETWORK_DEFAULTS.AO.ARIO.HYPERBEAM_URL || '', | ||
| ); | ||
| setValidHyperbeamUrl(true); | ||
| dispatchGlobalState({ | ||
| type: 'setHyperbeamUrl', | ||
| payload: | ||
| NETWORK_DEFAULTS.AO.ARIO.HYPERBEAM_URL || undefined, | ||
| }); | ||
| }} | ||
| > | ||
| reset | ||
| </button> | ||
| </div> | ||
| } | ||
| /> | ||
|
|
||
| <div className="flex flex-row p-2 justify-end items-center"> | ||
| <button | ||
| className="p-2 text-white border-2 border-black hover:bg-primary hover:text-black bg-primary-thin rounded-md font-bold" | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@atticusofsparta - remove this file