Skip to content

Commit

Permalink
Chat history update button implemented
Browse files Browse the repository at this point in the history
  • Loading branch information
yesbhautik committed Apr 15, 2024
1 parent bcc6789 commit 3446c17
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions src/main/java/ChatApp.java
Original file line number Diff line number Diff line change
Expand Up @@ -45,18 +45,22 @@ public void start(Stage stage) {
input.setPromptText("Start talking with JavaGPT");
input.setOnAction(e -> doSearch(input.getText()));

Button searchButton = new Button("Search");
Button searchButton = new Button("Ask");
searchButton.setOnAction(e -> doSearch(input.getText()));

Button clearButton = new Button("Clear");
Button refreshButton = new Button("🔃"); // Add this line for the new Refresh button
refreshButton.setOnAction(e -> refreshChatHistory()); // Set the action to refresh chat history

Button clearButton = new Button("Clear Chat History");
clearButton.setOnAction(e -> {
data.clear(); // Clear the observable list
clearChatHistoryFromDatabase(); // Add this line to clear history from the database
lastAnswer.clear();
});
HBox inputBox = new HBox(20, input, searchButton, clearButton, refreshButton); // Include refreshButton here

HBox inputBox = new HBox(20, input, searchButton, clearButton);
inputBox.setPadding(new Insets(10, 0, 20, 0));
// HBox inputBox = new HBox(20, input, searchButton, clearButton);
// inputBox.setPadding(new Insets(10, 0, 20, 0));

TableColumn<SearchAction, Boolean> finishedColumn = new TableColumn<>("Finished");
finishedColumn.setCellValueFactory(cellData -> cellData.getValue().getFinishedProperty());
Expand Down Expand Up @@ -149,4 +153,9 @@ private void clearChatHistoryFromDatabase() {
e.printStackTrace();
}
}

private void refreshChatHistory() {
data.clear(); // Clear the current chat history from the UI
loadChatsFromDatabase(); // Reload chat history from the database
}
}

0 comments on commit 3446c17

Please sign in to comment.