aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordec05eba <dec05eba@protonmail.com>2021-05-05 16:04:29 +0200
committerdec05eba <dec05eba@protonmail.com>2021-05-05 16:04:29 +0200
commit12b352c31c0821ba8bd667a4ed17e1d5406fcdf6 (patch)
treeb54d3163d739756f32872338264a1acae6cb41e3
parent6f3564aea7f9833029d7301706db9019f71e73b4 (diff)
Fix red color when reply to us is edited
-rw-r--r--TODO4
-rw-r--r--plugins/Matrix.hpp1
-rw-r--r--src/QuickMedia.cpp32
3 files changed, 26 insertions, 11 deletions
diff --git a/TODO b/TODO
index d2ac4bd..fd7895c 100644
--- a/TODO
+++ b/TODO
@@ -41,7 +41,6 @@ Cleanup keybindings. Some require ctrl, some dont.
Set the icon of the window to be the icon of the plugin. Nice for KDE, GNOME, etc with titlebars.
If --no-audio is used then music should be played with a lightweight music player instead. MPV is heavy even for music (60mb RAM). Maybe use sfml audio functions?
Update 4chan thread in real time, just like 4chan-x.
-Save the original event message, so when replying for example we can use the original message as the replying to message, rather than our converted "body" text.
Remove tidy dependency and use my own html-parser.
Add option to sort by other than timestamp for nyaa.si.
Add url preview for matrix (using matrix api, fallback to client url preview (using our own url preview project) if disabled by the homeserver).
@@ -61,7 +60,6 @@ Modify sfml to use GL_COMPRESSED_LUMINANCE and other texture compression modes (
Decrease memory usage even further (mostly in matrix /sync when part of large rooms) by using rapidjson SAX style API to stream json string into SAX style parsing.
Sometimes we fail to get images in mangadex, most common reason being that the manga is licensed and we can't view the manga on mangadex. QuickMedia should implement mangaplus and redirect us to mangaplus plugin to view the manga, or simply show that we cant view the manga because its licensed.
Show redacted messages even when part of the initial sync in matrix. Right now they are hidden while new sync redacted messages are not.
-Fix inconsistent behavior when editing a message that is replied to in matrix. Right now if the replied to message already exits in the body then its used directly and when editing that message the reply message shows the edit embedded, but not if the edit is of an body item that is created because we dont already have it,
to fix this we could perhaps replace the newly created body items for replies when loading old messages and one of the old messages is also one of the embedded messages (by event id).
Add button to skip to next video. MPV has this feature when setting "next" video (can be done over IPC).
Use a custom allocator that replaces malloc/realloc/free/new/delete to release memory properly, using munmap in free/delete. The C allocator doesn't do that! memory usage remains high after one large allocation. The C allocator only marks it as free.
@@ -112,7 +110,6 @@ When fetching previous messages in matrix, fetching until there are 0 messages o
QuickMedia crashes if you enter a room that you have left before. This could happen if cache is loaded that has a room that is then getting removed when sync is finished.
Limit size of Entry and scroll content instead.
Instead of doing a GET for the first N bytes to check if a video is streamable, start streaming the video and if the first bytes doesn't contain MOOV then wait until the whole video has downloaded before playing it.
-If a message reply is edited and its a reply to us, then we want the text to be red even if its edited.
Implement matrix spoiler, see: https://github.com/matrix-org/matrix-doc/blob/master/proposals/2010-spoilers.md.
Replace sfml font glyph loading completely with FreeType. There is a very old bug in sfml that causes text to get corrupt sometimes. Im guessing this happens when adding new characters to the font atlas and that coordinates for the glyphs become incorrect?
Add arguments to pipe plugin to pass input and output fifo for sending commands to QuickMedia and receiving events.
@@ -120,7 +117,6 @@ Create a workaround for dwm terminal swallow patch stealing mpv when moving Quic
Add option to decline and mute user in invites. This is to combat invite spam, where muted users cant invite you.
Allow hiding videos so they dont show up in recommendations and related videos.
Add an option to select video resolution, if we want to use less power and less bandwidth for example.
-Replies to the local user shouldn't remove the red text. Maybe fix this by checking if the reply to message user is the local user or when the replied to message has loaded then make the reply red if its a reply to us. Also for existing messages check if the message is a notification message and then make the message red.
Check what happens with xsrf_token if comments are not fetched for a long time. Does it time out? if so do we need to refetch the video page to get the new token?.
Add support for comments in live youtube videos, api is at: https://www.youtube.com/youtubei/v1/live_chat/get_live_chat?key=AIzaSyAO_FJ2SlqU8Q4STEHLGCilw_Y9_11qcW8.
Make video visible when reading comments (youtube).
diff --git a/plugins/Matrix.hpp b/plugins/Matrix.hpp
index 9bfee65..25b2633 100644
--- a/plugins/Matrix.hpp
+++ b/plugins/Matrix.hpp
@@ -82,6 +82,7 @@ namespace QuickMedia {
std::string transaction_id;
time_t timestamp = 0; // In milliseconds
MessageType type;
+ Message *replaces = nullptr;
std::shared_ptr<Message> replaced_by = nullptr;
// TODO: Store body item ref here
};
diff --git a/src/QuickMedia.cpp b/src/QuickMedia.cpp
index 4489194..f94601c 100644
--- a/src/QuickMedia.cpp
+++ b/src/QuickMedia.cpp
@@ -3811,6 +3811,19 @@ namespace QuickMedia {
user_update_display_info(body_item->embedded_item.get(), room, (Message*)body_item->embedded_item->userdata);
}
+ static Message* get_original_message(Message *message) {
+ if(!message)
+ return nullptr;
+
+ Message *replaces = message->replaces;
+ while(replaces) {
+ if(!replaces->replaces)
+ return replaces;
+ replaces = replaces->replaces;
+ }
+ return nullptr;
+ }
+
bool Program::chat_page(MatrixChatPage *matrix_chat_page, RoomData *current_room, std::vector<Tab> &room_tabs, int room_selected_tab) {
assert(current_room);
assert(strcmp(plugin_name, "matrix") == 0);
@@ -3973,13 +3986,15 @@ namespace QuickMedia {
if(message->related_event_type == RelatedEventType::REDACTION) {
set_body_as_deleted(message.get(), body_item.get());
} else {
- Message *orig_message = static_cast<Message*>(body_item->userdata);
+ Message *reply_to_message = static_cast<Message*>(body_item->userdata);
+ Message *orig_message = get_original_message(reply_to_message);
body_item->set_description(strip(message_get_body_remove_formatting(message.get())));
if(message->user != me && (message_contains_user_mention(body_item->get_description(), my_display_name) || message_contains_user_mention(body_item->get_description(), me->user_id) || (orig_message && orig_message->user == me)))
body_item->set_description_color(sf::Color(255, 100, 100));
else
body_item->set_description_color(sf::Color::White);
- orig_message->replaced_by = message;
+ message->replaces = reply_to_message;
+ reply_to_message->replaced_by = message;
}
it = unreferenced_events.erase(it);
} else {
@@ -4009,13 +4024,15 @@ namespace QuickMedia {
if(message->related_event_type == RelatedEventType::REDACTION) {
set_body_as_deleted(message.get(), body_item.get());
} else {
- Message *orig_message = static_cast<Message*>(body_item->userdata);
+ Message *reply_to_message = static_cast<Message*>(body_item->userdata);
+ Message *orig_message = get_original_message(reply_to_message);
body_item->set_description(strip(message_get_body_remove_formatting(message.get())));
if(message->user != me && (message_contains_user_mention(body_item->get_description(), my_display_name) || message_contains_user_mention(body_item->get_description(), me->user_id) || (orig_message && orig_message->user == me)))
body_item->set_description_color(sf::Color(255, 100, 100));
else
body_item->set_description_color(sf::Color::White);
- orig_message->replaced_by = message;
+ message->replaces = reply_to_message;
+ reply_to_message->replaced_by = message;
}
} else {
unreferenced_events.push_back(message);
@@ -4190,12 +4207,13 @@ namespace QuickMedia {
if(message->related_event_type == RelatedEventType::EDIT) {
auto body_item = find_body_item_by_event_id(tabs[MESSAGES_TAB_INDEX].body->items.data(), tabs[MESSAGES_TAB_INDEX].body->items.size(), message->related_event_id);
if(body_item) {
- Message *orig_message = static_cast<Message*>(body_item->userdata);
- if(!orig_message) {
+ Message *reply_to_message = static_cast<Message*>(body_item->userdata);
+ if(!reply_to_message) {
show_notification("QuickMedia", "Unexpected error, failed to set replaced by message", Urgency::CRITICAL);
return;
}
- orig_message->replaced_by = message;
+ message->replaces = reply_to_message;
+ reply_to_message->replaced_by = message;
}
} else if(message->related_event_type == RelatedEventType::REPLY) {
auto pending_sent_reply_it = pending_sent_replies.find(message->transaction_id);