|  |  |  | @ -1,5 +1,19 @@ | 
		
	
		
			
				|  |  |  |  | import PromiseKit | 
		
	
		
			
				|  |  |  |  | 
 | 
		
	
		
			
				|  |  |  |  | // Helper function for objc apis | 
		
	
		
			
				|  |  |  |  | private extension Promise where T == Any { | 
		
	
		
			
				|  |  |  |  |     func recoverNetworkError(on queue: DispatchQueue) -> Promise<T> { | 
		
	
		
			
				|  |  |  |  |         return self.recover(on: queue) { error -> Promise<T> in | 
		
	
		
			
				|  |  |  |  |             switch error { | 
		
	
		
			
				|  |  |  |  |             case NetworkManagerError.taskError(_, let underlyingError): | 
		
	
		
			
				|  |  |  |  |                 throw underlyingError | 
		
	
		
			
				|  |  |  |  |             default: | 
		
	
		
			
				|  |  |  |  |                 throw error | 
		
	
		
			
				|  |  |  |  |             } | 
		
	
		
			
				|  |  |  |  |         } | 
		
	
		
			
				|  |  |  |  |     } | 
		
	
		
			
				|  |  |  |  | } | 
		
	
		
			
				|  |  |  |  | 
 | 
		
	
		
			
				|  |  |  |  | @objc public final class LokiAPI : NSObject { | 
		
	
		
			
				|  |  |  |  |      | 
		
	
		
			
				|  |  |  |  |     private static let version = "v1" | 
		
	
	
		
			
				
					|  |  |  | @ -68,13 +82,16 @@ import PromiseKit | 
		
	
		
			
				|  |  |  |  |     // MARK: Obj-C API | 
		
	
		
			
				|  |  |  |  |     @objc public static func objc_getMessages() -> AnyPromise { | 
		
	
		
			
				|  |  |  |  |         let promise = getMessages() | 
		
	
		
			
				|  |  |  |  |             .recoverNetworkError(on: DispatchQueue.global()) | 
		
	
		
			
				|  |  |  |  |         let anyPromise = AnyPromise(promise) | 
		
	
		
			
				|  |  |  |  |         anyPromise.retainUntilComplete() | 
		
	
		
			
				|  |  |  |  |         return anyPromise | 
		
	
		
			
				|  |  |  |  |     } | 
		
	
		
			
				|  |  |  |  |      | 
		
	
		
			
				|  |  |  |  |     @objc public static func objc_sendSignalMessage(_ signalMessage: SignalMessage, to destination: String, requiringPoW isPoWRequired: Bool) -> AnyPromise { | 
		
	
		
			
				|  |  |  |  |         let promise = LokiMessage.fromSignalMessage(signalMessage, requiringPoW: isPoWRequired).then(sendMessage) | 
		
	
		
			
				|  |  |  |  |         let promise = LokiMessage.fromSignalMessage(signalMessage, requiringPoW: isPoWRequired) | 
		
	
		
			
				|  |  |  |  |             .then(sendMessage) | 
		
	
		
			
				|  |  |  |  |             .recoverNetworkError(on: DispatchQueue.global()) | 
		
	
		
			
				|  |  |  |  |         let anyPromise = AnyPromise(promise) | 
		
	
		
			
				|  |  |  |  |         anyPromise.retainUntilComplete() | 
		
	
		
			
				|  |  |  |  |         return anyPromise | 
		
	
	
		
			
				
					|  |  |  | 
 |