Skip to content

Commit

Permalink
Made loadStateFromPreferenceStore() check if no messages
Browse files Browse the repository at this point in the history
  • Loading branch information
jukofyork committed Nov 9, 2024
1 parent bd1ac26 commit 5b9ac08
Showing 1 changed file with 24 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -270,28 +270,30 @@ public void run() {
Logger.warning("Failed to load chat conversation: " + e.getMessage());
tempConversation = new ChatConversation(); // Fallback to an empty conversation
}
performOnMainView(mainView -> {
mainView.getChatMessageArea().setEnabled(false);
mainView.getChatMessageArea().setVisible(false);
});
for (ChatMessage message : tempConversation.messages()) {
switch (message.getRole()) {
case USER:
sendUserMessage(message.getMessage(), false);
break;
case ASSISTANT:
sendAutoReplyAssistantMessage(message.getMessage());
break;
case NOTIFICATION:
displayNotificationMessage(message.getMessage());
break;
}
}
performOnMainView(mainView -> {
mainView.getChatMessageArea().setVisible(true);
mainView.getChatMessageArea().setEnabled(true);
});
onScrollToBottom(); // Ensures the view is scrolled to the bottom after loading messages
if (!tempConversation.isEmpty()) {
performOnMainView(mainView -> {
mainView.getChatMessageArea().setEnabled(false);
mainView.getChatMessageArea().setVisible(false);
});
for (ChatMessage message : tempConversation.messages()) {
switch (message.getRole()) {
case USER:
sendUserMessage(message.getMessage(), false);
break;
case ASSISTANT:
sendAutoReplyAssistantMessage(message.getMessage());
break;
case NOTIFICATION:
displayNotificationMessage(message.getMessage());
break;
}
}
performOnMainView(mainView -> {
mainView.getChatMessageArea().setVisible(true);
mainView.getChatMessageArea().setEnabled(true);
});
onScrollToBottom();
}
try {
userMessageHistory = Preferences.loadUserMessageHistory();
} catch (IOException e) {
Expand Down

0 comments on commit 5b9ac08

Please sign in to comment.