aboutsummaryrefslogtreecommitdiff
path: root/plugins
diff options
context:
space:
mode:
authordec05eba <dec05eba@protonmail.com>2021-08-19 16:40:42 +0200
committerdec05eba <dec05eba@protonmail.com>2021-08-19 17:13:17 +0200
commit4ff87535e7aae35bfbd66fe88402dcb513af249c (patch)
tree6427d23446d8f2aec80abc15d912010c26ae38fa /plugins
parentf4a02cabfd7452ed13b9c7b2e8b20ea5886768c8 (diff)
Matrix: add ctrl+r to navigate to replied to message and navigate to message from notifications tab
Diffstat (limited to 'plugins')
-rw-r--r--plugins/Matrix.hpp23
1 files changed, 14 insertions, 9 deletions
diff --git a/plugins/Matrix.hpp b/plugins/Matrix.hpp
index a27a4f6..0d29821 100644
--- a/plugins/Matrix.hpp
+++ b/plugins/Matrix.hpp
@@ -91,6 +91,8 @@ namespace QuickMedia {
// TODO: Store body item ref here
};
+ using Messages = std::vector<std::shared_ptr<Message>>;
+
struct RoomData {
std::shared_ptr<UserInfo> get_user_by_id(const std::string &user_id);
void add_user(std::shared_ptr<UserInfo> user);
@@ -106,9 +108,9 @@ namespace QuickMedia {
void set_user_avatar_url(std::shared_ptr<UserInfo> &user, std::string avatar_url);
// Ignores duplicates, returns the number of added messages
- size_t prepend_messages_reverse(const std::vector<std::shared_ptr<Message>> &new_messages);
+ size_t prepend_messages_reverse(const Messages &new_messages);
// Ignores duplicates, returns the number of added messages
- size_t append_messages(const std::vector<std::shared_ptr<Message>> &new_messages);
+ size_t append_messages(const Messages &new_messages);
std::shared_ptr<Message> get_message_by_id(const std::string &id);
@@ -118,7 +120,7 @@ namespace QuickMedia {
void acquire_room_lock();
void release_room_lock();
- const std::vector<std::shared_ptr<Message>>& get_messages_thread_unsafe() const;
+ const Messages& get_messages_thread_unsafe() const;
const std::vector<std::string>& get_pinned_events_thread_unsafe() const;
bool has_prev_batch();
@@ -177,7 +179,7 @@ namespace QuickMedia {
// Each room has its own list of user data, even if multiple rooms has the same user
// because users can have different display names and avatars in different rooms.
std::unordered_map<std::string, std::shared_ptr<UserInfo>> user_info_by_user_id;
- std::vector<std::shared_ptr<Message>> messages;
+ Messages messages;
std::unordered_map<std::string, std::shared_ptr<Message>> message_by_event_id;
std::vector<std::string> pinned_events;
std::set<std::string> tags;
@@ -204,8 +206,6 @@ namespace QuickMedia {
std::string content_uri;
};
- using Messages = std::vector<std::shared_ptr<Message>>;
-
struct SyncData {
Messages messages;
std::optional<std::vector<std::string>> pinned_events;
@@ -422,7 +422,7 @@ namespace QuickMedia {
class MatrixChatPage : public Page {
public:
- MatrixChatPage(Program *program, std::string room_id, MatrixRoomsPage *rooms_page);
+ MatrixChatPage(Program *program, std::string room_id, MatrixRoomsPage *rooms_page, std::string jump_to_event_id = "");
~MatrixChatPage();
const char* get_title() const override { return ""; }
@@ -443,6 +443,8 @@ namespace QuickMedia {
Body *chat_body = nullptr;
bool messages_tab_visible = false;
+
+ const std::string jump_to_event_id;
private:
RoomData *current_room = nullptr;
Body *users_body = nullptr;
@@ -522,7 +524,8 @@ namespace QuickMedia {
void get_all_synced_room_messages(RoomData *room, Messages &messages);
void get_all_pinned_events(RoomData *room, std::vector<std::string> &events);
- PluginResult get_previous_room_messages(RoomData *room, Messages &messages, bool latest_messages = false);
+ PluginResult get_messages_in_direction(RoomData *room, const std::string &token, MessageDirection message_dir, Messages &messages, std::string &new_token);
+ PluginResult get_previous_room_messages(RoomData *room, Messages &messages, bool latest_messages = false, bool *reached_end = nullptr);
PluginResult get_previous_notifications(std::function<void(const MatrixNotification&)> callback_func);
void get_cached_notifications(std::function<void(const MatrixNotification&)> callback_func);
@@ -577,6 +580,8 @@ namespace QuickMedia {
// Returns nullptr if message cant be found. Note: cached
std::shared_ptr<Message> get_message_by_id(RoomData *room, const std::string &event_id);
+ PluginResult get_message_context(RoomData *room, const std::string &event_id, std::shared_ptr<Message> &message, Messages &before_messages, Messages &after_messages, std::string &before_token, std::string &after_token);
+ void clear_previous_messages_token(RoomData *room);
RoomData* get_room_by_id(const std::string &id);
void update_room_users(RoomData *room);
@@ -600,7 +605,7 @@ namespace QuickMedia {
PluginResult parse_notifications(const rapidjson::Value &notifications_json, std::function<void(const MatrixNotification&)> callback_func);
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, bool is_additional_messages_sync, bool initial_sync);
- PluginResult get_previous_room_messages(RoomData *room_data, bool latest_messages, size_t &num_new_messages);
+ 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);
std::shared_ptr<UserInfo> parse_user_info(const rapidjson::Value &json, const std::string &user_id, RoomData *room_data);
void events_set_user_read_marker(const rapidjson::Value &events_json, RoomData *room_data, std::shared_ptr<UserInfo> &me);