From 1c65c36cb6178ae0221dc8d3172807523d363d6e Mon Sep 17 00:00:00 2001 From: James Booth Date: Sun, 31 Jan 2016 02:47:50 +0000 Subject: Show offline contacts with unread messages in roster --- src/ui/rosterwin.c | 50 ++++++++++++++------------------------------------ 1 file changed, 14 insertions(+), 36 deletions(-) (limited to 'src/ui') 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; -- cgit 1.4.1-2-gfad0 n26' href='#n26'>26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107