aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/Body.hpp3
-rw-r--r--src/Body.cpp7
-rw-r--r--src/QuickMedia.cpp6
3 files changed, 13 insertions, 3 deletions
diff --git a/include/Body.hpp b/include/Body.hpp
index 43e2946..45121f8 100644
--- a/include/Body.hpp
+++ b/include/Body.hpp
@@ -118,6 +118,9 @@ namespace QuickMedia {
void *userdata; // Not managed, should be deallocated by whoever sets this
double last_drawn_time;
FetchStatus embedded_item_status = FetchStatus::NONE;
+ // Important! Should refer to a new BodyItem, not one that already exists in the body.
+ // TODO: Allow referring to an existing body item. This doesn't work properly at the moment because max width of text and line count calculation getting messed up
+ // if an embedded item wraps but not the original body item.
std::shared_ptr<BodyItem> embedded_item; // Used by matrix for example to display reply message body. Note: only the first level of embedded items is rendered (not recursive, this is done on purpose)
ThumbnailMaskType thumbnail_mask_type = ThumbnailMaskType::NONE;
sf::Vector2i thumbnail_size;
diff --git a/src/Body.cpp b/src/Body.cpp
index 5c2a66c..430c28f 100644
--- a/src/Body.cpp
+++ b/src/Body.cpp
@@ -67,7 +67,12 @@ namespace QuickMedia {
userdata = other.userdata;
last_drawn_time = other.last_drawn_time;
embedded_item_status = other.embedded_item_status;
- embedded_item = other.embedded_item;
+ if(other.embedded_item) {
+ embedded_item = std::make_shared<BodyItem>("");
+ *embedded_item = *other.embedded_item;
+ } else {
+ embedded_item = nullptr;
+ }
thumbnail_mask_type = other.thumbnail_mask_type;
thumbnail_size = other.thumbnail_size;
title = other.title;
diff --git a/src/QuickMedia.cpp b/src/QuickMedia.cpp
index f494d35..1bb7a04 100644
--- a/src/QuickMedia.cpp
+++ b/src/QuickMedia.cpp
@@ -3601,7 +3601,8 @@ namespace QuickMedia {
// TODO: Optimize from linear search to hash map
auto related_body_item = find_body_item_by_event_id(tabs[MESSAGES_TAB_INDEX].body->items.data(), tabs[MESSAGES_TAB_INDEX].body->items.size(), event_data->message->related_event_id);
if(related_body_item) {
- body_item->embedded_item = related_body_item;
+ body_item->embedded_item = std::make_shared<BodyItem>("");
+ *body_item->embedded_item = *related_body_item;
body_item->embedded_item_status = FetchStatus::FINISHED_LOADING;
return;
}
@@ -3673,7 +3674,8 @@ namespace QuickMedia {
// TODO: Optimize from linear search to hash map
auto related_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(related_body_item) {
- body_item->embedded_item = related_body_item;
+ body_item->embedded_item = std::make_shared<BodyItem>("");
+ *body_item->embedded_item = *related_body_item;
body_item->embedded_item_status = FetchStatus::FINISHED_LOADING;
return;
}