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 {
// 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)
......
......@@ -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"
......
......@@ -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 {
......
......@@ -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:
......
......@@ -33,7 +33,6 @@ enum ServiceEventType {
case knownDevicesChanged
case exportOnRingEnded
case contactAdded
case contactRequestSended
case contactRequestReceived
case contactRequestDiscarded
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