Refactor LinkPreviewer
Refactor `LinkPreviewer` to take an event and put the functions for getting the link in the class itself. This means the functions in `EventHandler` are no longer required. This mr also sets up `LinkPreviewer` so that it is automatically updated when an event is edited. This includes changing the link if edited, and it can handle a message having a previous link removed or a one added when one didn't exist before. Also adds test suite.
This commit is contained in:
@@ -493,18 +493,4 @@ QString TextHandler::linkifyUrls(QString stringIn)
|
||||
return stringIn;
|
||||
}
|
||||
|
||||
QList<QUrl> TextHandler::getLinkPreviews()
|
||||
{
|
||||
auto data = m_data.remove(TextRegex::removeRichReply);
|
||||
auto linksMatch = TextRegex::url.globalMatch(data);
|
||||
QList<QUrl> links;
|
||||
while (linksMatch.hasNext()) {
|
||||
auto link = linksMatch.next().captured();
|
||||
if (!link.contains(QStringLiteral("matrix.to"))) {
|
||||
links += QUrl(link);
|
||||
}
|
||||
}
|
||||
return links;
|
||||
}
|
||||
|
||||
#include "moc_texthandler.cpp"
|
||||
|
||||
Reference in New Issue
Block a user