mirror of
https://github.com/Chatterino/chatterino2.git
synced 2024-11-21 22:24:07 +01:00
Refresh links of new messages.
As I understand links update when all message snapshots update, so we need to refresh url manually via signal.
This commit is contained in:
parent
2d1701cf86
commit
5f19a57f5a
3 changed files with 27 additions and 6 deletions
|
@ -61,6 +61,12 @@ MessageElementFlags MessageElement::getFlags() const
|
||||||
return this->flags_;
|
return this->flags_;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
MessageElement *MessageElement::updateLink()
|
||||||
|
{
|
||||||
|
this->linkChanged.invoke();
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
// IMAGE
|
// IMAGE
|
||||||
ImageElement::ImageElement(ImagePtr image, MessageElementFlags flags)
|
ImageElement::ImageElement(ImagePtr image, MessageElementFlags flags)
|
||||||
: MessageElement(flags)
|
: MessageElement(flags)
|
||||||
|
@ -152,6 +158,15 @@ void TextElement::addToContainer(MessageLayoutContainer &container,
|
||||||
color, this->style_, container.getScale()))
|
color, this->style_, container.getScale()))
|
||||||
->setLink(this->getLink());
|
->setLink(this->getLink());
|
||||||
e->setTrailingSpace(trailingSpace);
|
e->setTrailingSpace(trailingSpace);
|
||||||
|
|
||||||
|
// If URL link was changed,
|
||||||
|
// Should update it in MessageLayoutElement too!
|
||||||
|
if (this->getLink().type == Link::Url) {
|
||||||
|
this->linkChanged.connect(
|
||||||
|
[this, e]() {
|
||||||
|
e->setLink(this->getLink());
|
||||||
|
});
|
||||||
|
}
|
||||||
return e;
|
return e;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -12,6 +12,7 @@
|
||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
#include <pajlada/signals/signalholder.hpp>
|
||||||
|
|
||||||
namespace chatterino {
|
namespace chatterino {
|
||||||
class Channel;
|
class Channel;
|
||||||
|
@ -128,6 +129,7 @@ public:
|
||||||
const Link &getLink() const;
|
const Link &getLink() const;
|
||||||
bool hasTrailingSpace() const;
|
bool hasTrailingSpace() const;
|
||||||
MessageElementFlags getFlags() const;
|
MessageElementFlags getFlags() const;
|
||||||
|
MessageElement *updateLink();
|
||||||
|
|
||||||
virtual void addToContainer(MessageLayoutContainer &container,
|
virtual void addToContainer(MessageLayoutContainer &container,
|
||||||
MessageElementFlags flags) = 0;
|
MessageElementFlags flags) = 0;
|
||||||
|
@ -135,6 +137,7 @@ public:
|
||||||
protected:
|
protected:
|
||||||
MessageElement(MessageElementFlags flags);
|
MessageElement(MessageElementFlags flags);
|
||||||
bool trailingSpace = true;
|
bool trailingSpace = true;
|
||||||
|
pajlada::Signals::NoArgSignal linkChanged;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Link link_;
|
Link link_;
|
||||||
|
|
|
@ -280,13 +280,16 @@ void TwitchMessageBuilder::addTextOrEmoji(const QString &string_)
|
||||||
->setLink(link);
|
->setLink(link);
|
||||||
|
|
||||||
LinkResolver::getLinkInfo(
|
LinkResolver::getLinkInfo(
|
||||||
linkString, [linkMELowercase, linkMEOriginal](QString tooltipText,
|
linkString, [linkMELowercase, linkMEOriginal, linkString]
|
||||||
Link originalLink) {
|
(QString tooltipText, Link originalLink) {
|
||||||
if (!tooltipText.isEmpty()) {
|
if (!tooltipText.isEmpty()) {
|
||||||
linkMELowercase->setTooltip(tooltipText)
|
linkMELowercase->setTooltip(tooltipText);
|
||||||
->setLink(originalLink);
|
linkMEOriginal->setTooltip(tooltipText);
|
||||||
linkMEOriginal->setTooltip(tooltipText)
|
}
|
||||||
->setLink(originalLink);
|
if (originalLink.value != linkString &&
|
||||||
|
!originalLink.value.isEmpty()) {
|
||||||
|
linkMELowercase->setLink(originalLink)->updateLink();
|
||||||
|
linkMEOriginal->setLink(originalLink)->updateLink();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue