diff --git a/src/gui/tray/sortedactivitylistmodel.cpp b/src/gui/tray/sortedactivitylistmodel.cpp index d62ad4985bfae..a148509f9973c 100644 --- a/src/gui/tray/sortedactivitylistmodel.cpp +++ b/src/gui/tray/sortedactivitylistmodel.cpp @@ -74,6 +74,53 @@ bool SortedActivityListModel::lessThan(const QModelIndex &sourceLeft, const QMod return leftIsErrorFileItemStatus; } + auto leftActivityNeedsPostInteraction = false; + auto rightActivityNeedsPostInteraction = false; + + auto leftActivityNeedsReplyInteraction = false; + auto rightActivityNeedsReplyInteraction = false; + + auto leftActivityNeedsWebInteraction = false; + auto rightActivityNeedsWebInteraction = false; + + for (const auto &link : leftActivity._links) { + if (link._verb == QByteArrayLiteral("POST")) { + leftActivityNeedsPostInteraction = true; + } else if (link._verb == QByteArrayLiteral("REPLY")) { + leftActivityNeedsReplyInteraction = true; + } else if (link._verb == QByteArrayLiteral("WEB")) { + leftActivityNeedsWebInteraction = true; + } + } + + for (const auto &link : rightActivity._links) { + if (link._verb == QByteArrayLiteral("POST")) { + rightActivityNeedsPostInteraction = true; + } else if (link._verb == QByteArrayLiteral("REPLY")) { + rightActivityNeedsReplyInteraction = true; + } else if (link._verb == QByteArrayLiteral("WEB")) { + rightActivityNeedsWebInteraction = true; + } + } + + if (leftActivityNeedsPostInteraction && !rightActivityNeedsPostInteraction) { + return true; + } else if (!leftActivityNeedsPostInteraction && rightActivityNeedsPostInteraction) { + return false; + } + + if (leftActivityNeedsReplyInteraction && !rightActivityNeedsReplyInteraction) { + return true; + } else if (!leftActivityNeedsReplyInteraction && rightActivityNeedsReplyInteraction) { + return false; + } + + if (leftActivityNeedsWebInteraction && !rightActivityNeedsWebInteraction) { + return true; + } else if (!leftActivityNeedsWebInteraction && rightActivityNeedsWebInteraction) { + return false; + } + // Let's go back to more broadly comparing by type if (const auto rightType = rightActivity._type; leftType != rightType) { return leftType < rightType;