Changed setting chat name in CREATE_CHAT message

This commit is contained in:
ChronosX88 2019-03-23 17:22:02 +04:00
parent 8e701da329
commit 6ee7223fcd
Signed by: ChronosXYZ
GPG Key ID: 085A69A82C8C511A

View File

@ -34,8 +34,8 @@ public class NetworkHandler implements NetworkObserver {
switch (getMessageAction((String) object)) { switch (getMessageAction((String) object)) {
case NetworkActions.CREATE_CHAT: { case NetworkActions.CREATE_CHAT: {
NewChatRequestMessage newChatRequestMessage = gson.fromJson((String) object, NewChatRequestMessage.class); NewChatRequestMessage newChatRequestMessage = gson.fromJson((String) object, NewChatRequestMessage.class);
createChatEntry(newChatRequestMessage.getChatID(), newChatRequestMessage.getChatID(), newChatRequestMessage.getSenderPeerAddress()); createChatEntry(newChatRequestMessage.getChatID(), newChatRequestMessage.getSenderID(), newChatRequestMessage.getSenderPeerAddress());
handleIncomingChat(newChatRequestMessage.getChatID(), newChatRequestMessage.getSenderPeerAddress()); handleIncomingChatRequest(newChatRequestMessage.getChatID(), newChatRequestMessage.getSenderPeerAddress());
JsonObject jsonObject = new JsonObject(); JsonObject jsonObject = new JsonObject();
jsonObject.addProperty("action", UIActions.NEW_CHAT); jsonObject.addProperty("action", UIActions.NEW_CHAT);
AppHelper.getObservable().notifyUIObservers(jsonObject); AppHelper.getObservable().notifyUIObservers(jsonObject);
@ -68,7 +68,7 @@ public class NetworkHandler implements NetworkObserver {
AppHelper.getChatDB().chatDao().addChat(new ChatEntity(chatID, name, "", Serializer.serialize(peerAddress))); AppHelper.getChatDB().chatDao().addChat(new ChatEntity(chatID, name, "", Serializer.serialize(peerAddress)));
} }
private void handleIncomingChat(String chatID, PeerAddress chatStarterAddress) { private void handleIncomingChatRequest(String chatID, PeerAddress chatStarterAddress) {
NewChatRequestMessage newChatRequestMessage = new NewChatRequestMessage(AppHelper.getPeerID(), peerDHT.peerAddress()); NewChatRequestMessage newChatRequestMessage = new NewChatRequestMessage(AppHelper.getPeerID(), peerDHT.peerAddress());
newChatRequestMessage.setChatID(chatID); newChatRequestMessage.setChatID(chatID);
newChatRequestMessage.setAction(NetworkActions.SUCCESSFULL_CREATE_CHAT); newChatRequestMessage.setAction(NetworkActions.SUCCESSFULL_CREATE_CHAT);