Fix desktop chat

This commit is contained in:
2026-04-08 08:38:23 -06:00
parent a7ba0fb4b4
commit cbdec1882c
5 changed files with 48 additions and 21 deletions

View File

@@ -241,16 +241,16 @@ public class AppointmentController {
return new AppointmentDTO(
response.getAppointmentId().intValue(),
response.getCustomerId() != null ? response.getCustomerId().intValue() : 0,
response.getCustomerName(),
response.getCustomerName() != null ? response.getCustomerName() : "",
response.getPetId() != null ? response.getPetId().intValue() : 0,
response.getPetName(),
response.getPetName() != null ? response.getPetName() : "",
response.getServiceId() != null ? response.getServiceId().intValue() : 0,
response.getServiceName(),
response.getServiceName() != null ? response.getServiceName() : "",
response.getEmployeeId() != null ? response.getEmployeeId().intValue() : 0,
response.getEmployeeName(),
response.getAppointmentDate().toString(),
response.getAppointmentTime().toString(),
response.getAppointmentStatus()
response.getEmployeeName() != null ? response.getEmployeeName() : "",
response.getAppointmentDate() != null ? response.getAppointmentDate().toString() : "",
response.getAppointmentTime() != null ? response.getAppointmentTime().toString() : "",
response.getAppointmentStatus() != null ? response.getAppointmentStatus() : ""
);
}
}

View File

@@ -105,7 +105,12 @@ public class ChatController {
});
realtimeClient.setConversationListener(conversation -> Platform.runLater(() -> upsertConversation(conversation)));
realtimeClient.setMessageListener(message -> Platform.runLater(() -> appendMessageIfSelected(message)));
realtimeClient.setMessageListener(message -> Platform.runLater(() -> {
Long myId = UserSession.getInstance().getUserId();
if (message.getSenderId() == null || !message.getSenderId().equals(myId)) {
appendMessageIfSelected(message);
}
}));
realtimeClient.setStatusListener(status -> Platform.runLater(() -> lblChatStatus.setText(status)));
realtimeClient.subscribeToConversations();
@@ -208,9 +213,7 @@ public class ChatController {
MessageResponse response = ChatApi.getInstance().sendMessage(conversationId, new MessageRequest(content));
Platform.runLater(() -> {
btnSend.setDisable(false);
if (!realtimeClient.isConnected()) {
appendMessageIfSelected(response);
}
appendMessageIfSelected(response);
if (selectedConversation != null && selectedConversation.getId().equals(conversationId)) {
lblChatStatus.setText("Message sent");
}

View File

@@ -327,12 +327,12 @@ public class PetController {
private Pet mapToPet(PetResponse response) {
Pet pet = new Pet(
response.getPetId().intValue(),
response.getPetName(),
response.getPetSpecies(),
response.getPetBreed(),
response.getPetName() != null ? response.getPetName() : "",
response.getPetSpecies() != null ? response.getPetSpecies() : "",
response.getPetBreed() != null ? response.getPetBreed() : "",
response.getPetAge() != null ? response.getPetAge() : 0,
response.getPetStatus(),
response.getPetPrice().doubleValue(),
response.getPetStatus() != null ? response.getPetStatus() : "",
response.getPetPrice() != null ? response.getPetPrice().doubleValue() : 0.0,
response.getImageUrl()
);
pet.setCustomerName(response.getCustomerName());