aboutsummaryrefslogtreecommitdiff
path: root/src/QuickMedia.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/QuickMedia.cpp')
-rw-r--r--src/QuickMedia.cpp54
1 files changed, 20 insertions, 34 deletions
diff --git a/src/QuickMedia.cpp b/src/QuickMedia.cpp
index 3b687dd..cb570fc 100644
--- a/src/QuickMedia.cpp
+++ b/src/QuickMedia.cpp
@@ -3257,6 +3257,20 @@ namespace QuickMedia {
Message *message = nullptr;
};
+ static void user_update_display_info(BodyItem *body_item, RoomData *room, Message *message) {
+ body_item->set_author(room->get_user_display_name(message->user));
+
+ if(!is_visual_media_message_type(message->type)) {
+ body_item->thumbnail_url = room->get_user_avatar_url(message->user);
+ body_item->thumbnail_mask_type = ThumbnailMaskType::CIRCLE;
+ // if construct is not configured to use ImageMagic then it wont give thumbnails of size 32x32 even when requested and the spec says that the server SHOULD do that
+ body_item->thumbnail_size = AVATAR_THUMBNAIL_SIZE;
+ }
+
+ if(body_item->embedded_item_status == FetchStatus::FINISHED_LOADING && body_item->embedded_item && body_item->userdata)
+ user_update_display_info(body_item->embedded_item.get(), room, (Message*)body_item->embedded_item->userdata);
+ }
+
bool Program::chat_page(MatrixChatPage *matrix_chat_page, RoomData *current_room, std::vector<Tab> &room_tabs, int room_selected_tab, TabAssociatedData &room_tab_associated_data) {
assert(current_room);
assert(strcmp(plugin_name, "matrix") == 0);
@@ -3872,6 +3886,7 @@ namespace QuickMedia {
if(related_body_item) {
body_item->embedded_item = std::make_shared<BodyItem>("");
*body_item->embedded_item = *related_body_item;
+ body_item->embedded_item->embedded_item = nullptr;
body_item->embedded_item->reactions.clear();
if(related_body_item->userdata && static_cast<Message*>(related_body_item->userdata)->user == me)
body_item->set_description_color(sf::Color(255, 100, 100));
@@ -3977,6 +3992,7 @@ namespace QuickMedia {
if(related_body_item) {
body_item->embedded_item = std::make_shared<BodyItem>("");
*body_item->embedded_item = *related_body_item;
+ body_item->embedded_item->embedded_item = nullptr;
body_item->embedded_item->reactions.clear();
if((related_body_item->userdata && static_cast<Message*>(related_body_item->userdata)->user == me) || message_contains_user_mention(message->body, current_room->get_user_display_name(me)) || message_contains_user_mention(message->body, me->user_id))
body_item->set_description_color(sf::Color(255, 100, 100));
@@ -4211,42 +4227,24 @@ namespace QuickMedia {
auto update_pinned_messages_author = [&tabs, &current_room](const std::shared_ptr<UserInfo> &user) {
fprintf(stderr, "updated pinned messages author for user: %s\n", user->user_id.c_str());
- std::string user_display_name = current_room->get_user_display_name(user);
- std::string user_avatar_url = current_room->get_user_avatar_url(user);
-
for(auto &pinned_body_item : tabs[PINNED_TAB_INDEX].body->items) {
Message *message = static_cast<PinnedEventData*>(pinned_body_item->userdata)->message;
// Its fine if we dont set it now. When the message is fetches, it will have updated user info since its fetched later
if(!message || message->user != user)
continue;
- pinned_body_item->set_author(user_display_name);
- if(!is_visual_media_message_type(message->type)) {
- pinned_body_item->thumbnail_url = user_avatar_url;
- pinned_body_item->thumbnail_mask_type = ThumbnailMaskType::CIRCLE;
- // if construct is not configured to use ImageMagic then it wont give thumbnails of size 32x32 even when requested and the spec says that the server SHOULD do that
- pinned_body_item->thumbnail_size = AVATAR_THUMBNAIL_SIZE;
- }
+ user_update_display_info(pinned_body_item.get(), current_room, message);
}
};
auto update_messages_author = [&tabs, &current_room](const std::shared_ptr<UserInfo> &user) {
fprintf(stderr, "updated messages author for user: %s\n", user->user_id.c_str());
- std::string user_display_name = current_room->get_user_display_name(user);
- std::string user_avatar_url = current_room->get_user_avatar_url(user);
-
for(auto &message_body_items : tabs[MESSAGES_TAB_INDEX].body->items) {
Message *message = static_cast<Message*>(message_body_items->userdata);
if(!message || message->user != user)
continue;
- message_body_items->set_author(user_display_name);
- if(!is_visual_media_message_type(message->type)) {
- message_body_items->thumbnail_url = user_avatar_url;
- message_body_items->thumbnail_mask_type = ThumbnailMaskType::CIRCLE;
- // if construct is not configured to use ImageMagic then it wont give thumbnails of size 32x32 even when requested and the spec says that the server SHOULD do that
- message_body_items->thumbnail_size = AVATAR_THUMBNAIL_SIZE;
- }
+ user_update_display_info(message_body_items.get(), current_room, message);
}
};
@@ -4259,13 +4257,7 @@ namespace QuickMedia {
if(!message)
continue;
- pinned_body_item->set_author(current_room->get_user_display_name(message->user));
- if(!is_visual_media_message_type(message->type)) {
- pinned_body_item->thumbnail_url = current_room->get_user_avatar_url(message->user);
- pinned_body_item->thumbnail_mask_type = ThumbnailMaskType::CIRCLE;
- // if construct is not configured to use ImageMagic then it wont give thumbnails of size 32x32 even when requested and the spec says that the server SHOULD do that
- pinned_body_item->thumbnail_size = AVATAR_THUMBNAIL_SIZE;
- }
+ user_update_display_info(pinned_body_item.get(), current_room, message);
}
};
@@ -4277,13 +4269,7 @@ namespace QuickMedia {
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);
- message_body_items->thumbnail_mask_type = ThumbnailMaskType::CIRCLE;
- // if construct is not configured to use ImageMagic then it wont give thumbnails of size 32x32 even when requested and the spec says that the server SHOULD do that
- message_body_items->thumbnail_size = AVATAR_THUMBNAIL_SIZE;
- }
+ user_update_display_info(message_body_items.get(), current_room, message);
}
};