Fix insertion of oldest message

This commit is contained in:
Kai S. K. Engelbart 2020-07-01 08:58:02 +02:00
parent c54e7085ce
commit 7f536eacc6

View File

@ -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);
}
/**