Skip to content

Commit 6cffb4e

Browse files
committed
Made changes to acessing userdatabase and also calling chatview
1 parent fea161b commit 6cffb4e

File tree

2 files changed

+11
-19
lines changed

2 files changed

+11
-19
lines changed

src/main/java/app_screen/AppScreen.java

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -44,14 +44,15 @@ public AppScreen(String currentUsername, ArrayList<Chat> chats) {
4444

4545
// adding the action listeners for the +private-chat and +group-chat buttons
4646
addPrivateChat.addActionListener(e -> {
47-
ChatView newChat = new ChatView(currentUsername, true);
47+
ChatView newChat = new ChatView(currentUsername, true, "");
4848
newChat.chatDisplay();
4949

5050
});
51-
addGroupChat.addActionListener(e -> {
52-
ChatView newChat = new ChatView(currentUsername, true);
53-
newChat.chatDisplay();
54-
});
51+
//TODO: add groupchat action
52+
// addGroupChat.addActionListener(e -> {
53+
// ChatView newChat = new ChatView(currentUsername, true);
54+
// newChat.chatDisplay();
55+
// });
5556

5657

5758
topPanel.add(addPrivateChat);
@@ -97,7 +98,7 @@ public void displayAppScreen(){
9798
// defines the action of opening a chat when a chat is clicked on
9899
b.addActionListener(e -> {
99100

100-
ChatView newChat = new ChatView(currentUsername, false);
101+
ChatView newChat = new ChatView(currentUsername, false, chatName);
101102
newChat.chatDisplay();
102103
});
103104
jPanel.add(b);

src/main/java/app_screen_interface_adapters/UserAppScreenGateway.java

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,38 +2,29 @@
22

33
import Interface_adapters.Login;
44
import entities.User;
5-
import data_access.UserDataBase;
6-
7-
8-
import java.io.File;
5+
import data_access.UserDatabase;
96
import java.util.ArrayList;
107

118
public class UserAppScreenGateway implements Login {
129

1310
private final UserDatabase userDatabase;
14-
private final File userAccounts;
15-
private String username;
11+
private final String username;
1612
private ArrayList<Chat> userChats;
1713

1814
/**
1915
* Create gateway between user and appscreen
2016
*/
2117
public UserAppScreenGateway(String username){
2218
this.username = username;
23-
24-
// should be given the path of the file
25-
this.userAccounts = new File("\data_access\UserAccounts.csv");
26-
27-
this.userDatabase = new UserDatabase(userAccounts);
19+
this.userDatabase = new UserDatabase();
2820
login();
2921
}
3022

31-
3223
/**
3324
* Log the user into the system
3425
*/
3526
public void login(){;
36-
this.userChats = userDatabase.getUserChats(this.username);
27+
this.userChats = this.userDatabase.getUserChats(this.username);
3728
AppScreenLoader appScreenLoader = new AppScreenLoader(this.username, this.userChats);
3829
}
3930

0 commit comments

Comments
 (0)