fix desktop chat
This commit is contained in:
@@ -123,7 +123,6 @@ public class ChatController {
|
|||||||
|
|
||||||
@FXML
|
@FXML
|
||||||
void btnSendClicked() {
|
void btnSendClicked() {
|
||||||
try {
|
|
||||||
if (selectedConversation == null) {
|
if (selectedConversation == null) {
|
||||||
lblChatStatus.setText("Select a conversation");
|
lblChatStatus.setText("Select a conversation");
|
||||||
return;
|
return;
|
||||||
@@ -135,17 +134,9 @@ public class ChatController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
txtMessage.clear();
|
txtMessage.clear();
|
||||||
boolean sent = realtimeClient.sendMessage(selectedConversation.getId(), content);
|
btnSend.setDisable(true);
|
||||||
if (!sent) {
|
lblChatStatus.setText("Sending message...");
|
||||||
sendMessageFallback(selectedConversation.getId(), content);
|
sendMessage(selectedConversation.getId(), content);
|
||||||
}
|
|
||||||
} catch (Exception e) {
|
|
||||||
ActivityLogger.getInstance().logException(
|
|
||||||
"ChatController.btnSendClicked",
|
|
||||||
e,
|
|
||||||
"Sending chat message");
|
|
||||||
lblChatStatus.setText("Chat send failed");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void loadCustomers() {
|
private void loadCustomers() {
|
||||||
@@ -211,19 +202,29 @@ public class ChatController {
|
|||||||
}).start();
|
}).start();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void sendMessageFallback(Long conversationId, String content) {
|
private void sendMessage(Long conversationId, String content) {
|
||||||
new Thread(() -> {
|
new Thread(() -> {
|
||||||
try {
|
try {
|
||||||
MessageResponse response = ChatApi.getInstance().sendMessage(conversationId, new MessageRequest(content));
|
MessageResponse response = ChatApi.getInstance().sendMessage(conversationId, new MessageRequest(content));
|
||||||
Platform.runLater(() -> {
|
Platform.runLater(() -> {
|
||||||
lblChatStatus.setText("Chat fallback active");
|
btnSend.setDisable(false);
|
||||||
|
if (!realtimeClient.isConnected()) {
|
||||||
appendMessageIfSelected(response);
|
appendMessageIfSelected(response);
|
||||||
|
}
|
||||||
|
if (selectedConversation != null && selectedConversation.getId().equals(conversationId)) {
|
||||||
|
lblChatStatus.setText("Message sent");
|
||||||
|
}
|
||||||
});
|
});
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
Platform.runLater(() -> ActivityLogger.getInstance().logException(
|
Platform.runLater(() -> {
|
||||||
"ChatController.sendMessageFallback",
|
txtMessage.setText(content);
|
||||||
|
btnSend.setDisable(false);
|
||||||
|
lblChatStatus.setText("Chat send failed");
|
||||||
|
ActivityLogger.getInstance().logException(
|
||||||
|
"ChatController.sendMessage",
|
||||||
e,
|
e,
|
||||||
"Sending chat message for conversation " + conversationId));
|
"Sending chat message for conversation " + conversationId);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}).start();
|
}).start();
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user