elsirion / webimint-rs

Experimental integration of `fedimint-client` with the Leptos web frontend framework
https://webimint.sirion.io/
MIT License
20 stars 10 forks source link

Save Successfully-connected Federations to Local Storage #32

Closed IroncladDev closed 10 months ago

IroncladDev commented 1 year ago

Why

It's difficult to have to paste in a fedimint invite code every time the page reloads. Additionally, if you enter an invalid federation there's just a blank screen and no error indications.

Changes

  1. Added a "Try Again" screen (src/components/failure.rs) if the federation client fails to join the specified invite code. Pressing the "Try again" button refreshes the page. Screenshot 2023-09-19 at 12 44 32 PM
  2. Save successfully-connected federations to Local Storage. Both the federation invite code (src/components/app.rs:27) and the federation name/label (src/components/joined.rs:46) are saved to local storage to be accessed later. If the localstorage values exist, a clickable component will be shown on the initial connection screen. Clicking it auto-fills the input. Screenshot 2023-09-19 at 12 48 42 PM

Other Changes

Test Plan

  1. Ensure fedimint-cli is running
  2. Get an invite code in fedimint-cli by running cat target/devimint/cfg/invite-code in the fedimint shell
  3. Run webimint-rs with trunk serve
  4. Join the federation via invite code
  5. Refresh the page
  6. You will see the "Join an existing federation" component
  7. Clicking the saved federation should autofill the form
  8. Refresh the page
  9. Enter an invalid invite code (any string)
  10. The "Try again" screen will appear
  11. Clicking the "Try again" button will refresh the page
elsirion commented 1 year ago

I'll look into it more thoroughly later, could you clean up the git history a bit please (see https://git-scm.com/book/en/v2/Git-Tools-Rewriting-History for help)?

It's funny that not having persistent storage for the client leads to the idea to at least save the join codes :laughing: you still lose all your e-cash, but at least you can join the same federation again. Don't get me wrong, this is certainly useful for testing, just very funny imo :rofl:

IroncladDev commented 1 year ago

Whoops, sorry, I think I nuked the entire branch.

I can move all my changes to a new branch and start again if you want.

As a followup PR, I'll make transactions persistent in localstorage.

elsirion commented 1 year ago

As a followup PR, I'll make transactions persistent in localstorage.

What would be your strategy for that? Implementing a proper transactional KV store on top of it seems non-trivial. A workaround that is broken but works most of the time would be saving the in-memory DB to local storage periodically (ideally on every commit with writes).

elsirion commented 10 months ago

I think this got closed by #33