Skip to content

Commit

Permalink
ensure the notifications are sorted by time before display
Browse files Browse the repository at this point in the history
  • Loading branch information
c99koder committed May 20, 2022
1 parent 100ae3b commit bc2dc4d
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions src/com/irccloud/android/data/collection/NotificationsList.java
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,8 @@
import java.net.URLEncoder;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
Expand Down Expand Up @@ -557,6 +559,12 @@ private android.app.Notification buildNotification(String ticker, int cid, int b
String uid = prefs.getString("uid", "");
int defaults = 0;
String channelId = prefs.getBoolean("notify_channels", false) ? (uid + String.valueOf(bid)) : "highlight";
Collections.sort(messages, new Comparator<Notification>() {
@Override
public int compare(Notification notification, Notification t1) {
return Long.compare(notification.getEid(), t1.getEid());
}
});
if(prefs.getBoolean("notify_channels", false))
createChannel(uid + String.valueOf(bid), title, NotificationManagerCompat.IMPORTANCE_HIGH, String.valueOf(cid));
NotificationCompat.Builder builder = new NotificationCompat.Builder(IRCCloudApplication.getInstance().getApplicationContext(), channelId)
Expand Down Expand Up @@ -815,6 +823,13 @@ private synchronized void showMessageNotifications(String ticker) {
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(IRCCloudApplication.getInstance().getApplicationContext());
String text = "";
final List<Notification> notifications = getMessageNotifications();
Collections.sort(notifications, new Comparator<Notification>() {
@Override
public int compare(Notification notification, Notification t1) {
return Long.compare(notification.getEid(), t1.getEid());
}
});

boolean pref_avatarsOff = !prefs.getBoolean("avatars-off", true);
boolean pref_avatarImages = prefs.getBoolean("avatar-images", false);

Expand Down

0 comments on commit bc2dc4d

Please sign in to comment.