Remove chat rename

This commit is contained in:
2026-03-11 14:08:35 -06:00
parent d98b4cc8e5
commit 20db3e5344
3 changed files with 1 additions and 44 deletions

View File

@@ -4,7 +4,6 @@ module org.example.petshopdesktop {
requires javafx.web;
requires java.sql;
requires java.net.http;
requires java.prefs;
requires com.fasterxml.jackson.databind;
requires com.fasterxml.jackson.core;
requires com.fasterxml.jackson.annotation;

View File

@@ -6,7 +6,6 @@ import javafx.collections.ObservableList;
import javafx.fxml.FXML;
import javafx.scene.control.Button;
import javafx.scene.control.Label;
import javafx.scene.control.TextInputDialog;
import javafx.scene.control.ListCell;
import javafx.scene.control.ListView;
import javafx.scene.control.ScrollPane;
@@ -32,7 +31,6 @@ import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import java.util.prefs.Preferences;
public class ChatController {
private static final DateTimeFormatter TIME_FORMATTER = DateTimeFormatter.ofPattern("MMM d, HH:mm");
@@ -61,8 +59,6 @@ public class ChatController {
@FXML
private Label lblChatStatus;
private static final Preferences CHAT_PREFERENCES = Preferences.userNodeForPackage(ChatController.class);
private final ObservableList<ConversationResponse> conversations = FXCollections.observableArrayList();
private final Map<Long, String> customerLabels = new HashMap<>();
private final ChatRealtimeClient realtimeClient = ChatRealtimeClient.getInstance();
@@ -125,35 +121,6 @@ public class ChatController {
}
}
@FXML
void lblConversationTitleClicked() {
if (selectedConversation == null) {
return;
}
TextInputDialog dialog = new TextInputDialog(getConversationTitle(selectedConversation));
dialog.setTitle("Rename Conversation");
dialog.setHeaderText("Rename this conversation");
dialog.setContentText("Title:");
dialog.getEditor().setTextFormatter(new javafx.scene.control.TextFormatter<String>(change -> change.getControlNewText().length() <= 60 ? change : null));
Optional<String> result = dialog.showAndWait();
if (result.isEmpty()) {
return;
}
String alias = result.get().trim();
String key = conversationPreferenceKey(selectedConversation.getId());
if (alias.isEmpty() || alias.equals(defaultConversationTitle(selectedConversation))) {
CHAT_PREFERENCES.remove(key);
} else {
CHAT_PREFERENCES.put(key, alias);
}
lblConversationTitle.setText(getConversationTitle(selectedConversation));
lvConversations.refresh();
}
@FXML
void btnSendClicked() {
if (selectedConversation == null) {
@@ -354,19 +321,10 @@ public class ChatController {
}
private String getConversationTitle(ConversationResponse conversation) {
String alias = CHAT_PREFERENCES.get(conversationPreferenceKey(conversation.getId()), null);
return alias != null && !alias.isBlank() ? alias : defaultConversationTitle(conversation);
}
private String defaultConversationTitle(ConversationResponse conversation) {
String customerLabel = customerLabels.get(conversation.getCustomerId());
return customerLabel != null ? customerLabel : "Customer #" + conversation.getCustomerId();
}
private String conversationPreferenceKey(Long conversationId) {
return "chat.title." + conversationId;
}
private String buildConversationMeta(ConversationResponse conversation) {
String assignee;
if (conversation.getStaffId() != null) {

View File

@@ -48,7 +48,7 @@
<Insets bottom="18.0" left="18.0" right="18.0" top="18.0" />
</padding>
<children>
<Label fx:id="lblConversationTitle" onMouseClicked="#lblConversationTitleClicked" style="-fx-cursor: hand;" text="Select a conversation" textFill="#0f172a">
<Label fx:id="lblConversationTitle" text="Select a conversation" textFill="#0f172a">
<font>
<Font name="System Bold" size="24.0" />
</font>