Skip to content

Commit

Permalink
Reconnection Issue Fix to Prevent App from Being Stuck in a Waiting s…
Browse files Browse the repository at this point in the history
…tatus (#54)

* Adds waiting as a retriable state

* Hides the chat bubble for this hotfix

* Refactors Settings Screens to clean up navigation

* Handles case where the server sends back multiple O or OU entries

* Spelling correction for logger
  • Loading branch information
CoryFoy authored Mar 27, 2024
1 parent 59e2790 commit 4414652
Show file tree
Hide file tree
Showing 10 changed files with 110 additions and 39 deletions.
28 changes: 18 additions & 10 deletions TAKTracker.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
A50C5F5B2A5F92FF001E52E6 /* SettingsStore.swift in Sources */ = {isa = PBXBuildFile; fileRef = A50C5F5A2A5F92FF001E52E6 /* SettingsStore.swift */; };
A50C5F5D2A601CF0001E52E6 /* SettingsView.swift in Sources */ = {isa = PBXBuildFile; fileRef = A50C5F5C2A601CF0001E52E6 /* SettingsView.swift */; };
A50C5F5F2A6032D2001E52E6 /* EmergencyView.swift in Sources */ = {isa = PBXBuildFile; fileRef = A50C5F5E2A6032D2001E52E6 /* EmergencyView.swift */; };
A51B12EA2BB1E28800C25239 /* AdvancedOptions.swift in Sources */ = {isa = PBXBuildFile; fileRef = A51B12E92BB1E28800C25239 /* AdvancedOptions.swift */; };
A51B12EC2BB1E29800C25239 /* SituationalAwarenessOptions.swift in Sources */ = {isa = PBXBuildFile; fileRef = A51B12EB2BB1E29800C25239 /* SituationalAwarenessOptions.swift */; };
A54F70872AB0AEA400D8C541 /* DataPackageParserTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = A54F70862AB0AEA400D8C541 /* DataPackageParserTests.swift */; };
A54F70892AB0C40B00D8C541 /* TCPMessageTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = A54F70882AB0C40B00D8C541 /* TCPMessageTests.swift */; };
A54F708A2AB0C41100D8C541 /* TCPMessage.swift in Sources */ = {isa = PBXBuildFile; fileRef = A5BF02012A5EBCA40043065B /* TCPMessage.swift */; };
Expand Down Expand Up @@ -105,6 +107,8 @@
A50C5F5A2A5F92FF001E52E6 /* SettingsStore.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SettingsStore.swift; sourceTree = "<group>"; };
A50C5F5C2A601CF0001E52E6 /* SettingsView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SettingsView.swift; sourceTree = "<group>"; };
A50C5F5E2A6032D2001E52E6 /* EmergencyView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = EmergencyView.swift; sourceTree = "<group>"; };
A51B12E92BB1E28800C25239 /* AdvancedOptions.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AdvancedOptions.swift; sourceTree = "<group>"; };
A51B12EB2BB1E29800C25239 /* SituationalAwarenessOptions.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SituationalAwarenessOptions.swift; sourceTree = "<group>"; };
A54F70862AB0AEA400D8C541 /* DataPackageParserTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DataPackageParserTests.swift; sourceTree = "<group>"; };
A54F70882AB0C40B00D8C541 /* TCPMessageTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TCPMessageTests.swift; sourceTree = "<group>"; };
A5582CC22AD5CB4600DE0D5C /* TAKTrackerTestCase.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TAKTrackerTestCase.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -234,6 +238,8 @@
A55ABF4E2ABDC0A800195AB7 /* TAKOptions.swift */,
A55ABF502ABDC0E900195AB7 /* MapOptions.swift */,
A55ABF522ABDC11900195AB7 /* AboutInformation.swift */,
A51B12E92BB1E28800C25239 /* AdvancedOptions.swift */,
A51B12EB2BB1E29800C25239 /* SituationalAwarenessOptions.swift */,
);
path = SettingsScreens;
sourceTree = "<group>";
Expand Down Expand Up @@ -650,10 +656,12 @@
A5E7B0182A76AA8B00D9203F /* TAKLogger.swift in Sources */,
A508213F2AB3D19B00E0CBD8 /* TAKCAConfigResponseParser.swift in Sources */,
A55ABF492ABDC02200195AB7 /* ConnectionOptions.swift in Sources */,
A51B12EC2BB1E29800C25239 /* SituationalAwarenessOptions.swift in Sources */,
A5D8D3A82A53B465002F0E3E /* LocationManager.swift in Sources */,
A55ABF4D2ABDC08800195AB7 /* DeviceOptions.swift in Sources */,
A55CE96B2AB1D8860081AF86 /* Converter.swift in Sources */,
4630FD1C2B5071D200988ED4 /* MessageData.swift in Sources */,
A51B12EA2BB1E28800C25239 /* AdvancedOptions.swift in Sources */,
A55ABF472ABDBFEA00195AB7 /* ServerInformation.swift in Sources */,
A5BF02022A5EBCA40043065B /* TCPMessage.swift in Sources */,
A55ABF452ABDBF9A00195AB7 /* UserInformation.swift in Sources */,
Expand Down Expand Up @@ -841,9 +849,9 @@
ASSETCATALOG_COMPILER_INCLUDE_ALL_APPICON_ASSETS = YES;
CODE_SIGN_ENTITLEMENTS = TAKTracker/TAKTracker.entitlements;
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 58;
CURRENT_PROJECT_VERSION = 59;
DEVELOPMENT_ASSET_PATHS = "TAKTracker/Preview\\ Content";
DEVELOPMENT_TEAM = BCKVL9BZPW;
DEVELOPMENT_TEAM = 5LZ5HR44P3;
ENABLE_PREVIEWS = YES;
ENABLE_USER_SCRIPT_SANDBOXING = NO;
GENERATE_INFOPLIST_FILE = YES;
Expand All @@ -862,7 +870,7 @@
"$(inherited)",
"@executable_path/Frameworks",
);
MARKETING_VERSION = 1.1;
MARKETING_VERSION = 1.2;
PRODUCT_BUNDLE_IDENTIFIER = com.flighttactics.TAKTracker;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_EMIT_LOC_STRINGS = YES;
Expand All @@ -880,9 +888,9 @@
ASSETCATALOG_COMPILER_INCLUDE_ALL_APPICON_ASSETS = YES;
CODE_SIGN_ENTITLEMENTS = TAKTracker/TAKTracker.entitlements;
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 58;
CURRENT_PROJECT_VERSION = 59;
DEVELOPMENT_ASSET_PATHS = "TAKTracker/Preview\\ Content";
DEVELOPMENT_TEAM = BCKVL9BZPW;
DEVELOPMENT_TEAM = 5LZ5HR44P3;
ENABLE_PREVIEWS = YES;
ENABLE_USER_SCRIPT_SANDBOXING = NO;
GENERATE_INFOPLIST_FILE = YES;
Expand All @@ -901,7 +909,7 @@
"$(inherited)",
"@executable_path/Frameworks",
);
MARKETING_VERSION = 1.1;
MARKETING_VERSION = 1.2;
PRODUCT_BUNDLE_IDENTIFIER = com.flighttactics.TAKTracker;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_EMIT_LOC_STRINGS = YES;
Expand All @@ -917,7 +925,7 @@
ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES;
BUNDLE_LOADER = "$(TEST_HOST)";
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 58;
CURRENT_PROJECT_VERSION = 59;
DEVELOPMENT_TEAM = 5LZ5HR44P3;
ENABLE_USER_SCRIPT_SANDBOXING = NO;
GENERATE_INFOPLIST_FILE = YES;
Expand All @@ -939,7 +947,7 @@
ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES;
BUNDLE_LOADER = "$(TEST_HOST)";
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 58;
CURRENT_PROJECT_VERSION = 59;
DEVELOPMENT_TEAM = 5LZ5HR44P3;
ENABLE_USER_SCRIPT_SANDBOXING = NO;
GENERATE_INFOPLIST_FILE = YES;
Expand All @@ -959,7 +967,7 @@
buildSettings = {
ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES;
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 58;
CURRENT_PROJECT_VERSION = 59;
DEVELOPMENT_TEAM = 5LZ5HR44P3;
GENERATE_INFOPLIST_FILE = YES;
MARKETING_VERSION = 1.1;
Expand All @@ -977,7 +985,7 @@
buildSettings = {
ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES;
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 58;
CURRENT_PROJECT_VERSION = 59;
DEVELOPMENT_TEAM = 5LZ5HR44P3;
GENERATE_INFOPLIST_FILE = YES;
MARKETING_VERSION = 1.1;
Expand Down
3 changes: 2 additions & 1 deletion TAKTracker.xcworkspace/xcshareddata/swiftpm/Package.resolved
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
"originHash" : "fde2bb25a2ae91a7c7605521d48605d47226394f8d90d6636a7f3cb6288cdeec",
"pins" : [
{
"identity" : "certificatesigningrequest",
Expand Down Expand Up @@ -55,5 +56,5 @@
}
}
],
"version" : 2
"version" : 3
}
3 changes: 3 additions & 0 deletions TAKTracker/Communications/TCPMessage.swift
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,9 @@ class TCPMessage: NSObject, ObservableObject {
case .waiting:
TAKLogger.debug("[TCPMessage]: Entered state: waiting")
DispatchQueue.main.async {
SettingsStore.global.isConnectedToServer = false
SettingsStore.global.shouldTryReconnect = true
SettingsStore.global.isConnectingToServer = false
SettingsStore.global.connectionStatus = ConnectionStatus.Waiting.description
}
case .failed:
Expand Down
7 changes: 6 additions & 1 deletion TAKTracker/Parsers/TAKCAConfigResponseParser.swift
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,12 @@ class TAKCAConfigResponseParser: NSObject, XMLParserDelegate {
if(elementName == "nameEntry") {
if let nameVal = attributeDict["name"],
let valueVal = attributeDict["value"] {
nameEntries[nameVal] = valueVal
// Only ever take the first value coming back
if(!nameEntries.keys.contains(nameVal)) {
nameEntries[nameVal] = valueVal
} else {
TAKLogger.info("[TAKConfigResponseParser]: Multiple entries received for \(nameVal), only using first")
}
}
}

Expand Down
13 changes: 5 additions & 8 deletions TAKTracker/Screens/MainScreen.swift
Original file line number Diff line number Diff line change
Expand Up @@ -255,14 +255,11 @@ struct MainScreen: View {
.imageScale(.large)
.foregroundColor(settingsStore.isAlertActivated ? .red : .white)
}
Spacer()

Button(action: { sheet = .chat }) {
Image(systemName: "bubble.left")
.imageScale(.large)
.foregroundColor(.white)
}
Spacer()
// Button(action: { sheet = .chat }) {
// Image(systemName: "bubble.left")
// .imageScale(.large)
// .foregroundColor(.white)
// }

Button(action: { sheet = .settings }) {
Image(systemName: "gear")
Expand Down
23 changes: 13 additions & 10 deletions TAKTracker/Screens/SettingsScreens/AboutInformation.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,19 @@ import SwiftUI

struct SwiftTAK: View {
var body: some View {
Text("""
SwiftTAK Copyright 2023 Flight Tactics
List{
Text("""
SwiftTAK Copyright 2023 Flight Tactics
https://github.com/flighttactics/SwiftTAK
https://github.com/flighttactics/SwiftTAK
Licensed under the Apache License, Version 2.0 (the 'License'); you may not use this file except in compliance with the License. You may obtain a copy of the License at
Licensed under the Apache License, Version 2.0 (the 'License'); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an 'AS IS' BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
""").padding([.leading, .trailing], 12)
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an 'AS IS' BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
""").padding([.leading, .trailing], 12)
}
}
}

Expand All @@ -38,19 +40,20 @@ struct TAKTrackerInfo: View {
NavigationLink(destination: SwiftTAK()) {
Text("SwiftTAK")
}
.navigationBarTitleDisplayMode(.inline)
}
}
}

