Bugfixes: - Add toggle for offline mode simulation (DEBUG only) - Fix VPN false-positives with interface count check - Add detailed error logging for download failures - Fix last sync timestamp display - Translate all strings to English Network Monitoring: - Add NetworkMonitorRepository with NWPathMonitor - Check path.status AND availableInterfaces for reliability - Add manual reportConnectionFailure/Success methods - Auto-load cached bookmarks when offline - Visual debug banner (green=online, red=offline) Architecture: - Clean architecture with Repository → UseCase → ViewModel - Network status in AppSettings for global access - Combine publishers for reactive updates
59 lines
1.1 KiB
Swift
59 lines
1.1 KiB
Swift
//
|
|
// NetworkMonitorUseCase.swift
|
|
// readeck
|
|
//
|
|
// Created by Claude on 18.11.25.
|
|
//
|
|
|
|
import Foundation
|
|
import Combine
|
|
|
|
// MARK: - Protocol
|
|
|
|
protocol PNetworkMonitorUseCase {
|
|
var isConnected: AnyPublisher<Bool, Never> { get }
|
|
func startMonitoring()
|
|
func stopMonitoring()
|
|
func reportConnectionFailure()
|
|
func reportConnectionSuccess()
|
|
}
|
|
|
|
// MARK: - Implementation
|
|
|
|
final class NetworkMonitorUseCase: PNetworkMonitorUseCase {
|
|
|
|
// MARK: - Dependencies
|
|
|
|
private let repository: PNetworkMonitorRepository
|
|
|
|
// MARK: - Properties
|
|
|
|
var isConnected: AnyPublisher<Bool, Never> {
|
|
repository.isConnected
|
|
}
|
|
|
|
// MARK: - Initialization
|
|
|
|
init(repository: PNetworkMonitorRepository) {
|
|
self.repository = repository
|
|
}
|
|
|
|
// MARK: - Public Methods
|
|
|
|
func startMonitoring() {
|
|
repository.startMonitoring()
|
|
}
|
|
|
|
func stopMonitoring() {
|
|
repository.stopMonitoring()
|
|
}
|
|
|
|
func reportConnectionFailure() {
|
|
repository.reportConnectionFailure()
|
|
}
|
|
|
|
func reportConnectionSuccess() {
|
|
repository.reportConnectionSuccess()
|
|
}
|
|
}
|