about summary refs log tree commit diff stats
path: root/src/ui
diff options
context:
space:
mode:
authorJames Booth <boothj5@gmail.com>2016-01-31 02:47:50 +0000
committerJames Booth <boothj5@gmail.com>2016-01-31 02:47:50 +0000
commit1c65c36cb6178ae0221dc8d3172807523d363d6e (patch)
treed073af2f33de681f55869ed72fefe3d1ba0f5558 /src/ui
parente816b124ee754ba11dfe84710b478388651defdc (diff)
downloadprofani-tty-1c65c36cb6178ae0221dc8d3172807523d363d6e.tar.gz
Show offline contacts with unread messages in roster
Diffstat (limited to 'src/ui')
-rw-r--r--src/ui/rosterwin.c50
1 files changed, 14 insertions, 36 deletions
diff --git a/src/ui/rosterwin.c b/src/ui/rosterwin.c
index 385911b9..971c6fd3 100644
--- a/src/ui/rosterwin.c
+++ b/src/ui/rosterwin.c
@@ -923,7 +923,6 @@ _rosterwin_private_header(ProfLayoutSplit *layout, GList *privs)
 static GSList*
 _filter_contacts(GSList *contacts)
 {
-    char *countpref = prefs_get_string(PREF_ROSTER_COUNT);
     GSList *filtered_contacts = NULL;
 
     // if show offline, include all contacts
@@ -935,43 +934,25 @@ _filter_contacts(GSList *contacts)
         }
     // if dont show offline
     } else {
-        // if header count unread
-        if (g_strcmp0(countpref, "unread") == 0) {
-            GSList *curr = contacts;
-            while (curr) {
-                PContact contact = curr->data;
-                const char *presence = p_contact_presence(contact);
+        GSList *curr = contacts;
+        while (curr) {
+            PContact contact = curr->data;
+            const char *presence = p_contact_presence(contact);
 
-                // include if not offline
-                if (g_strcmp0(presence, "offline") != 0) {
+            // include if offline and unread messages
+            if (g_strcmp0(presence, "offline") == 0) {
+                ProfChatWin *chatwin = wins_get_chat(p_contact_barejid(contact));
+                if (chatwin && chatwin->unread > 0) {
                     filtered_contacts = g_slist_append(filtered_contacts, contact);
-
-                // include if offline and unread messages
-                } else {
-                    ProfChatWin *chatwin = wins_get_chat(p_contact_barejid(contact));
-                    if (chatwin && chatwin->unread > 0) {
-                        filtered_contacts = g_slist_append(filtered_contacts, contact);
-                    }
                 }
-                curr = g_slist_next(curr);
-            }
 
-        // header count not unread
-        } else {
-            GSList *curr = contacts;
-            while (curr) {
-                PContact contact = curr->data;
-                const char *presence = p_contact_presence(contact);
-
-                // include if not offline
-                if (g_strcmp0(presence, "offline") != 0) {
-                    filtered_contacts = g_slist_append(filtered_contacts, contact);
-                }
-                curr = g_slist_next(curr);
+            // include if not offline
+            } else {
+                filtered_contacts = g_slist_append(filtered_contacts, contact);
             }
+            curr = g_slist_next(curr);
         }
     }
-    prefs_free_string(countpref);
 
     return filtered_contacts;
 }
@@ -983,7 +964,6 @@ _filter_contacts_with_presence(GSList *contacts, const char *const presence)
 
     // handling offline contacts
     if (g_strcmp0(presence, "offline") == 0) {
-        char *countpref = prefs_get_string(PREF_ROSTER_COUNT);
 
         // if show offline, include all contacts
         if (prefs_get_boolean(PREF_ROSTER_OFFLINE)) {
@@ -993,8 +973,8 @@ _filter_contacts_with_presence(GSList *contacts, const char *const presence)
                 curr = g_slist_next(curr);
             }
 
-        // if header count unread, include those with unread messages
-        } else if (g_strcmp0(countpref, "unread") == 0) {
+        // otherwise show if unread messages
+        } else {
             GSList *curr = contacts;
             while (curr) {
                 PContact contact = curr->data;
@@ -1006,8 +986,6 @@ _filter_contacts_with_presence(GSList *contacts, const char *const presence)
             }
         }
 
-        prefs_free_string(countpref);
-
     // any other presence, include all
     } else {
         GSList *curr = contacts;