Skip to content

Commit

Permalink
fix(demo): use builder instead of constructor
Browse files Browse the repository at this point in the history
Closes #5
  • Loading branch information
mlopezFC authored and javier-godoy committed Nov 14, 2023
1 parent ee45827 commit 4821b2f
Showing 1 changed file with 9 additions and 24 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,6 @@
*/
package com.flowingcode.vaadin.addons.chatassistant;

import com.flowingcode.vaadin.addons.chatassistant.ChatAssistant;
import com.flowingcode.vaadin.addons.chatassistant.Message;
import com.flowingcode.vaadin.addons.chatassistant.Sender;
import com.flowingcode.vaadin.addons.demo.DemoSource;
import com.vaadin.flow.component.button.Button;
import com.vaadin.flow.component.dependency.CssImport;
Expand All @@ -45,27 +42,15 @@ public ChatAssistantDemo() {
message.setSizeFull();

Button chat = new Button("Chat");
chat.addClickListener(
ev -> {
Message m =
new Message(
message.getValue(),
false,
false,
0,
false,
new Sender("Assistant", "1", "chatbot.png"));
chatAssistant.sendMessage(m);
message.clear();
});
chatAssistant.sendMessage(
new Message(
"Hello, I am here to assist you",
false,
false,
0,
false,
new Sender("Assistant", "1", "chatbot.png")));
chat.addClickListener(ev -> {
Message m = Message.builder().content(message.getValue())
.sender(Sender.builder().name("Assistant").id("1").avatar("chatbot.png").build()).build();

chatAssistant.sendMessage(m);
message.clear();
});
chatAssistant.sendMessage(Message.builder().content("Hello, I am here to assist you")
.sender(Sender.builder().name("Assistant").id("1").avatar("chatbot.png").build()).build());
chatAssistant.toggle();
chatAssistant.addChatSentListener(
ev -> {
Expand Down

0 comments on commit 4821b2f

Please sign in to comment.