Implemented some suggestions made by @delvh
This commit is contained in:
parent
b5e83272a6
commit
d8eb2d6f6e
@ -140,10 +140,10 @@ public final class ChatScene implements Restorable {
|
|||||||
userList.getItems().remove(chat);
|
userList.getItems().remove(chat);
|
||||||
userList.getItems().add(0, chat);
|
userList.getItems().add(0, chat);
|
||||||
if (chat.equals(currentChat)) userList.getSelectionModel().select(0);
|
if (chat.equals(currentChat)) userList.getSelectionModel().select(0);
|
||||||
|
userList.refresh();
|
||||||
localDB.getChats().remove(chat);
|
localDB.getChats().remove(chat);
|
||||||
localDB.getChats().add(0, chat);
|
localDB.getChats().add(0, chat);
|
||||||
});
|
});
|
||||||
userList.refresh();
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -1,9 +1,8 @@
|
|||||||
package envoy.client.ui.controller;
|
package envoy.client.ui.controller;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
import javafx.application.Platform;
|
import javafx.application.Platform;
|
||||||
import javafx.fxml.FXML;
|
import javafx.fxml.FXML;
|
||||||
@ -64,10 +63,8 @@ public class ContactSearchScene {
|
|||||||
searchBar.setClearButtonListener(e -> { searchBar.getTextField().clear(); contactList.getItems().clear(); });
|
searchBar.setClearButtonListener(e -> { searchBar.getTextField().clear(); contactList.getItems().clear(); });
|
||||||
eventBus.register(ContactSearchResult.class,
|
eventBus.register(ContactSearchResult.class,
|
||||||
response -> Platform.runLater(() -> {
|
response -> Platform.runLater(() -> {
|
||||||
List<Chat> chats = new ArrayList<Chat>();
|
|
||||||
response.get().stream().forEach(r -> chats.add(new Chat(r)));
|
|
||||||
contactList.getItems().clear();
|
contactList.getItems().clear();
|
||||||
contactList.getItems().addAll(chats);
|
contactList.getItems().addAll(response.get().stream().map(Chat::new).collect(Collectors.toList()));
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -117,7 +114,7 @@ public class ContactSearchScene {
|
|||||||
eventBus.dispatch(new SendEvent(event));
|
eventBus.dispatch(new SendEvent(event));
|
||||||
// Updates the UI
|
// Updates the UI
|
||||||
eventBus.dispatch(event);
|
eventBus.dispatch(event);
|
||||||
logger.log(Level.INFO, "Added contact " + chat);
|
logger.log(Level.INFO, "Added contact " + chat.getRecipient());
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -4,6 +4,7 @@ import javafx.geometry.Pos;
|
|||||||
import javafx.scene.control.Label;
|
import javafx.scene.control.Label;
|
||||||
import javafx.scene.layout.*;
|
import javafx.scene.layout.*;
|
||||||
|
|
||||||
|
import envoy.client.data.Chat;
|
||||||
import envoy.data.Contact;
|
import envoy.data.Contact;
|
||||||
import envoy.data.Group;
|
import envoy.data.Group;
|
||||||
import envoy.data.User;
|
import envoy.data.User;
|
||||||
@ -24,20 +25,20 @@ public class ChatControl extends HBox {
|
|||||||
* @param contact the contact that should be formatted
|
* @param contact the contact that should be formatted
|
||||||
* @since Envoy Client v0.1-beta
|
* @since Envoy Client v0.1-beta
|
||||||
*/
|
*/
|
||||||
public ChatControl(Contact contact, int unreadMessagesAmount) {
|
public ChatControl(Chat chat, int unreadMessagesAmount) {
|
||||||
// Container with contact name
|
// Container with contact name
|
||||||
final var vBox = new VBox();
|
final var vBox = new VBox();
|
||||||
final var nameLabel = new Label(contact.getName());
|
final var nameLabel = new Label(chat.getRecipient().getName());
|
||||||
nameLabel.setWrapText(true);
|
nameLabel.setWrapText(true);
|
||||||
vBox.getChildren().add(nameLabel);
|
vBox.getChildren().add(nameLabel);
|
||||||
if (contact instanceof User) {
|
if (chat.getRecipient() instanceof User) {
|
||||||
// Online status
|
// Online status
|
||||||
final var user = (User) contact;
|
final var user = (User) chat.getRecipient();
|
||||||
final var statusLabel = new Label(user.getStatus().toString());
|
final var statusLabel = new Label(user.getStatus().toString());
|
||||||
statusLabel.getStyleClass().add(user.getStatus().toString().toLowerCase());
|
statusLabel.getStyleClass().add(user.getStatus().toString().toLowerCase());
|
||||||
vBox.getChildren().add(statusLabel);
|
vBox.getChildren().add(statusLabel);
|
||||||
} else // Member count
|
} else // Member count
|
||||||
vBox.getChildren().add(new Label(((Group) contact).getContacts().size() + " members"));
|
vBox.getChildren().add(new Label(((Group) chat.getRecipient()).getContacts().size() + " members"));
|
||||||
|
|
||||||
getChildren().add(vBox);
|
getChildren().add(vBox);
|
||||||
if (unreadMessagesAmount != 0) {
|
if (unreadMessagesAmount != 0) {
|
||||||
|
@ -36,7 +36,7 @@ public class ContactListCellFactory extends ListCell<Chat> {
|
|||||||
setText(null);
|
setText(null);
|
||||||
setGraphic(null);
|
setGraphic(null);
|
||||||
} else {
|
} else {
|
||||||
final var control = new ChatControl(chat.getRecipient(), chat.getUnreadAmount());
|
final var control = new ChatControl(chat, chat.getUnreadAmount());
|
||||||
prefWidthProperty().bind(listView.widthProperty().subtract(40));
|
prefWidthProperty().bind(listView.widthProperty().subtract(40));
|
||||||
setGraphic(control);
|
setGraphic(control);
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user