There are a number of complications to work through in optimizing how we present Agora offers to the user.
Cashtab has already gone though some iterations here.
Currently, each OrderBook component is well optimized to load all the info it needs to render. The Agora screen loads an OrderBook component for every `active offer.
Still, this is more than 500 components. And we do not have any way of sorting or searching these components.
This diff gives us a start. We initialize a map as a ref (so that it does not rerender when it changes). This map is passed to each OrderBook, so that each OrderBook can update it when it loads its own information.
When the map is loaded, the Agora screen is able to use this information to sort OrderBooks. For now, we only enable a sort by number of offers.
Going forward, we will enable sorting by price and depth.
After that, we can add more calculations to each OrderBook component to enable sorting by trading volume.
We still have more optimization work to do here. For example we should not render all 500 components on the screen, it causes the screen to go slowly and even the switch to perform this sort is slow.
But this is an important incremental improvement.