diff --git a/Sources/CommonMain/Features/FeaturesViewModel.swift b/Sources/CommonMain/Features/FeaturesViewModel.swift index c582989..affe9b8 100644 --- a/Sources/CommonMain/Features/FeaturesViewModel.swift +++ b/Sources/CommonMain/Features/FeaturesViewModel.swift @@ -29,6 +29,12 @@ class FeaturesViewModel { self?.prepareFeaturesData(data: jsonData) } streamingUpdate.connect() + + streamingUpdate.onDissconnect { _, shouldReconnect, _ in + if let shouldReconnect = shouldReconnect, shouldReconnect { + streamingUpdate.connect() + } + } } /// Fetch Features diff --git a/Sources/CommonMain/Network/SSEHandler.swift b/Sources/CommonMain/Network/SSEHandler.swift index 57c7e1b..b54227a 100644 --- a/Sources/CommonMain/Network/SSEHandler.swift +++ b/Sources/CommonMain/Network/SSEHandler.swift @@ -161,7 +161,7 @@ extension SSEHandler { private func shouldReconnect(statusCode: Int) -> Bool { switch statusCode { case 200: - return false + return true case _ where statusCode > 200 && statusCode < 300: return true default: