Merge pull request 'Fixed Bug not Updating GroupCreationTab After a new Contact was Added' (#46) from b/group-tab-update into develop
Reviewed-on: https://git.kske.dev/zdm/envoy/pulls/46 Reviewed-by: DieGurke <maxi@kske.dev> Reviewed-by: kske <kai@kske.dev>
This commit is contained in:
		| @@ -42,9 +42,10 @@ public class ContactSearchTab implements EventListener { | |||||||
| 	@FXML | 	@FXML | ||||||
| 	private ListView<User> userList; | 	private ListView<User> userList; | ||||||
|  |  | ||||||
| 	private Alert alert = new Alert(AlertType.CONFIRMATION); |  | ||||||
| 	private User currentlySelectedUser; | 	private User currentlySelectedUser; | ||||||
|  |  | ||||||
|  | 	private final Alert alert = new Alert(AlertType.CONFIRMATION); | ||||||
|  |  | ||||||
| 	private static final EventBus	eventBus	= EventBus.getInstance(); | 	private static final EventBus	eventBus	= EventBus.getInstance(); | ||||||
| 	private static final Logger		logger		= EnvoyLog.getLogger(ChatScene.class); | 	private static final Logger		logger		= EnvoyLog.getLogger(ChatScene.class); | ||||||
|  |  | ||||||
| @@ -69,7 +70,7 @@ public class ContactSearchTab implements EventListener { | |||||||
| 	} | 	} | ||||||
|  |  | ||||||
| 	/** | 	/** | ||||||
| 	 * Disables the clear and search button if no text is present in the search bar. | 	 * If text is present, sends a request to the server. | ||||||
| 	 * | 	 * | ||||||
| 	 * @since Envoy Client v0.1-beta | 	 * @since Envoy Client v0.1-beta | ||||||
| 	 */ | 	 */ | ||||||
|   | |||||||
| @@ -4,6 +4,7 @@ import static java.util.function.Predicate.not; | |||||||
|  |  | ||||||
| import java.util.stream.Collectors; | import java.util.stream.Collectors; | ||||||
|  |  | ||||||
|  | import javafx.application.Platform; | ||||||
| import javafx.fxml.FXML; | import javafx.fxml.FXML; | ||||||
| import javafx.scene.control.*; | import javafx.scene.control.*; | ||||||
| import javafx.scene.layout.HBox; | import javafx.scene.layout.HBox; | ||||||
| @@ -13,6 +14,7 @@ import envoy.client.event.*; | |||||||
| import envoy.client.ui.listcell.*; | import envoy.client.ui.listcell.*; | ||||||
| import envoy.data.*; | import envoy.data.*; | ||||||
| import envoy.event.GroupCreation; | import envoy.event.GroupCreation; | ||||||
|  | import envoy.event.contact.ContactOperation; | ||||||
| import envoy.util.Bounds; | import envoy.util.Bounds; | ||||||
|  |  | ||||||
| import dev.kske.eventbus.*; | import dev.kske.eventbus.*; | ||||||
| @@ -70,6 +72,7 @@ public class GroupCreationTab implements EventListener { | |||||||
| 		userList.setCellFactory(new ListCellFactory<>(ContactControl::new)); | 		userList.setCellFactory(new ListCellFactory<>(ContactControl::new)); | ||||||
| 		userList.getSelectionModel().setSelectionMode(SelectionMode.MULTIPLE); | 		userList.getSelectionModel().setSelectionMode(SelectionMode.MULTIPLE); | ||||||
| 		createButton.setDisable(true); | 		createButton.setDisable(true); | ||||||
|  | 		eventBus.registerListener(this); | ||||||
| 		userList.getItems() | 		userList.getItems() | ||||||
| 			.addAll(localDB.getChats() | 			.addAll(localDB.getChats() | ||||||
| 				.stream() | 				.stream() | ||||||
| @@ -199,4 +202,18 @@ public class GroupCreationTab implements EventListener { | |||||||
| 		errorProceedBox.setMinHeight(value); | 		errorProceedBox.setMinHeight(value); | ||||||
| 		errorProceedBox.setMaxHeight(value); | 		errorProceedBox.setMaxHeight(value); | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
|  | 	@Event | ||||||
|  | 	private void onContactOperation(ContactOperation operation) { | ||||||
|  | 		if (operation.get() instanceof User) Platform.runLater(() -> { | ||||||
|  | 			switch (operation.getOperationType()) { | ||||||
|  | 				case ADD: | ||||||
|  | 					userList.getItems().add((User) operation.get()); | ||||||
|  | 					break; | ||||||
|  | 				case REMOVE: | ||||||
|  | 					userList.getItems().removeIf(u -> u.equals(operation.get())); | ||||||
|  | 					break; | ||||||
|  | 			} | ||||||
|  | 		}); | ||||||
|  | 	} | ||||||
| } | } | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user