aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authordec05eba <dec05eba@protonmail.com>2021-03-26 00:36:39 +0100
committerdec05eba <dec05eba@protonmail.com>2021-03-26 00:36:39 +0100
commitd96e65b2abf2a569a4be4c160fa30a504abdb2fc (patch)
tree5b1f71b034571cf5b695b0235342debc2ec55e60 /src
parent1aec2bb2708b1b9597e06a7e6324a7dadf73bb80 (diff)
Bye bye construct, we use /event to get event by id instead of /context
Diffstat (limited to 'src')
-rw-r--r--src/Body.cpp2
-rw-r--r--src/QuickMedia.cpp54
-rw-r--r--src/plugins/Matrix.cpp6
3 files changed, 24 insertions, 38 deletions
diff --git a/src/Body.cpp b/src/Body.cpp
index 10708f0..de924da 100644
--- a/src/Body.cpp
+++ b/src/Body.cpp
@@ -1100,7 +1100,7 @@ namespace QuickMedia {
item_pos.y += reaction_max_height + reaction_padding_y;
}
- if(item->timestamp_text) {
+ if(item_index == selected_item && item->timestamp_text) {
item->timestamp_text->setPosition(std::floor(item_pos.x + size.x - item->timestamp_text->getLocalBounds().width - padding_x), timestamp_text_y + 8.0f);
window.draw(*item->timestamp_text);
}
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);
}
};
diff --git a/src/plugins/Matrix.cpp b/src/plugins/Matrix.cpp
index 263a948..1460687 100644
--- a/src/plugins/Matrix.cpp
+++ b/src/plugins/Matrix.cpp
@@ -3012,7 +3012,7 @@ namespace QuickMedia {
auto fetched_message_it = room->fetched_messages_by_event_id.find(event_id);
if(fetched_message_it != room->fetched_messages_by_event_id.end())
return fetched_message_it->second;
-#if 1
+#if 0
rapidjson::Document request_data(rapidjson::kObjectType);
request_data.AddMember("lazy_load_members", true, request_data.GetAllocator());
@@ -3086,12 +3086,12 @@ namespace QuickMedia {
room->fetched_messages_by_event_id.insert(std::make_pair(event_id, nullptr));
return nullptr;
}
-#if 1
+#if 0
const rapidjson::Value &state_json = GetMember(json_root, "state");
events_add_user_info(state_json, room);
#endif
//events_set_room_name(state_json, room);
-#if 1
+#if 0
const rapidjson::Value &event_json = GetMember(json_root, "event");
std::shared_ptr<Message> new_message = parse_message_event(event_json, room);
#else