Skip to content

Commit 1eb95b0

Browse files
author
Nasim Bondar Sahebi
committed
completed new clean architecture for the chat-initiation.
1 parent 14fc3c1 commit 1eb95b0

File tree

1 file changed

+17
-21
lines changed

1 file changed

+17
-21
lines changed
Lines changed: 17 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,36 @@
11
package use_cases.chat_initiation_use_case;
22

33

4-
54
import entities.chat.PrivateChat;
6-
import entities.message.MsgFactory;
5+
import entities.chat.PrivateChatfactory;
76

8-
/**
9-
* Chatinteractor connects our ChatView UI to our Entities.
10-
* It provide data to the view, so that view can put that data on the screen.
11-
* this class contain Privatchat and methods to update the Private chat.
12-
*/
7+
import java.util.UUID;
138

14-
public class ChatInteractor {
9+
public class ChatInteractor implements ChatInputBoundry{
1510

16-
PrivateChat privatechat;
1711

12+
PrivateChatfactory chatfactory;
1813

19-
// constructor containing the private chat
20-
public ChatInteractor(PrivateChat privatechat) {
21-
this.privatechat = privatechat;
22-
}
2314

15+
//Add a DaTa base to check if exist or not
16+
public ChatInteractor(PrivateChatfactory chatfactory){
17+
18+
this.chatfactory = chatfactory;
2419

25-
//Update the Recipientusername when the user type in the username text field and click add button.
26-
public void setRecipientUsername(String recipientUsername) {
27-
this.privatechat.setRecipientUsername(recipientUsername) ;
2820
}
2921

3022

31-
// Update the message history when the type in put in message txtfieled and click send button.
32-
public void setMessage(String content) {
33-
MsgFactory msgfactory = new MsgFactory("text");
34-
privatechat.addToConvHist(msgfactory.createMsg(privatechat.getSenderUsername(), content));
35-
}
23+
//create a private chat with the Recipient username that user typed in the textfield UI of the private chat.
24+
@Override
25+
public PrivateChat create(ChatModel chatmodel) {
26+
27+
//check if in data exist later
3628

29+
PrivateChat p= chatfactory.create(chatmodel.getRecipientusername(), UUID.randomUUID().toString(),chatmodel.getRecipientusername().toString());
30+
//
31+
return p;
3732

33+
}
3834

3935

4036
}

0 commit comments

Comments
 (0)