Skip to content

Commit

Permalink
Get unreads back on top..
Browse files Browse the repository at this point in the history
  • Loading branch information
b100dian committed Dec 14, 2020
1 parent 2337d6e commit c9740d3
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 6 deletions.
18 changes: 12 additions & 6 deletions qml/pages/ChannelList.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ function handleChannelLeft(channel) {
}

function getChannelSection(channel) {
if (channel.is_starred > 0) {
if (channel.is_starred) {
return "starred"
}
else {
Expand All @@ -55,19 +55,25 @@ function getChannelSection(channel) {
}

function compareChannels(a, b) {
var result = compareByBool(a, b, "is_starred", true);
if (result) return result;
var result = 0;
if (b.unreadCount !== a.unreadCount) {
result = (b.unreadCount ? 1 : 0) - (a.unreadCount ? 1 : 0);
}
if (result !== 0) return result;

result = compareByBool(a, b, "is_starred", true);
if (result !== 0) return result;

result = compareByCategory(a, b);
if (result) return result;
if (result !== 0) return result;

result = compareByBool(a, b, "is_private", false);
if (result) return result;
if (result !== 0) return result;

return Channel.compareByName(a, b)
}

var categories = ["starred", "channel", "chat"];
var categories = ["channel", "chat"];
function compareByCategory(a, b) {
if (a.category !== b.category) {
var diff = categories.indexOf(a.category) - categories.indexOf(b.category);
Expand Down
2 changes: 2 additions & 0 deletions qml/pages/ChannelListView.qml
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,8 @@ SilicaListView {

function getSectionName(section) {
switch (section) {
case "unread":
return qsTr("Unread");
case "starred":
return qsTr("Starred")

Expand Down

0 comments on commit c9740d3

Please sign in to comment.