aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--README.md2
-rw-r--r--TODO2
-rw-r--r--plugins/Matrix.hpp2
-rw-r--r--src/QuickMedia.cpp17
-rw-r--r--src/plugins/Matrix.cpp8
5 files changed, 19 insertions, 12 deletions
diff --git a/README.md b/README.md
index c5554f2..9319e6f 100644
--- a/README.md
+++ b/README.md
@@ -85,7 +85,7 @@ See project.conf \[dependencies].
`xdg-utils` which provides `xdg-open` needs to be installed when downloading torrents with `nyaa.si` plugin.\
`ffmpeg (and ffprobe which is included in ffmpeg)` needs to be installed to upload videos with thumbnails on matrix.
## License
-QuickMedia is free software licensed under GPL 3.0. `images/sprites-small.png` is licensed under CC BY 4.0. Source for that image is available at https://github.com/EmojiTwo/emojitwo/
+QuickMedia is free software licensed under GPL 3.0. See the `LICENSE` file for more information. `images/sprites-small.png` is licensed under CC BY 4.0 and is available at https://github.com/EmojiTwo/emojitwo/
# Screenshots
## Youtube search
![](https://www.dec05eba.com/images/youtube.jpg)
diff --git a/TODO b/TODO
index 9f95a34..d6bc31f 100644
--- a/TODO
+++ b/TODO
@@ -94,7 +94,7 @@ Read image exif into to apply image rotation. This is common in images taken on
Handle M_LIMIT_EXCEEDED in matrix
Maybe dont clear cache for body items when filtering.
Change scroll in body when previous items change size (such as when thumbnail has finished loading).
-Load the replied-to message in the pinned messages tab.
+Load and show replied-to message in the pinned messages tab.
Pressing enter on a pinned message should go to the message in the messages tab.
Cache pinned messages on disk (messages by event id), but take into consider edits? for example if one message is pinned in the room and then edited multiple times (such as room rules). In that case cache the pinned message to quickly display it and then fetch the latest version from the server and then replace the message with the latest version.
Display file list for nyaa.
diff --git a/plugins/Matrix.hpp b/plugins/Matrix.hpp
index 789b301..4514b4c 100644
--- a/plugins/Matrix.hpp
+++ b/plugins/Matrix.hpp
@@ -455,7 +455,7 @@ namespace QuickMedia {
PluginResult on_start_typing(RoomData *room);
PluginResult on_stop_typing(RoomData *room);
- PluginResult set_read_marker(RoomData *room, const Message *message);
+ PluginResult set_read_marker(RoomData *room, const std::string &event_id);
PluginResult join_room(const std::string &room_id);
PluginResult leave_room(const std::string &room_id);
diff --git a/src/QuickMedia.cpp b/src/QuickMedia.cpp
index 315fef0..d0eadb4 100644
--- a/src/QuickMedia.cpp
+++ b/src/QuickMedia.cpp
@@ -3199,7 +3199,7 @@ namespace QuickMedia {
auto find_body_item_by_event_id = [](std::shared_ptr<BodyItem> *body_items, size_t num_body_items, const std::string &event_id, size_t *index_result = nullptr) -> std::shared_ptr<BodyItem> {
for(size_t i = 0; i < num_body_items; ++i) {
auto &body_item = body_items[i];
- if(static_cast<Message*>(body_item->userdata)->event_id == event_id) {
+ if(body_item->userdata && static_cast<Message*>(body_item->userdata)->event_id == event_id) {
if(index_result)
*index_result = i;
return body_item;
@@ -3610,6 +3610,8 @@ namespace QuickMedia {
return;
Message *message = static_cast<Message*>(body_item->userdata);
+ if(!message)
+ return;
assert(message);
#if 0
@@ -3848,7 +3850,7 @@ namespace QuickMedia {
for(auto &message_body_items : tabs[MESSAGES_TAB_INDEX].body->items) {
Message *message = static_cast<Message*>(message_body_items->userdata);
- if(message->user != user)
+ if(!message || message->user != user)
continue;
message_body_items->set_author(user_display_name);
@@ -3885,6 +3887,9 @@ namespace QuickMedia {
fprintf(stderr, "updated messages author for all users in room: %s\n", current_room->id.c_str());
for(auto &message_body_items : tabs[MESSAGES_TAB_INDEX].body->items) {
Message *message = static_cast<Message*>(message_body_items->userdata);
+ if(!message)
+ continue;
+
message_body_items->set_author(current_room->get_user_display_name(message->user));
if(!is_visual_media_message_type(message->type)) {
message_body_items->thumbnail_url = current_room->get_user_avatar_url(message->user);
@@ -4326,6 +4331,7 @@ namespace QuickMedia {
} else if(provisional_message->body_item) {
provisional_message->body_item->set_description("Failed to send: " + provisional_message->body_item->get_description());
provisional_message->body_item->set_description_color(sf::Color::Red);
+ provisional_message->body_item->userdata = nullptr;
}
}
@@ -4543,9 +4549,10 @@ namespace QuickMedia {
// TODO: What if the message is no longer valid?
setting_read_marker = true;
RoomData *room = current_room;
- set_read_marker_future = [this, room, message]() mutable {
- if(matrix->set_read_marker(room, message) != PluginResult::OK) {
- fprintf(stderr, "Warning: failed to set read marker to %s\n", message->event_id.c_str());
+ std::string event_id = message->event_id;
+ set_read_marker_future = [this, room, event_id]() mutable {
+ if(matrix->set_read_marker(room, event_id) != PluginResult::OK) {
+ fprintf(stderr, "Warning: failed to set read marker to %s\n", event_id.c_str());
}
};
}
diff --git a/src/plugins/Matrix.cpp b/src/plugins/Matrix.cpp
index 9da6185..199cba5 100644
--- a/src/plugins/Matrix.cpp
+++ b/src/plugins/Matrix.cpp
@@ -3109,10 +3109,10 @@ namespace QuickMedia {
return download_result_to_plugin_result(download_result);
}
- PluginResult Matrix::set_read_marker(RoomData *room, const Message *message) {
+ PluginResult Matrix::set_read_marker(RoomData *room, const std::string &event_id) {
rapidjson::Document request_data(rapidjson::kObjectType);
- request_data.AddMember("m.fully_read", rapidjson::StringRef(message->event_id.c_str()), request_data.GetAllocator());
- request_data.AddMember("m.read", rapidjson::StringRef(message->event_id.c_str()), request_data.GetAllocator());
+ request_data.AddMember("m.fully_read", rapidjson::StringRef(event_id.c_str()), request_data.GetAllocator());
+ request_data.AddMember("m.read", rapidjson::StringRef(event_id.c_str()), request_data.GetAllocator());
request_data.AddMember("m.hidden", false, request_data.GetAllocator()); // What is this for? element sends it but its not part of the documentation. Is it for hiding read receipt from other users? in that case, TODO: make it configurable
rapidjson::StringBuffer buffer;
@@ -3132,7 +3132,7 @@ namespace QuickMedia {
auto me = get_me(room);
if(me)
- room->set_user_read_marker(me, message->event_id);
+ room->set_user_read_marker(me, event_id);
return PluginResult::OK;
}