From ffc5426e871e68f7f369bb0c883312195ea5e7fa Mon Sep 17 00:00:00 2001
From: tastytea <tastytea@tastytea.de>
Date: Wed, 20 Apr 2022 09:41:18 +0200
Subject: [PATCH] Show pack Id for image pack changes in timeline

Show either pack name, state key or (empty).
---
 src/timeline/TimelineModel.cpp | 17 +++++++++++++----
 1 file changed, 13 insertions(+), 4 deletions(-)

diff --git a/src/timeline/TimelineModel.cpp b/src/timeline/TimelineModel.cpp
index 9c12b967e..4309fb244 100644
--- a/src/timeline/TimelineModel.cpp
+++ b/src/timeline/TimelineModel.cpp
@@ -2250,18 +2250,27 @@ TimelineModel::formatImagePackEvent(const QString &id)
     auto added   = calcChange(newImages, oldImages);
     auto removed = calcChange(oldImages, newImages);
 
-    auto sender = utils::replaceEmoji(displayName(QString::fromStdString(event->sender)));
+    auto sender       = utils::replaceEmoji(displayName(QString::fromStdString(event->sender)));
+    const auto packId = [&event]() -> QString {
+        if (!event->content.pack->display_name.empty()) {
+            return event->content.pack->display_name.c_str();
+        } else if (!event->state_key.empty()) {
+            return event->state_key.c_str();
+        }
+        return tr("(empty)");
+    }();
 
     QString msg;
 
     if (!removed.isEmpty()) {
-        msg = tr("%1 removed the following images from the pack:<br>%2")
-                .arg(sender, removed.join(", "));
+        msg = tr("%1 removed the following images from the pack %2:<br>%3")
+                .arg(sender, packId, removed.join(", "));
     }
     if (!added.isEmpty()) {
         if (!msg.isEmpty())
             msg += "<br>";
-        msg += tr("%1 added the following images to the pack:<br>%2").arg(sender, added.join(", "));
+        msg += tr("%1 added the following images to the pack %2:<br>%3")
+                 .arg(sender, packId, added.join(", "));
     }
 
     if (msg.isEmpty())
-- 
GitLab