@@ -51,7 +51,7 @@ public AppScreen(String currentUsername, ArrayList<Chat> chats) {
51
51
52
52
// adding the action listeners for the +private-chat and +group-chat buttons
53
53
addPrivateChat .addActionListener (e -> {
54
- PrivateChatfactory privateChatfactory = ( PrivateChatfactory ) new CommonPrivatechat ();
54
+ PrivateChatfactory privateChatfactory = new CommonPrivatechat ();
55
55
ChatInputBoundry inputBoundry = new ChatInteractor (privateChatfactory );
56
56
ChatController controller = new ChatController (inputBoundry );
57
57
new ChatView (controller , true );
@@ -165,32 +165,14 @@ public void updateChatOrder(Chat chat){
165
165
166
166
}
167
167
168
- /**
169
- * Add a new chat to the screen, if the chat already exists (i.e. there exists a chat with the
170
- * same ID, do nothing)
171
- * @param chat The new chat to be added
172
- */
173
- public void addNewChat (Chat chat ){
174
-
175
- if (!(this .chats .contains (chat ))){
176
- updateChatOrder (chat );
177
- jFrame .remove (this .jScrollPane );
178
- createGateway ();
179
-
180
- // refresh the screen
181
- displayAppScreen ();
182
-
183
- }
184
- }
185
-
186
168
/**
187
169
* Update the order of chats that appear on screen if there was a change to conversation history
188
- * This should not be called if chatID is not an ID of an existing chat that the current user has
189
- * @param chatID The ID of the given chat
170
+ * This should be called if a new chat was added or if an existing chat has a new message
171
+ * @param chat The chat with an update
190
172
*/
191
173
@ Override
192
- public void updateScreen (String chatID ) {
193
- updateChatOrder (getChat ( chatID ) );
174
+ public void updateScreen (Chat chat ) {
175
+ updateChatOrder (chat );
194
176
jFrame .remove (this .jScrollPane );
195
177
createGateway ();
196
178
0 commit comments