Fix message duplicates on history load
This commit is contained in:
parent
46cf6f40aa
commit
97c0d34159
1 changed files with 7 additions and 1 deletions
|
@ -87,7 +87,13 @@ public class ChatHistory {
|
|||
* @param message The message to add
|
||||
*/
|
||||
public void addMessage(Message message, ErrorCallback errorCallback) {
|
||||
db.addMessage(message, () -> Platform.runLater(() -> history.add(message)), errorCallback);
|
||||
db.addMessage(message, () -> {
|
||||
// Add message to active history only if we already fetched it from db
|
||||
// This prevents duplicates when loading the db
|
||||
if (historyLoaded) {
|
||||
Platform.runLater(() -> history.add(message));
|
||||
}
|
||||
}, errorCallback);
|
||||
}
|
||||
|
||||
public interface HistoryLoadedCallback {
|
||||
|
|
Loading…
Reference in a new issue