Commit 369775fc authored by Kateryna Kostiuk's avatar Kateryna Kostiuk Committed by Andreas Traczyk

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's avatarAndreas Traczyk <andreas.traczyk@savoirfairelinux.com>
parent cd3bc60d
...@@ -100,8 +100,7 @@ class ConversationViewModel: Stateable, ViewModel { ...@@ -100,8 +100,7 @@ class ConversationViewModel: Stateable, ViewModel {
// invite and block buttons // invite and block buttons
if let contact = contact { if let contact = contact {
let showInviteButton = !contact.confirmed && !contact.banned self.inviteButtonIsAvailable.onNext(false)
self.inviteButtonIsAvailable.onNext(showInviteButton)
self.blockButtonIsAvailable.onNext(!contact.banned) self.blockButtonIsAvailable.onNext(!contact.banned)
} }
...@@ -109,8 +108,7 @@ class ConversationViewModel: Stateable, ViewModel { ...@@ -109,8 +108,7 @@ class ConversationViewModel: Stateable, ViewModel {
return cont.ringId == contactRingId return cont.ringId == contactRingId
}) })
.subscribe(onNext: { [unowned self] contact in .subscribe(onNext: { [unowned self] contact in
let showInviteButton = !contact.confirmed && !contact.banned self.inviteButtonIsAvailable.onNext(false)
self.inviteButtonIsAvailable.onNext(showInviteButton)
let isContact = self.contactsService.contact(withRingId: contact.ringId) != nil && !contact.banned let isContact = self.contactsService.contact(withRingId: contact.ringId) != nil && !contact.banned
self.blockButtonIsAvailable.onNext(isContact) self.blockButtonIsAvailable.onNext(isContact)
}).disposed(by: self.disposeBag) }).disposed(by: self.disposeBag)
......
...@@ -36,9 +36,8 @@ enum MessageSequencing { ...@@ -36,9 +36,8 @@ enum MessageSequencing {
} }
enum GeneratedMessageType: String { enum GeneratedMessageType: String {
case sendContactRequest = "The invitation has been sent"
case receivedContactRequest = "Contact request received" case receivedContactRequest = "Contact request received"
case contactRequestAccepted = "Contact added" case contactAdded = "Contact added"
case missedIncomingCall = "Missed incoming call" case missedIncomingCall = "Missed incoming call"
case missedOutgoingCall = "Missed outgoing call" case missedOutgoingCall = "Missed outgoing call"
case incomingCall = "Incoming call" case incomingCall = "Incoming call"
......
...@@ -118,7 +118,6 @@ class ContactsService { ...@@ -118,7 +118,6 @@ class ContactsService {
status: ProfileStatus.trusted) status: ProfileStatus.trusted)
var event = ServiceEvent(withEventType: .contactAdded) var event = ServiceEvent(withEventType: .contactAdded)
event.addEventInput(.accountId, value: account.id) event.addEventInput(.accountId, value: account.id)
event.addEventInput(.state, value: true)
event.addEventInput(.uri, value: contactRequest.ringId) event.addEventInput(.uri, value: contactRequest.ringId)
self.responseStream.onNext(event) self.responseStream.onNext(event)
observable.on(.completed) observable.on(.completed)
...@@ -160,7 +159,7 @@ class ContactsService { ...@@ -160,7 +159,7 @@ class ContactsService {
payload = try CNContactVCardSerialization.dataWithImageAndUUID(from: vCard, andImageCompression: 40000) payload = try CNContactVCardSerialization.dataWithImageAndUUID(from: vCard, andImageCompression: 40000)
} }
self.contactsAdapter.sendTrustRequest(toContact: ringId, payload: payload, withAccountId: account.id) 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(.accountId, value: account.id)
event.addEventInput(.uri, value: ringId) event.addEventInput(.uri, value: ringId)
self.responseStream.onNext(event) self.responseStream.onNext(event)
...@@ -208,7 +207,6 @@ class ContactsService { ...@@ -208,7 +207,6 @@ class ContactsService {
withAccount: account) withAccount: account)
.subscribe( onCompleted: { .subscribe( onCompleted: {
var event = ServiceEvent(withEventType: .contactAdded) var event = ServiceEvent(withEventType: .contactAdded)
event.addEventInput(.state, value: contact.confirmed)
event.addEventInput(.accountId, value: account.id) event.addEventInput(.accountId, value: account.id)
event.addEventInput(.uri, value: contact.ringId) event.addEventInput(.uri, value: contact.ringId)
self.responseStream.onNext(event) self.responseStream.onNext(event)
...@@ -259,17 +257,11 @@ extension ContactsService: ContactsAdapterDelegate { ...@@ -259,17 +257,11 @@ extension ContactsService: ContactsAdapterDelegate {
self.removeContactRequest(withRingId: uri) self.removeContactRequest(withRingId: uri)
// update contact status // update contact status
if let contact = self.contact(withRingId: uri) { if let contact = self.contact(withRingId: uri) {
self.contactStatus.onNext(contact)
if contact.confirmed != confirmed { if contact.confirmed != confirmed {
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 //sync contacts with daemon contacts
else { else {
......
...@@ -75,17 +75,7 @@ class GeneratedInteractionsManager { ...@@ -75,17 +75,7 @@ class GeneratedInteractionsManager {
switch contactRequestEvent.eventType { switch contactRequestEvent.eventType {
case ServiceEventType.contactAdded: case ServiceEventType.contactAdded:
type = GeneratedMessageType.contactAdded
guard let contactConfirmed: Bool = contactRequestEvent.getEventInput(.state) else {
return
}
if !contactConfirmed {
return
}
type = GeneratedMessageType.contactRequestAccepted
case ServiceEventType.contactRequestSended:
type = GeneratedMessageType.sendContactRequest
case ServiceEventType.contactRequestReceived: case ServiceEventType.contactRequestReceived:
type = GeneratedMessageType.receivedContactRequest type = GeneratedMessageType.receivedContactRequest
case ServiceEventType.contactRequestDiscarded: case ServiceEventType.contactRequestDiscarded:
......
...@@ -33,7 +33,6 @@ enum ServiceEventType { ...@@ -33,7 +33,6 @@ enum ServiceEventType {
case knownDevicesChanged case knownDevicesChanged
case exportOnRingEnded case exportOnRingEnded
case contactAdded case contactAdded
case contactRequestSended
case contactRequestReceived case contactRequestReceived
case contactRequestDiscarded case contactRequestDiscarded
case proxyEnabled case proxyEnabled
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment