From 369775fc3cd37afdce1def367b86e035e9f4893f Mon Sep 17 00:00:00 2001 From: Kateryna Kostiuk Date: Fri, 23 Feb 2018 11:43:28 -0500 Subject: [PATCH] conversation: hide add contact button This patch hides add contact button after contact was added, regardless of the contact status. Change-Id: If56bc362f1cfefb04453c92cab4ab035b3ad4a0f Reviewed-by: Andreas Traczyk --- .../Conversation/ConversationViewModel.swift | 6 ++---- .../Conversation/MessageViewModel.swift | 3 +-- Ring/Ring/Services/ContactsService.swift | 14 +++----------- .../Services/GeneratedInteractionsManager.swift | 12 +----------- Ring/Ring/Services/ServiceEvent.swift | 1 - 5 files changed, 7 insertions(+), 29 deletions(-) diff --git a/Ring/Ring/Features/Conversations/Conversation/ConversationViewModel.swift b/Ring/Ring/Features/Conversations/Conversation/ConversationViewModel.swift index 59272f4..0248b5e 100644 --- a/Ring/Ring/Features/Conversations/Conversation/ConversationViewModel.swift +++ b/Ring/Ring/Features/Conversations/Conversation/ConversationViewModel.swift @@ -100,8 +100,7 @@ class ConversationViewModel: Stateable, ViewModel { // invite and block buttons if let contact = contact { - let showInviteButton = !contact.confirmed && !contact.banned - self.inviteButtonIsAvailable.onNext(showInviteButton) + self.inviteButtonIsAvailable.onNext(false) self.blockButtonIsAvailable.onNext(!contact.banned) } @@ -109,8 +108,7 @@ class ConversationViewModel: Stateable, ViewModel { return cont.ringId == contactRingId }) .subscribe(onNext: { [unowned self] contact in - let showInviteButton = !contact.confirmed && !contact.banned - self.inviteButtonIsAvailable.onNext(showInviteButton) + self.inviteButtonIsAvailable.onNext(false) let isContact = self.contactsService.contact(withRingId: contact.ringId) != nil && !contact.banned self.blockButtonIsAvailable.onNext(isContact) }).disposed(by: self.disposeBag) diff --git a/Ring/Ring/Features/Conversations/Conversation/MessageViewModel.swift b/Ring/Ring/Features/Conversations/Conversation/MessageViewModel.swift index e0612a1..eea3a24 100644 --- a/Ring/Ring/Features/Conversations/Conversation/MessageViewModel.swift +++ b/Ring/Ring/Features/Conversations/Conversation/MessageViewModel.swift @@ -36,9 +36,8 @@ enum MessageSequencing { } enum GeneratedMessageType: String { - case sendContactRequest = "The invitation has been sent" case receivedContactRequest = "Contact request received" - case contactRequestAccepted = "Contact added" + case contactAdded = "Contact added" case missedIncomingCall = "Missed incoming call" case missedOutgoingCall = "Missed outgoing call" case incomingCall = "Incoming call" diff --git a/Ring/Ring/Services/ContactsService.swift b/Ring/Ring/Services/ContactsService.swift index 3bd740c..32fcef4 100644 --- a/Ring/Ring/Services/ContactsService.swift +++ b/Ring/Ring/Services/ContactsService.swift @@ -118,7 +118,6 @@ class ContactsService { status: ProfileStatus.trusted) var event = ServiceEvent(withEventType: .contactAdded) event.addEventInput(.accountId, value: account.id) - event.addEventInput(.state, value: true) event.addEventInput(.uri, value: contactRequest.ringId) self.responseStream.onNext(event) observable.on(.completed) @@ -160,7 +159,7 @@ class ContactsService { payload = try CNContactVCardSerialization.dataWithImageAndUUID(from: vCard, andImageCompression: 40000) } self.contactsAdapter.sendTrustRequest(toContact: ringId, payload: payload, withAccountId: account.id) - var event = ServiceEvent(withEventType: .contactRequestSended) + var event = ServiceEvent(withEventType: .contactAdded) event.addEventInput(.accountId, value: account.id) event.addEventInput(.uri, value: ringId) self.responseStream.onNext(event) @@ -208,7 +207,6 @@ class ContactsService { withAccount: account) .subscribe( onCompleted: { var event = ServiceEvent(withEventType: .contactAdded) - event.addEventInput(.state, value: contact.confirmed) event.addEventInput(.accountId, value: account.id) event.addEventInput(.uri, value: contact.ringId) self.responseStream.onNext(event) @@ -259,17 +257,11 @@ extension ContactsService: ContactsAdapterDelegate { self.removeContactRequest(withRingId: uri) // update contact status if let contact = self.contact(withRingId: uri) { + self.contactStatus.onNext(contact) if contact.confirmed != confirmed { contact.confirmed = confirmed - self.contactStatus.onNext(contact) - if confirmed { - var event = ServiceEvent(withEventType: .contactAdded) - event.addEventInput(.state, value: confirmed) - event.addEventInput(.accountId, value: accountId) - event.addEventInput(.uri, value: uri) - self.responseStream.onNext(event) - } } + self.contactStatus.onNext(contact) } //sync contacts with daemon contacts else { diff --git a/Ring/Ring/Services/GeneratedInteractionsManager.swift b/Ring/Ring/Services/GeneratedInteractionsManager.swift index ca27c3a..490637d 100644 --- a/Ring/Ring/Services/GeneratedInteractionsManager.swift +++ b/Ring/Ring/Services/GeneratedInteractionsManager.swift @@ -75,17 +75,7 @@ class GeneratedInteractionsManager { switch contactRequestEvent.eventType { case ServiceEventType.contactAdded: - - guard let contactConfirmed: Bool = contactRequestEvent.getEventInput(.state) else { - return - } - - if !contactConfirmed { - return - } - type = GeneratedMessageType.contactRequestAccepted - case ServiceEventType.contactRequestSended: - type = GeneratedMessageType.sendContactRequest + type = GeneratedMessageType.contactAdded case ServiceEventType.contactRequestReceived: type = GeneratedMessageType.receivedContactRequest case ServiceEventType.contactRequestDiscarded: diff --git a/Ring/Ring/Services/ServiceEvent.swift b/Ring/Ring/Services/ServiceEvent.swift index 2be3773..fe63151 100644 --- a/Ring/Ring/Services/ServiceEvent.swift +++ b/Ring/Ring/Services/ServiceEvent.swift @@ -33,7 +33,6 @@ enum ServiceEventType { case knownDevicesChanged case exportOnRingEnded case contactAdded - case contactRequestSended case contactRequestReceived case contactRequestDiscarded case proxyEnabled -- GitLab