diff options
author | dec05eba <dec05eba@protonmail.com> | 2020-10-17 23:30:16 +0200 |
---|---|---|
committer | dec05eba <dec05eba@protonmail.com> | 2020-10-17 23:30:16 +0200 |
commit | 75e088746dbf3ab4cafd5ac16890b134d4b19d2a (patch) | |
tree | babd67fbcbeb1f51dc9965ef1153d7b8a8c9833b /src/plugins | |
parent | c903b63a470279525cfe87fbbcefce36986de387 (diff) |
Matrix: update room list when joining a room (in another client) without restarting, and set sync retry to 1 sec instead of 50ms
Diffstat (limited to 'src/plugins')
-rw-r--r-- | src/plugins/Matrix.cpp | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/src/plugins/Matrix.cpp b/src/plugins/Matrix.cpp index 5dfd1d1..5cf4611 100644 --- a/src/plugins/Matrix.cpp +++ b/src/plugins/Matrix.cpp @@ -136,12 +136,11 @@ namespace QuickMedia { return PluginResult::OK; } - PluginResult Matrix::get_joined_rooms(Rooms &rooms) { + void Matrix::get_room_join_updates(Rooms &new_rooms) { std::lock_guard<std::mutex> lock(room_data_mutex); - for(auto &it : room_data_by_id) { - rooms.push_back(it.second); - } - return PluginResult::OK; + new_rooms.insert(new_rooms.end(), rooms.begin() + room_list_read_index, rooms.end()); + size_t num_new_rooms = rooms.size() - room_list_read_index; + room_list_read_index += num_new_rooms; } PluginResult Matrix::get_all_synced_room_messages(std::shared_ptr<RoomData> room, Messages &messages) { @@ -1368,6 +1367,7 @@ namespace QuickMedia { return PluginResult::NET_ERR; // Make sure all fields are reset here! + rooms.clear(); room_data_by_id.clear(); user_id.clear(); username.clear(); @@ -1605,12 +1605,13 @@ namespace QuickMedia { auto room_it = room_data_by_id.find(id); if(room_it == room_data_by_id.end()) return nullptr; - return room_it->second; + return rooms[room_it->second]; } void Matrix::add_room(std::shared_ptr<RoomData> room) { std::lock_guard<std::mutex> lock(room_data_mutex); - room_data_by_id.insert(std::make_pair(room->id, room)); + room_data_by_id.insert(std::make_pair(room->id, rooms.size())); + rooms.push_back(room); } DownloadResult Matrix::download_json(rapidjson::Document &result, const std::string &url, std::vector<CommandArg> additional_args, bool use_browser_useragent, std::string *err_msg) const { |