While testing my merge request, Tobias spotted that NeoChat was making multiple requests to the /hierarchy
API endpoint. The requests were actually being spammed to the server.
So I was suggested to separate the Space hierarchy caching functionality to a separate class itself.
The work was mostly about refactoring. Code was already existing in a different class. I moved it to the new SpaceHierarchyCache
class and edited it to glue in properly.
getRoomListForSpace()
in SpaceHierarchyCache
accepts a space id, and returns a list of rooms id that belong to the space. This function is exposed in QML and used to populate SortFilterRoomListModel:: m_activeSpaceRooms
whenever user clicks a Space icon.
Rest of the implementation is mostly similar to what was earlier scattered through SortFilterRoomListModel
.
The code is currently on a separate branch on my fork so that my mentors can check if it looks and works right. If they say its fine, I'll add the code to my open merge request.
PS. Its my birthday today :)