summary refs log tree commit diff
diff options
context:
space:
mode:
authorNicolas Werner <nicolas.werner@hotmail.de>2022-03-22 19:45:25 +0100
committerNicolas Werner <nicolas.werner@hotmail.de>2022-03-22 19:45:25 +0100
commit637db55e08c98c4f408efda0f739ed1f377eb7b3 (patch)
treeb62184c9e4f57fdc0abf4de00b4070bc786d573a
parentAdd a default filename for clipboard pastes again (diff)
downloadnheko-637db55e08c98c4f408efda0f739ed1f377eb7b3.tar.xz
Default body to shortcode if unset and sending sticker
-rw-r--r--src/CombinedImagePackModel.h6
-rw-r--r--src/timeline/InputBar.cpp2
2 files changed, 7 insertions, 1 deletions
diff --git a/src/CombinedImagePackModel.h b/src/CombinedImagePackModel.h
index 78598469..b0560ee3 100644
--- a/src/CombinedImagePackModel.h
+++ b/src/CombinedImagePackModel.h
@@ -33,6 +33,12 @@ public:
             return {};
         return images.at(static_cast<size_t>(row)).image;
     }
+    QString shortcodeAt(int row)
+    {
+        if (row < 0 || static_cast<size_t>(row) >= images.size())
+            return {};
+        return images.at(static_cast<size_t>(row)).shortcode;
+    }
 
 private:
     std::string room_id;
diff --git a/src/timeline/InputBar.cpp b/src/timeline/InputBar.cpp
index 7a7d22b7..a82796a8 100644
--- a/src/timeline/InputBar.cpp
+++ b/src/timeline/InputBar.cpp
@@ -636,7 +636,7 @@ InputBar::sticker(CombinedImagePackModel *model, int row)
     mtx::events::msg::StickerImage sticker{};
     sticker.info = img.info.value_or(mtx::common::ImageInfo{});
     sticker.url  = img.url;
-    sticker.body = img.body;
+    sticker.body = img.body.empty() ? model->shortcodeAt(row).toStdString() : img.body;
 
     // workaround for https://github.com/vector-im/element-ios/issues/2353
     sticker.info.thumbnail_url           = sticker.url;