Skip to content

Implement react persist

Antoine Estienne requested to merge implementReactPersist into master

Refactor Merge Request

Related Issue

resolves #387 (closed)

Description of Refactor

We used to listen to store changes and save them in localstorage, and then load them when loading the page, through a loading component.

  • Now we use react-persist instead

  • HistoryLoader disappears, as 'visits' are now part of the persisted data

  • Since persisted data needs to be network and user specific, it will be stored under the key: networkID+userAddress. Therefore, we need to get this information before instantiating the store, using a initialMetaMaskLoader component

Persisted data :

  • concepts
  • assessments
  • ethereum.lastUpdatedAt, ethereum.deployedConceptRegistryAt, ethereum.deployedFathomTokenAt
  • navigation.visits

(the whitelist needs to be declared on the relevant level of the store)

So the final architecture after the implementation of react persist:


h(initialMetaMaskLoader, [ 
 h( PersistStoreInstanciator, [
  h( Web3DataLoader,[ 
   h(MainView)
]]]

Where

  • initialMetaMaskLoader fetches networkID and userAddress and injects into children as props
  • PersistStoreInstanciator instanciates the store and loads the persisted state referenced by networkID+userAddress
  • Web3DataLoader is a loader component that calls a unique loading function that will load all the data before displaying the MainView

implement initialMetaMaskLoader and PersistStoreInstanciator and leave Web3DataLoader for another MR

This also means modal has to be rethought through without redux

What's Next?

https://gitlab.com/fathom/app/issues/398 https://gitlab.com/fathom/app/issues/399


Edited by Antoine Estienne

Merge request reports