Fix insertion of oldest message
This commit is contained in:
parent
c54e7085ce
commit
7f536eacc6
@ -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