-
-
Notifications
You must be signed in to change notification settings - Fork 16
Description
The 'Recent Transactions' card on the AddressPage does not auto-refresh at all currently. Conversely, an address's transactions table will auto-refresh even for unrelated events. Both of these are caused by the fact that there's currently no way to get a lastTransactionID
for an individual address. There needs to be a way to subscribe to an address's (and other data types) last transaction IDs.
The current idea I have in mind is a new hook, which uses useSelector under the hood. When mounted, it sends a message to the WebsocketService (maybe via the Context API?) to add a subscription for an address. When unmounted, it removes said subscription. A Redux store can contain a map of these subscriptions, and the useSelector hook can just fetch that refresh ID. The initial state doesn't matter; zero is fine, it will only increment when it changes, thus triggering a refresh.
To handle multiple subscriptions, it'd probably be best to give each subscription a UUID. Then, the useSelector hook can just subscribe to its own UUID, and the WebsocketService can remove that UUID when unmounted. This would allow two different components to subscribe to the same address at different times and unmount/unsubscribe at different times.