Skip to content

Commit a063654

Browse files
committed
Added UserChatGateway, and the method getUserChats in UserDatabase
1 parent 4ea4c74 commit a063654

File tree

2 files changed

+24
-1
lines changed

2 files changed

+24
-1
lines changed

src/main/java/UserChatGateway.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
import java.util.ArrayList;
2+
3+
public interface UserChatGateway {
4+
5+
// ArrayList<Chat> getUserChats(String username);
6+
}

src/main/java/UserDatabase.java

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
import java.util.ArrayList;
33
import java.util.List;
44
public class UserDatabase implements UserExists, UserRetriever, UserCreator, IRetrieveList, UserModificationGateway,
5-
ConvHistGateway, MsgSenderGateway {
5+
ConvHistGateway, MsgSenderGateway, UserChatGateway {
66
File accounts;
77
List<User> accountList;
88
public UserDatabase(){
@@ -116,6 +116,7 @@ public void modifyUser(String oldUsername, User modified){
116116
}
117117
}
118118

119+
119120
// Below two methods are used by conversation history-related interactors
120121
// (Commented as objects are not found)
121122
// /**
@@ -147,4 +148,20 @@ public void modifyUser(String oldUsername, User modified){
147148
//
148149
// return Chat.getConversationHistory();
149150
// }
151+
152+
153+
154+
155+
// This method will get a user's chats; this will be used by AppScreenLoader to display chats and could
156+
// also be used by ChatInteractor (Chat entity is undefined here and at the moment user doesn't have chats)
157+
// @Override
158+
// public ArrayList<Chat> getUserChats(String username) {
159+
// for (User user: accountList){
160+
// if (user.getUsername().equals(username)){
161+
// return user.getChats();
162+
// }
163+
// }
164+
// throw new RuntimeException("Invalid username: user does not exist");
165+
// }
166+
150167
}

0 commit comments

Comments
 (0)