struct AboutInformation: View {
var body: some View {
Group {
Text("TAK Tracker v\(AppConstants.getAppVersion())")
.frame(maxWidth: .infinity, alignment: .center)
.foregroundColor(.secondary)
NavigationLink(destination: TAKTrackerInfo()) {
Text("About")
}
Text("TAK Tracker v\(AppConstants.getAppVersion())")
.frame(maxWidth: .infinity, alignment: .center)
.foregroundColor(.secondary)
}
}
}
4 changes: 2 additions & 2 deletions TAKTracker/Screens/SettingsScreens/AdvancedModeToggle.swift
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,13 @@ struct AdvancedModeToggle: View {
Group {
VStack {
HStack {
Text("Enable Advanced Mode")
Text("Enable Map Display")
.font(.system(size: 18, weight: .medium))
.foregroundColor(.secondary)
Spacer()
}

Picker(selection: $settingsStore.enableAdvancedMode, label: Text("Advanced Mode"), content: {
Picker(selection: $settingsStore.enableAdvancedMode, label: Text("Map Display"), content: {
Text("On").tag(true)
Text("Off").tag(false)
})
Expand Down
27 changes: 27 additions & 0 deletions TAKTracker/Screens/SettingsScreens/AdvancedOptions.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
//
// AdvancedOptions.swift
// TAKTracker
//
// Created by Cory Foy on 3/25/24.
//

import Foundation
import SwiftUI

struct AdvancedOptions: View {
var body: some View {
NavigationLink(destination: AdvancedOptionsScreen()) {
Text("Advanced Options")
}
.navigationBarTitleDisplayMode(.inline)
}
}

struct AdvancedOptionsScreen: View {
var body: some View {
List {
DeviceOptions()
TAKOptions()
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
//
// SituationalAwarenessOptions.swift
// TAKTracker
//
// Created by Cory Foy on 3/25/24.
//

import Foundation
import SwiftUI

struct SituationalAwarenessOptions: View {
var body: some View {
NavigationLink(destination: SituationalAwarenessScreen()) {
Text("Situational Awareness")
}
.navigationBarTitleDisplayMode(.inline)
}
}

struct SituationalAwarenessScreen: View {
@Environment(\.dismiss) var dismiss
@StateObject var settingsStore: SettingsStore = SettingsStore.global

var body: some View {
List {
AdvancedModeToggle()
if(settingsStore.enableAdvancedMode) {
MapOptions()
}
}
}
}
9 changes: 2 additions & 7 deletions TAKTracker/Screens/SettingsView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,8 @@ struct SettingsView: View {
UserInformation()
ServerInformation()
ConnectionOptions(isProcessingDataPackage: $isProcessingDataPackage)
DeviceOptions()
AdvancedModeToggle()

if(settingsStore.enableAdvancedMode) {
MapOptions()
TAKOptions()
}
SituationalAwarenessOptions()
AdvancedOptions()
AboutInformation()
}
.navigationBarTitle("Settings")
Expand Down

0 comments on commit 4414652

Please sign in to comment.