On my weekly call with mentors today, I showed them how my Space bar works and I recieved some suggestions.
One point of discussion was that clicking on a Space icon for first time resulted in noticeable delay before the UI was updated with filtered room list. The cause was traced to the latency introduced by /hierarchy
api call.
The solution we agreed on was to cache the list of child rooms of each space. So along with m_activeSpaceRooms
, I created a QMap
named m_spaceHierarchy
which uses id of a Space as key, and its value being a list of child rooms. This cache is persistent as long an NeoChat is running.
We also decided we could prefetch the child rooms for all Spaces on startup. While this could potentially create many api requests at once, it seemed unlikely that a user would be part of so many Spaces so as to spam the server with /hierarchy
calls. Still, as a future addition, I would like to try limiting /hierarchy
calls, and instead queue them.
The prefetch is done when SortFilterRoomListModel is initialised, which doesn't seem like the right time to do it - because by that time, Connection is not established, and the prefetch function fails to result in a segfault.
I have to take a look into this and come up with a workaround. Meanwhile, other features do work.