@@ -24,7 +24,7 @@ class EventHandler {
2424
2525 func handleEvents( events: [ [ String : Any ] ] , completion: @escaping ( _ result: EventData . Result ) -> Void ) {
2626 var result = EventData . Result ( )
27- var successfulEvents = [ Int32 ] ( )
27+ var successfulEvents = [ Any ] ( )
2828 let dispatchQueue = DispatchQueue ( label: " taskQueue " )
2929 let dispatchSemaphore = DispatchSemaphore ( value: 0 )
3030
@@ -48,11 +48,14 @@ class EventHandler {
4848 }
4949 }
5050
51- func handleEventResult( result: inout EventData . Result , successfulEvents: inout [ Int32 ] , _ successfulEventId : Int32 ? , _ eventResult: Event . EventResult ) {
51+ func handleEventResult( result: inout EventData . Result , successfulEvents: inout [ Any ] , _ successfulEventId : Any ? , _ eventResult: Event . EventResult ) {
52+
5253 guard let eventId = successfulEventId else {
5354 return
5455 }
56+
5557 successfulEvents. append ( eventId)
58+
5659 switch ( eventResult) {
5760 case . Email( let email) :
5861 result. emailLabels. append ( contentsOf: Array ( email. labels. map ( { $0. text} ) ) )
@@ -76,9 +79,10 @@ class EventHandler {
7679 }
7780 }
7881
79- func handleEvent( _ event: [ String : Any ] , finishCallback: @escaping ( _ successfulEventId : Int32 ? , _ data: Event . EventResult ) -> Void ) {
82+ func handleEvent( _ event: [ String : Any ] , finishCallback: @escaping ( _ successfulEventId : Any ? , _ data: Event . EventResult ) -> Void ) {
8083 let cmd = event [ " cmd " ] as! Int32
8184 let rowId = event [ " rowid " ] as? Int32 ?? - 1
85+ let docId = event [ " docid " ] as? String ?? nil
8286 guard let params = event [ " params " ] as? [ String : Any ] ?? Utils . convertToDictionary ( text: ( event [ " params " ] as! String ) ) else {
8387 finishCallback ( nil , . Empty)
8488 return
@@ -88,7 +92,11 @@ class EventHandler {
8892 finishCallback ( nil , . Empty)
8993 return
9094 }
91- finishCallback ( rowId, result)
95+ if ( docId != nil ) {
96+ finishCallback ( docId, result)
97+ } else {
98+ finishCallback ( rowId, result)
99+ }
92100 }
93101 DBManager . refresh ( )
94102 switch ( cmd) {
@@ -147,7 +155,11 @@ class EventHandler {
147155 }
148156 handleEventResponse ( successfulEvent: true , result: . LinkData( linkData) )
149157 case Event . Link. success. rawValue:
150- finishCallback ( rowId, . Empty)
158+ if ( docId != nil ) {
159+ finishCallback ( docId, . Empty)
160+ } else {
161+ finishCallback ( rowId, . Empty)
162+ }
151163 case Event . Acc. customerType. rawValue:
152164 handleAccountCustomerType ( params: params, finishCallback: handleEventResponse)
153165 case Event . Peer. addressCreated. rawValue:
0 commit comments