|
1 | 1 | package use_cases.chat_initiation_use_case;
|
2 | 2 |
|
3 | 3 |
|
4 |
| - |
5 | 4 | import entities.chat.PrivateChat;
|
6 |
| -import entities.message.MsgFactory; |
| 5 | +import entities.chat.PrivateChatfactory; |
7 | 6 |
|
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; |
13 | 8 |
|
14 |
| -public class ChatInteractor { |
| 9 | +public class ChatInteractor implements ChatInputBoundry{ |
15 | 10 |
|
16 |
| - PrivateChat privatechat; |
17 | 11 |
|
| 12 | + PrivateChatfactory chatfactory; |
18 | 13 |
|
19 |
| - // constructor containing the private chat |
20 |
| - public ChatInteractor(PrivateChat privatechat) { |
21 |
| - this.privatechat = privatechat; |
22 |
| - } |
23 | 14 |
|
| 15 | + //Add a DaTa base to check if exist or not |
| 16 | + public ChatInteractor(PrivateChatfactory chatfactory){ |
| 17 | + |
| 18 | + this.chatfactory = chatfactory; |
24 | 19 |
|
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) ; |
28 | 20 | }
|
29 | 21 |
|
30 | 22 |
|
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 |
36 | 28 |
|
| 29 | + PrivateChat p= chatfactory.create(chatmodel.getRecipientusername(), UUID.randomUUID().toString(),chatmodel.getRecipientusername().toString()); |
| 30 | + // |
| 31 | + return p; |
37 | 32 |
|
| 33 | + } |
38 | 34 |
|
39 | 35 |
|
40 | 36 | }
|
0 commit comments