diff options
Diffstat (limited to 'plugins')
-rw-r--r-- | plugins/Matrix.hpp | 20 | ||||
-rw-r--r-- | plugins/utils/UniqueProcess.hpp | 7 |
2 files changed, 17 insertions, 10 deletions
diff --git a/plugins/Matrix.hpp b/plugins/Matrix.hpp index aae7411..c1ee3bd 100644 --- a/plugins/Matrix.hpp +++ b/plugins/Matrix.hpp @@ -326,6 +326,8 @@ namespace QuickMedia { virtual void remove_user(MatrixEventUserInfo user_info) = 0; virtual void set_user_info(MatrixEventUserInfo user_info) = 0; virtual void set_room_info(MatrixEventRoomInfo room_info) = 0; + + virtual void clear_data() = 0; }; class Matrix; @@ -360,6 +362,8 @@ namespace QuickMedia { void set_room_as_read(RoomData *room); + void clear_data() override; + Program *program; Matrix *matrix; MatrixChatPage *chat_page; @@ -397,6 +401,8 @@ namespace QuickMedia { void clear_search(); + void clear_data(); + MatrixQuickMedia *matrix_delegate = nullptr; Body *body = nullptr; private: @@ -422,6 +428,8 @@ namespace QuickMedia { void set_current_rooms_page(MatrixRoomsPage *rooms_page); + void clear_data(); + MatrixQuickMedia *matrix_delegate = nullptr; private: struct TagData { @@ -445,6 +453,8 @@ namespace QuickMedia { 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(); private: Matrix *matrix; Body *body; @@ -560,6 +570,7 @@ namespace QuickMedia { const std::string room_id; MatrixRoomsPage *rooms_page = nullptr; + bool should_clear_data = false; Body *chat_body = nullptr; bool messages_tab_visible = false; @@ -751,16 +762,16 @@ namespace QuickMedia { PluginResult set_qm_last_read_message_timestamp(RoomData *room, int64_t timestamp); void load_qm_read_markers_from_account_data(); - PluginResult parse_sync_response(const rapidjson::Document &root, bool initial_sync); + PluginResult parse_sync_response(const rapidjson::Document &root, bool is_additional_messages_sync, bool initial_sync); PluginResult parse_notifications(const rapidjson::Value ¬ifications_json, std::function<void(const MatrixNotification&)> callback_func); PluginResult parse_sync_account_data(const rapidjson::Value &account_data_json); - PluginResult parse_sync_room_data(const rapidjson::Value &rooms_json, bool initial_sync); + PluginResult parse_sync_room_data(const rapidjson::Value &rooms_json, bool is_additional_messages_sync, bool initial_sync); void parse_custom_emoji(const rapidjson::Value &custom_emoji_json); void load_custom_emoji_from_cache(); PluginResult get_previous_room_messages(RoomData *room_data, bool latest_messages, size_t &num_new_messages, bool *reached_end = nullptr); void events_add_user_info(const rapidjson::Value &events_json, RoomData *room_data, int64_t timestamp); std::shared_ptr<UserInfo> parse_user_info(const rapidjson::Value &json, const std::string &user_id, RoomData *room_data, int64_t timestamp); - void events_set_user_read_marker(const rapidjson::Value &events_json, RoomData *room_data, std::shared_ptr<UserInfo> &me); + void events_set_user_read_marker(const rapidjson::Value &events_json, RoomData *room_data, std::shared_ptr<UserInfo> &me, bool is_additional_messages_sync); // Returns the number of messages added size_t events_add_messages(const rapidjson::Value &events_json, RoomData *room_data, MessageDirection message_dir, bool has_unread_notifications); void events_set_room_info(const rapidjson::Value &events_json, RoomData *room_data, int64_t timestamp); @@ -782,6 +793,7 @@ namespace QuickMedia { std::string get_next_batch(); void set_next_notifications_token(std::string new_next_token); std::string get_next_notifications_token(); + void clear_sync_cache_for_new_sync(); std::shared_ptr<UserInfo> get_user_by_id(RoomData *room, const std::string &user_id, bool *is_new_user = nullptr, bool create_if_not_found = true); std::string get_filter_cached(); void load_silenced_invites(); @@ -810,7 +822,9 @@ namespace QuickMedia { std::mutex notifications_mutex; std::thread sync_thread; + std::thread sync_additional_messages_thread; std::thread notification_thread; + MessageQueue<bool> additional_messages_queue; bool sync_running = false; bool sync_failed = false; bool sync_is_cache = false; diff --git a/plugins/utils/UniqueProcess.hpp b/plugins/utils/UniqueProcess.hpp deleted file mode 100644 index f85704f..0000000 --- a/plugins/utils/UniqueProcess.hpp +++ /dev/null @@ -1,7 +0,0 @@ -#pragma once - -namespace QuickMedia { - bool is_quickmedia_instance_already_running(const char *sock_file_dir, const char *plugin_name); - bool set_quickmedia_instance_unique(const char *sock_file_dir, const char *plugin_name); - void remove_quickmedia_instance_lock(const char *sock_file_dir, const char *plugin_name); -}
\ No newline at end of file |