Fix insertion of oldest message
This commit is contained in:
parent
b380efc38f
commit
e5ddf32b4a
@ -101,12 +101,12 @@ public final class Chat implements Serializable {
|
||||
* @since Envoy Client v0.1-beta
|
||||
*/
|
||||
public void insert(Message message) {
|
||||
if (messages.isEmpty()) messages.add(message);
|
||||
else for (int i = messages.size() - 1; i >= 0; --i)
|
||||
for (int i = messages.size() - 1; i >= 0; --i)
|
||||
if (message.getCreationDate().isAfter(messages.get(i).getCreationDate())) {
|
||||
messages.add(i + 1, message);
|
||||
break;
|
||||
return;
|
||||
}
|
||||
messages.add(0, message);
|
||||
}
|
||||
|
||||
/**
|
||||
|
Reference in New Issue
Block a user