diff options
Diffstat (limited to 'src/timeline')
-rw-r--r-- | src/timeline/InputBar.cpp | 42 | ||||
-rw-r--r-- | src/timeline/InputBar.h | 2 | ||||
-rw-r--r-- | src/timeline/TimelineViewManager.cpp | 4 |
3 files changed, 32 insertions, 16 deletions
diff --git a/src/timeline/InputBar.cpp b/src/timeline/InputBar.cpp index dd6813c2..0c2e3752 100644 --- a/src/timeline/InputBar.cpp +++ b/src/timeline/InputBar.cpp @@ -836,28 +836,40 @@ InputBar::getCommandAndArgs(const QString ¤tText) const } void -InputBar::sticker(CombinedImagePackModel *model, int row) +InputBar::sticker(QStringList descriptor) { - if (!model || row < 0) + if (descriptor.size() != 3) return; - auto img = model->imageAt(row); + auto originalPacks = cache::client()->getImagePacks(room->roomId().toStdString(), true); - mtx::events::msg::StickerImage sticker{}; - sticker.info = img.info.value_or(mtx::common::ImageInfo{}); - sticker.url = img.url; - sticker.body = img.body.empty() ? model->shortcodeAt(row).toStdString() : img.body; + auto source_room = descriptor[0].toStdString(); + auto state_key = descriptor[1].toStdString(); + auto short_code = descriptor[2].toStdString(); - // workaround for https://github.com/vector-im/element-ios/issues/2353 - sticker.info.thumbnail_url = sticker.url; - sticker.info.thumbnail_info.mimetype = sticker.info.mimetype; - sticker.info.thumbnail_info.size = sticker.info.size; - sticker.info.thumbnail_info.h = sticker.info.h; - sticker.info.thumbnail_info.w = sticker.info.w; + for (auto &pack : originalPacks) { + if (pack.source_room == source_room && pack.state_key == state_key && + pack.pack.images.contains(short_code)) { + auto img = pack.pack.images.at(short_code); - sticker.relations = generateRelations(); + mtx::events::msg::StickerImage sticker{}; + sticker.info = img.info.value_or(mtx::common::ImageInfo{}); + sticker.url = img.url; + sticker.body = img.body.empty() ? short_code : img.body; - room->sendMessageEvent(sticker, mtx::events::EventType::Sticker); + // workaround for https://github.com/vector-im/element-ios/issues/2353 + sticker.info.thumbnail_url = sticker.url; + sticker.info.thumbnail_info.mimetype = sticker.info.mimetype; + sticker.info.thumbnail_info.size = sticker.info.size; + sticker.info.thumbnail_info.h = sticker.info.h; + sticker.info.thumbnail_info.w = sticker.info.w; + + sticker.relations = generateRelations(); + + room->sendMessageEvent(sticker, mtx::events::EventType::Sticker); + break; + } + } } bool diff --git a/src/timeline/InputBar.h b/src/timeline/InputBar.h index b2db377f..1f1d6fe1 100644 --- a/src/timeline/InputBar.h +++ b/src/timeline/InputBar.h @@ -217,7 +217,7 @@ public slots: MarkdownOverride useMarkdown = MarkdownOverride::NOT_SPECIFIED, bool rainbowify = false); void reaction(const QString &reactedEvent, const QString &reactionKey); - void sticker(CombinedImagePackModel *model, int row); + void sticker(QStringList descriptor); void acceptUploads(); void declineUploads(); diff --git a/src/timeline/TimelineViewManager.cpp b/src/timeline/TimelineViewManager.cpp index 44f288c6..4b171dc4 100644 --- a/src/timeline/TimelineViewManager.cpp +++ b/src/timeline/TimelineViewManager.cpp @@ -17,6 +17,7 @@ #include "CommandCompleter.h" #include "CompletionProxyModel.h" #include "EventAccessors.h" +#include "GridImagePackModel.h" #include "ImagePackListModel.h" #include "InviteesModel.h" #include "Logging.h" @@ -477,6 +478,9 @@ TimelineViewManager::completerFor(const QString &completerName, const QString &r auto proxy = new CompletionProxyModel(stickerModel, 1, static_cast<size_t>(-1) / 4); stickerModel->setParent(proxy); return proxy; + } else if (completerName == QLatin1String("stickergrid")) { + auto stickerModel = new GridImagePackModel(roomId.toStdString(), true); + return stickerModel; } else if (completerName == QLatin1String("customEmoji")) { auto stickerModel = new CombinedImagePackModel(roomId.toStdString(), false); auto proxy = new CompletionProxyModel(stickerModel); |