chats with most recent messages get moved to the top
This commit is contained in:
		@@ -135,6 +135,13 @@ public final class ChatScene implements Restorable {
 | 
				
			|||||||
					}
 | 
										}
 | 
				
			||||||
					Platform.runLater(() -> { messageList.refresh(); scrollToMessageListEnd(); });
 | 
										Platform.runLater(() -> { messageList.refresh(); scrollToMessageListEnd(); });
 | 
				
			||||||
				}
 | 
									}
 | 
				
			||||||
 | 
									// Moving chat with most recent unreadMessages to the top
 | 
				
			||||||
 | 
									Platform.runLater(() -> {
 | 
				
			||||||
 | 
										userList.getItems().remove(chat);
 | 
				
			||||||
 | 
										userList.getItems().add(0, chat);
 | 
				
			||||||
 | 
										localDB.getChats().remove(chat);
 | 
				
			||||||
 | 
										localDB.getChats().add(0, chat);
 | 
				
			||||||
 | 
									});
 | 
				
			||||||
				userList.refresh();
 | 
									userList.refresh();
 | 
				
			||||||
			});
 | 
								});
 | 
				
			||||||
		});
 | 
							});
 | 
				
			||||||
@@ -453,6 +460,14 @@ public final class ChatScene implements Restorable {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
			// Add message to LocalDB and update UI
 | 
								// Add message to LocalDB and update UI
 | 
				
			||||||
			currentChat.insert(message);
 | 
								currentChat.insert(message);
 | 
				
			||||||
 | 
								// Moving currentChat to the top
 | 
				
			||||||
 | 
								Platform.runLater(() -> {
 | 
				
			||||||
 | 
									userList.getItems().remove(currentChat);
 | 
				
			||||||
 | 
									userList.getItems().add(0, currentChat);
 | 
				
			||||||
 | 
									userList.getSelectionModel().select(0);
 | 
				
			||||||
 | 
									localDB.getChats().remove(currentChat);
 | 
				
			||||||
 | 
									localDB.getChats().add(0, currentChat);
 | 
				
			||||||
 | 
								});
 | 
				
			||||||
			messageList.refresh();
 | 
								messageList.refresh();
 | 
				
			||||||
			scrollToMessageListEnd();
 | 
								scrollToMessageListEnd();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user