Commit a5206c6b authored by Kateryna Kostiuk's avatar Kateryna Kostiuk

UI/UX: fix file transfer view

This patch removes unnecessary info request when transfer status
updated, since the info could be unavailable after transfer finished.
Instead it takes status directly from status updated signal.

Change-Id: I5543921180d94d97fc4a92180101d6edf0f23307
parent 44cc2030
...@@ -90,26 +90,10 @@ class MessageViewModel { ...@@ -90,26 +90,10 @@ class MessageViewModel {
}) })
.subscribe(onNext: { [unowned self] transferEvent in .subscribe(onNext: { [unowned self] transferEvent in
guard let transferId: UInt64 = transferEvent.getEventInput(ServiceEventInput.transferId), guard let transferId: UInt64 = transferEvent.getEventInput(ServiceEventInput.transferId),
let transferInfo = self.dataTransferService.getTransferInfo(withId: transferId) else { let transferStatus: DataTransferStatus = transferEvent.getEventInput(ServiceEventInput.state) else {
self.log.error("MessageViewModel: can't find transferInfo")
return return
} }
self.log.debug("MessageViewModel: dataTransferMessageUpdated - id:\(transferId) status:\(stringFromEventCode(with: transferInfo.lastEvent))") self.log.debug("MessageViewModel: dataTransferMessageUpdated - id:\(transferId) status:\(transferStatus)")
var transferStatus: DataTransferStatus = .unknown
switch transferInfo.lastEvent {
case .closed_by_host, .closed_by_peer:
transferStatus = DataTransferStatus.canceled
case .invalid, .unsupported, .invalid_pathname, .unjoinable_peer:
transferStatus = DataTransferStatus.error
case .wait_peer_acceptance, .wait_host_acceptance:
transferStatus = DataTransferStatus.awaiting
case .ongoing:
transferStatus = DataTransferStatus.ongoing
case .finished:
transferStatus = DataTransferStatus.success
case .created:
transferStatus = DataTransferStatus.created
}
self.message.transferStatus = transferStatus self.message.transferStatus = transferStatus
self.transferStatus.onNext(transferStatus) self.transferStatus.onNext(transferStatus)
}) })
......
...@@ -437,6 +437,7 @@ class ConversationsService { ...@@ -437,6 +437,7 @@ class ConversationsService {
let serviceEventType: ServiceEventType = .dataTransferMessageUpdated let serviceEventType: ServiceEventType = .dataTransferMessageUpdated
var serviceEvent = ServiceEvent(withEventType: serviceEventType) var serviceEvent = ServiceEvent(withEventType: serviceEventType)
serviceEvent.addEventInput(.transferId, value: transferId) serviceEvent.addEventInput(.transferId, value: transferId)
serviceEvent.addEventInput(.state, value: transferStatus)
self.responseStream.onNext(serviceEvent) self.responseStream.onNext(serviceEvent)
}, onError: { _ in }, onError: { _ in
self.messagesSemaphore.signal() self.messagesSemaphore.signal()
......
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