parent
73eb312a90
commit
eadccd7126
@ -137,10 +137,7 @@ public class LocalDB {
|
||||
public Sync fillSync(long userId) {
|
||||
addWaitingMessagesToSync();
|
||||
|
||||
getSentStateMessagesFromLocalDB();
|
||||
for (int i = 0; i < readMessages.getMessages().size(); i++) {
|
||||
sync.getMessages().add(readMessages.getMessages().get(i));
|
||||
}
|
||||
sync.getMessages().addAll(readMessages.getMessages());
|
||||
readMessages.getMessages().clear();
|
||||
|
||||
System.out.println(sync.getMessages().size());
|
||||
@ -230,14 +227,6 @@ public class LocalDB {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a message to the "sync" Sync object.
|
||||
*
|
||||
* @param message
|
||||
* @since Envoy v0.1-alpha
|
||||
*/
|
||||
private void addMessageToSync(Message message) { sync.getMessages().add(message); }
|
||||
|
||||
/**
|
||||
* Adds the unread messages returned from the server in the latest sync to the
|
||||
* right chats in the LocalDB.
|
||||
@ -254,23 +243,6 @@ public class LocalDB {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets all messages with state {@code SENT} from the LocalDB and adds them to
|
||||
* the {@code sync} {@link Sync} object.
|
||||
*
|
||||
* @param localDB
|
||||
* @since Envoy v0.1-alpha
|
||||
*/
|
||||
private void getSentStateMessagesFromLocalDB() {
|
||||
for (int i = 0; i < getChats().size(); i++) {
|
||||
for (int j = 0; j < getChats().get(i).getModel().getSize(); j++) {
|
||||
if (getChats().get(i).getModel().get(j).getMetadata().getState() == MessageState.SENT) {
|
||||
addMessageToSync(getChats().get(i).getModel().get(j));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Changes all messages with state {@code RECEIVED} of a specific chat to state
|
||||
* {@code READ}.
|
||||
@ -299,21 +271,18 @@ public class LocalDB {
|
||||
public void addWaitingMessageToLocalDB(Message message, Chat currentChat) { currentChat.appendMessage(message); }
|
||||
|
||||
/**
|
||||
* Adds all messages with State WAITING from the {@link LocalDB} to the Sync.
|
||||
* Adds all messages with state {@code WAITING} from the {@link LocalDB} to the
|
||||
* {@link Sync} object.
|
||||
*
|
||||
* @param localDB
|
||||
* @since Envoy v0.1-alpha
|
||||
*/
|
||||
private void addWaitingMessagesToSync() {
|
||||
for (int i = 0; i < getChats().size(); i++) {
|
||||
for (int j = 0; j < getChats().get(i).getModel().getSize(); j++) {
|
||||
if (getChats().get(i).getModel().get(j).getMetadata().getState() == MessageState.WAITING) {
|
||||
// addMessageToSync(localDB.getChats().get(i).getModel().get(j));
|
||||
for (Chat chat : getChats())
|
||||
for (int i = 0; i < chat.getModel().size(); i++)
|
||||
if (chat.getModel().get(i).getMetadata().getState() == MessageState.WAITING) {
|
||||
System.out.println("Got Waiting Message");
|
||||
sync.getMessages().add(0, getChats().get(i).getModel().get(j));
|
||||
sync.getMessages().add(chat.getModel().get(i));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -306,7 +306,8 @@ public class ChatWindow extends JFrame {
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates the data model and the ui every x seconds.
|
||||
* Updates the data model and the UI every repeatedly after a certain amount of
|
||||
* time.
|
||||
*
|
||||
* @param timeout the amount of time that passes between two requests sent to
|
||||
* the server
|
||||
|
Reference in New Issue
Block a user