aboutsummaryrefslogtreecommitdiff
path: root/plugins/Matrix.hpp
diff options
context:
space:
mode:
authordec05eba <dec05eba@protonmail.com>2020-11-04 21:45:53 +0100
committerdec05eba <dec05eba@protonmail.com>2020-11-04 21:45:53 +0100
commit3dd837611eef939a1fd54621c523cff4ab48e136 (patch)
tree3a8911fa0ecf697d083ff4c91f66314b771b7a8f /plugins/Matrix.hpp
parent4e7b6ef98c5f31dbeed50050254e0cb70fe0d959 (diff)
Matrix: fetch additional messages in the background for all rooms, filter room list when updated after sync
Diffstat (limited to 'plugins/Matrix.hpp')
-rw-r--r--plugins/Matrix.hpp20
1 files changed, 15 insertions, 5 deletions
diff --git a/plugins/Matrix.hpp b/plugins/Matrix.hpp
index 78725a5..812c1a0 100644
--- a/plugins/Matrix.hpp
+++ b/plugins/Matrix.hpp
@@ -259,6 +259,7 @@ namespace QuickMedia {
const char* get_title() const override { return title.c_str(); }
PluginResult submit(const std::string &title, const std::string &url, std::vector<Tab> &result_tabs) override;
+ bool clear_search_after_submit() override { return true; }
void on_navigate_to_page(Body *body) override;
@@ -274,6 +275,7 @@ namespace QuickMedia {
void sort_rooms();
MatrixQuickMedia *matrix_delegate = nullptr;
+ bool filter_on_update = false;
private:
std::mutex mutex;
std::vector<std::shared_ptr<BodyItem>> room_body_items;
@@ -289,9 +291,10 @@ namespace QuickMedia {
class MatrixRoomTagsPage : public Page {
public:
- MatrixRoomTagsPage(Program *program, Body *body) : Page(program), body(body) {}
+ MatrixRoomTagsPage(Program *program, Body *body, SearchBar *search_bar) : Page(program), body(body), search_bar(search_bar) {}
const char* get_title() const override { return "Tags"; }
PluginResult submit(const std::string &title, const std::string &url, std::vector<Tab> &result_tabs) override;
+ bool clear_search_after_submit() override { return true; }
void update() override;
void add_room_body_item_to_tag(std::shared_ptr<BodyItem> body_item, const std::string &tag);
@@ -306,6 +309,7 @@ namespace QuickMedia {
void sort_rooms();
MatrixQuickMedia *matrix_delegate = nullptr;
+ bool filter_on_update = false;
private:
struct TagData {
std::shared_ptr<BodyItem> tag_item;
@@ -319,20 +323,23 @@ namespace QuickMedia {
std::map<std::string, std::vector<std::shared_ptr<BodyItem>>> remove_room_body_items_by_tags;
MatrixRoomsPage *current_rooms_page = nullptr;
bool clear_data_on_update = false;
+ SearchBar *search_bar = nullptr;
};
class MatrixInvitesPage : public Page {
public:
- MatrixInvitesPage(Program *program, Matrix *matrix, Body *body);
+ MatrixInvitesPage(Program *program, Matrix *matrix, Body *body, SearchBar *search_bar);
const char* get_title() const override { return title.c_str(); }
PluginResult submit(const std::string &title, const std::string &url, std::vector<Tab> &result_tabs) override;
+ bool clear_search_after_submit() override { return true; }
void update() override;
void add_body_item(std::shared_ptr<BodyItem> body_item);
void remove_body_item_by_room_id(const std::string &room_id);
void clear_data();
+ bool filter_on_update = false;
private:
Matrix *matrix;
std::mutex mutex;
@@ -342,6 +349,7 @@ namespace QuickMedia {
std::string title = "Invites (0)";
size_t prev_invite_count = 0;
bool clear_data_on_update = false;
+ SearchBar *search_bar = nullptr;
};
class MatrixInviteDetailsPage : public Page {
@@ -446,10 +454,10 @@ namespace QuickMedia {
bool use_tor = false;
private:
- PluginResult parse_sync_response(const rapidjson::Document &root);
+ PluginResult parse_sync_response(const rapidjson::Document &root, bool is_additional_messages_sync);
PluginResult parse_notifications(const rapidjson::Value &notifications_json);
PluginResult parse_sync_account_data(const rapidjson::Value &account_data_json, std::optional<std::set<std::string>> &dm_rooms);
- PluginResult parse_sync_room_data(const rapidjson::Value &rooms_json);
+ PluginResult parse_sync_room_data(const rapidjson::Value &rooms_json, bool is_additional_messages_sync);
PluginResult get_previous_room_messages(RoomData *room_data, bool latest_messages);
void events_add_user_info(const rapidjson::Value &events_json, RoomData *room_data);
std::shared_ptr<UserInfo> parse_user_info(const rapidjson::Value &json, const std::string &user_id, RoomData *room_data);
@@ -465,7 +473,8 @@ namespace QuickMedia {
PluginResult upload_file(RoomData *room, const std::string &filepath, UploadInfo &file_info, UploadInfo &thumbnail_info, std::string &err_msg);
void add_room(std::unique_ptr<RoomData> room);
void remove_room(const std::string &room_id);
- void set_invite(const std::string &room_id, Invite invite);
+ // Returns false if an invite to the room already exists
+ bool set_invite(const std::string &room_id, Invite invite);
// Returns true if an invite for |room_id| exists
bool remove_invite(const std::string &room_id);
void set_next_batch(std::string new_next_batch);
@@ -489,6 +498,7 @@ namespace QuickMedia {
std::mutex invite_mutex;
std::thread sync_thread;
+ std::thread sync_additional_messages_thread;
std::thread notification_thread;
bool sync_running = false;
bool sync_failed = false;