Problem
Currently, the chat list rendering is wonky and done in several different ways:
The chat list is initialized by calling the corresponding lambda function.
When a file is uploaded, the chat list is updated on the client side by adding it to the chat list (or replacing it, if it already existed). However, the window is reloaded, so the lambda is called again.
When a chat is deleted, we reload the window so that the lambda is called and the chat list is initialized again.
There are too many lambda calls happening. Also, we should not rely on reloading the window to see changes.
In this ticket
Change the way that the chat list is rendered by reducing the number of lambda calls and window reloads.
Some ideas:
Update the chatList state variable directly when deleting or adding chats. This will mean we don't rely on lambda calls each time when either of these actions happen. It is important, then, that this solution does not require a window reload, otherwise it is still invoking the lambda.
Cache the chat list, and on window reloads retrieve it from the cache instead of invoking the lambda. Here it is important to always ensure that the cached chat list is up to date with what the database is holding.
Problem Currently, the chat list rendering is wonky and done in several different ways:
There are too many lambda calls happening. Also, we should not rely on reloading the window to see changes.
In this ticket Change the way that the chat list is rendered by reducing the number of lambda calls and window reloads.
Some ideas:
chatList
state variable directly when deleting or adding chats. This will mean we don't rely on lambda calls each time when either of these actions happen. It is important, then, that this solution does not require a window reload, otherwise it is still invoking the lambda.