Renamed database package to data, moved Chat to data package
This commit is contained in:
		| @@ -1,4 +1,4 @@ | ||||
| package envoy.client; | ||||
| package envoy.client.data; | ||||
| 
 | ||||
| import java.io.IOException; | ||||
| import java.io.Serializable; | ||||
| @@ -1,8 +1,7 @@ | ||||
| package envoy.client.database; | ||||
| package envoy.client.data; | ||||
| 
 | ||||
| import java.util.*; | ||||
| 
 | ||||
| import envoy.client.Chat; | ||||
| import envoy.data.IdGenerator; | ||||
| import envoy.data.User; | ||||
| 
 | ||||
| @@ -1,4 +1,4 @@ | ||||
| package envoy.client.database; | ||||
| package envoy.client.data; | ||||
| 
 | ||||
| import java.io.File; | ||||
| import java.io.IOException; | ||||
| @@ -1,4 +1,4 @@ | ||||
| package envoy.client.database; | ||||
| package envoy.client.data; | ||||
| 
 | ||||
| /** | ||||
|  * Implements a {@link LocalDb} in a way that does not persist any information | ||||
| @@ -10,7 +10,7 @@ import java.util.logging.Logger; | ||||
| import javax.naming.TimeLimitExceededException; | ||||
|  | ||||
| import envoy.client.Config; | ||||
| import envoy.client.database.LocalDb; | ||||
| import envoy.client.data.LocalDb; | ||||
| import envoy.client.util.EnvoyLog; | ||||
| import envoy.data.*; | ||||
| import envoy.event.Event; | ||||
|   | ||||
| @@ -10,9 +10,9 @@ import java.util.logging.Logger; | ||||
| import javax.swing.*; | ||||
| import javax.swing.border.EmptyBorder; | ||||
|  | ||||
| import envoy.client.Chat; | ||||
| import envoy.client.Settings; | ||||
| import envoy.client.database.LocalDb; | ||||
| import envoy.client.data.Chat; | ||||
| import envoy.client.data.LocalDb; | ||||
| import envoy.client.event.MessageCreationEvent; | ||||
| import envoy.client.event.ThemeChangeEvent; | ||||
| import envoy.client.net.Client; | ||||
| @@ -175,13 +175,8 @@ public class ChatWindow extends JFrame { | ||||
| 				// Select current chat | ||||
| 				currentChat = localDb.getChats().stream().filter(chat -> chat.getRecipient().getId() == user.getId()).findFirst().get(); | ||||
|  | ||||
| 				// Read current Chat | ||||
| 				try { | ||||
| 					currentChat.read(client); | ||||
| 				} catch (IOException e) { | ||||
| 					e.printStackTrace(); | ||||
| 					logger.log(Level.WARNING, "Could notify server about message status change", e); | ||||
| 				} | ||||
| 				// Read current chat | ||||
| 				readCurrentChat(); | ||||
|  | ||||
| 				// Set chat title | ||||
| 				textPane.setText(currentChat.getRecipient().getName()); | ||||
| @@ -221,15 +216,7 @@ public class ChatWindow extends JFrame { | ||||
| 			chat.appendMessage(message); | ||||
|  | ||||
| 			// Read message and update UI if in current chat | ||||
| 			if (chat == currentChat) { | ||||
| 				try { | ||||
| 					currentChat.read(client); | ||||
| 				} catch (IOException e) { | ||||
| 					e.printStackTrace(); | ||||
| 					logger.log(Level.WARNING, "Could notify server about message status change", e); | ||||
| 				} | ||||
| 				messageList.synchronizeModel(); | ||||
| 			} | ||||
| 			if (chat == currentChat) readCurrentChat(); | ||||
|  | ||||
| 			revalidate(); | ||||
| 			repaint(); | ||||
| @@ -356,6 +343,16 @@ public class ChatWindow extends JFrame { | ||||
| 		}).start(); | ||||
| 	} | ||||
|  | ||||
| 	private void readCurrentChat() { | ||||
| 		try { | ||||
| 			currentChat.read(client); | ||||
| 			messageList.synchronizeModel(); | ||||
| 		} catch (IOException e) { | ||||
| 			e.printStackTrace(); | ||||
| 			logger.log(Level.WARNING, "Couldn't notify server about message status change", e); | ||||
| 		} | ||||
| 	} | ||||
|  | ||||
| 	/** | ||||
| 	 * Sets the {@link Client} used by this {@link ChatWindow}. | ||||
| 	 * | ||||
|   | ||||
| @@ -13,9 +13,9 @@ import javax.swing.SwingUtilities; | ||||
|  | ||||
| import envoy.client.Config; | ||||
| import envoy.client.Settings; | ||||
| import envoy.client.database.LocalDb; | ||||
| import envoy.client.database.PersistentLocalDb; | ||||
| import envoy.client.database.TransientLocalDb; | ||||
| import envoy.client.data.LocalDb; | ||||
| import envoy.client.data.PersistentLocalDb; | ||||
| import envoy.client.data.TransientLocalDb; | ||||
| import envoy.client.net.Client; | ||||
| import envoy.client.net.MessageCache; | ||||
| import envoy.client.util.EnvoyLog; | ||||
|   | ||||
		Reference in New Issue
	
	Block a user