From 3ece9f0110aa5e2e46bfcc807209a70598eb97ca Mon Sep 17 00:00:00 2001 From: Dan Cunningham Date: Tue, 17 Sep 2024 19:54:20 -0700 Subject: [PATCH] Make sure to support demo mode when initing the tracker Signed-off-by: Dan Cunningham --- openHAB/OpenHABRootViewController.swift | 34 ++++++++++++++++--------- 1 file changed, 22 insertions(+), 12 deletions(-) diff --git a/openHAB/OpenHABRootViewController.swift b/openHAB/OpenHABRootViewController.swift index 8412fe23..30a83f1a 100644 --- a/openHAB/OpenHABRootViewController.swift +++ b/openHAB/OpenHABRootViewController.swift @@ -120,20 +120,30 @@ class OpenHABRootViewController: UIViewController { } fileprivate func setupTracker() { - Publishers.CombineLatest( + Publishers.CombineLatest3( Preferences.$localUrl, - Preferences.$remoteUrl + Preferences.$remoteUrl, + Preferences.$demomode ) - .sink { (localUrl, remoteUrl) in - let connection1 = ConnectionObject( - url: localUrl, - priority: 0 - ) - let connection2 = ConnectionObject( - url: remoteUrl, - priority: 1 - ) - NetworkTracker.shared.startTracking(connectionObjects: [connection1, connection2]) + .sink { (localUrl, remoteUrl, demomode) in + if demomode { + NetworkTracker.shared.startTracking(connectionObjects: [ + ConnectionObject( + url: "https://demo.openhab.org", + priority: 0 + ) + ]) + } else { + let connection1 = ConnectionObject( + url: localUrl, + priority: 0 + ) + let connection2 = ConnectionObject( + url: remoteUrl, + priority: 1 + ) + NetworkTracker.shared.startTracking(connectionObjects: [connection1, connection2]) + } } .store(in: &cancellables)