From 942096ae5832cfea3c2229846010a480cfe496d6 Mon Sep 17 00:00:00 2001 From: Marco Eidinger Date: Tue, 27 Jul 2021 22:10:32 -0700 Subject: [PATCH] =?UTF-8?q?fix:=20=F0=9F=90=9B=20avoid=20"A=20server=20err?= =?UTF-8?q?or=20occurred"=20msgs=20related=20to=20polling?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Polling request might time out if app goes into background. New polling request will be started when app comes back into foreground. There is no reason to bother the enduser with messages related to polling. Hence, in this commit `PollMessageDelivery` will no longer emit error messages related to polling. --- .../Foundation/Networking/PollMessageDelivery.swift | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/Sources/SAPCAI/Foundation/Networking/PollMessageDelivery.swift b/Sources/SAPCAI/Foundation/Networking/PollMessageDelivery.swift index ebe98b1..b66e5c7 100644 --- a/Sources/SAPCAI/Foundation/Networking/PollMessageDelivery.swift +++ b/Sources/SAPCAI/Foundation/Networking/PollMessageDelivery.swift @@ -24,7 +24,11 @@ public class PollMessageDelivery: MessageDelivering { private var conversationId: String? - private var state: State = .stopped + private var state: State = .stopped { + didSet { + self.logger.debug("Polling \(state)") + } + } private var logger = Logger.shared(named: "PollMessageDelivery") @@ -100,16 +104,13 @@ public class PollMessageDelivery: MessageDelivering { } case .failure(let error): + self.logger.error(error.debugDescription, error: error) switch error.type { case .server: - self.logger.error(error.debugDescription, error: error) - self.onMessages?(.failure(error)) self.startPolling() case .cancelled: - () // this naturally occurs when bot responses early? + () case .dataDecoding, .conversationNotFound: - self.logger.error(error.debugDescription, error: error) - self.onMessages?(.failure(error)) self._stop() } }