Skip to content

Commit

Permalink
Bring activities requiring interaction on top.
Browse files Browse the repository at this point in the history
Signed-off-by: alex-z <[email protected]>
  • Loading branch information
allexzander committed Sep 12, 2023
1 parent 2d8c68d commit 472d3e1
Showing 1 changed file with 47 additions and 0 deletions.
47 changes: 47 additions & 0 deletions src/gui/tray/sortedactivitylistmodel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 472d3e1

Please sign in to comment.