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
|
* @since Envoy Client v0.1-beta
|
||||||
*/
|
*/
|
||||||
public void insert(Message message) {
|
public void insert(Message message) {
|
||||||
if (messages.isEmpty()) messages.add(message);
|
for (int i = messages.size() - 1; i >= 0; --i)
|
||||||
else for (int i = messages.size() - 1; i >= 0; --i)
|
|
||||||
if (message.getCreationDate().isAfter(messages.get(i).getCreationDate())) {
|
if (message.getCreationDate().isAfter(messages.get(i).getCreationDate())) {
|
||||||
messages.add(i + 1, message);
|
messages.add(i + 1, message);
|
||||||
break;
|
return;
|
||||||
}
|
}
|
||||||
|
messages.add(0, message);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Reference in New Issue
Block a user