From a98911daeb80ab8028dfd425d07d19471e936448 Mon Sep 17 00:00:00 2001 From: dec05eba Date: Sun, 13 Nov 2022 22:25:03 +0100 Subject: Matrix: allow pinning a message if no message has ever been pinned before in the room, fix get_previous_message spam when reaching top sometimes, fit card view cutting off bottom text (description) --- src/plugins/Matrix.cpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'src/plugins') diff --git a/src/plugins/Matrix.cpp b/src/plugins/Matrix.cpp index 6e6264f..75e293a 100644 --- a/src/plugins/Matrix.cpp +++ b/src/plugins/Matrix.cpp @@ -3719,7 +3719,7 @@ namespace QuickMedia { const rapidjson::Value &end_json = GetMember(json_root, "end"); if(!end_json.IsString()) { - room_data->set_prev_batch("invalid"); + room_data->set_prev_batch(""); fprintf(stderr, "Warning: matrix messages response is missing 'end', this could happen if we received the very first messages in the room\n"); if(reached_end) *reached_end = true; @@ -4970,7 +4970,12 @@ namespace QuickMedia { } const rapidjson::Value &errcode_json = GetMember(json_root, "errcode"); - if(errcode_json.IsString() && strcmp(errcode_json.GetString(), "M_NOT_FOUND") != 0) { + if(errcode_json.IsString()) { + // This is the case if the room has never set pinned events. + // After a pinned event has added and then removed so the list is empty then an empty list is returned instead. + if(strcmp(errcode_json.GetString(), "M_NOT_FOUND") == 0) + return PluginResult::OK; + const rapidjson::Value &error_json = GetMember(json_root, "error"); if(error_json.IsString()) { show_notification("QuickMedia", "Failed to get pinned events for room " + room->id + ", error: " + std::string(error_json.GetString(), error_json.GetStringLength()), Urgency::CRITICAL); -- cgit v1.2.3