Skip to content

Commit c3bc4ab

Browse files
authored
Merge pull request #296 from TaskarCenterAtUW/Bug-fixes
Bug fixes
2 parents 15656f8 + 591d1c3 commit c3bc4ab

File tree

17 files changed

+61
-46
lines changed

17 files changed

+61
-46
lines changed

GoInfoGame/GoInfoGame/AppDelegate.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
6969
DispatchQueue.main.async {
7070
Utilities.clearAllData()
7171
if let window = UIApplication.window() {
72-
window.rootViewController = UIHostingController(rootView: PosmLoginView())
72+
window.rootViewController = UIHostingController(rootView: PosmLoginView(forceUpdateManager: ForceUpdateManager()))
7373
}
7474
}
7575
}

GoInfoGame/GoInfoGame/GoInfoGame.entitlements

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@
44
<dict>
55
<key>com.apple.developer.associated-domains</key>
66
<array>
7-
<string>applinks:www.srikanthvoonna.co.in</string>
8-
<string>applinks:srikanthvoonna.co.in</string>
97
<string>applinks:portal-dev.tdei.us</string>
8+
<string>applinks:portal-stage.tdei.us</string>
9+
<string>applinks:portal.tdei.us</string>
1010
</array>
1111
</dict>
1212
</plist>

GoInfoGame/GoInfoGame/Helpers/Extensions.swift

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -215,3 +215,16 @@ extension URLRequest {
215215
}
216216
}
217217
}
218+
219+
extension View {
220+
@ViewBuilder
221+
func applyPresentationSizingPage() -> some View {
222+
if #available(iOS 18.0, *) {
223+
self.presentationSizing(.page)
224+
} else {
225+
// No-op for older OS, letting the default sizing apply.
226+
// You can add a fallback here if needed, e.g., using detents.
227+
self
228+
}
229+
}
230+
}

GoInfoGame/GoInfoGame/Helpers/Utils.swift

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,6 @@ struct Utilities {
4343
// _ = KeychainManager.delete(key: "username")
4444
loggedIn = false
4545
UserProfileCache.shared.clearUserProfile()
46-
if let bundleID = Bundle.main.bundleIdentifier {
47-
UserDefaults.standard.removePersistentDomain(forName: bundleID)
48-
}
46+
UserDefaults.standard.removeObject(forKey: APIConfiguration.environmentKey)
4947
}
5048
}

GoInfoGame/GoInfoGame/Login/View/PosmLogin.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ struct PosmLoginView: View {
2222
@State private var showDisableDebugModeAlert: Bool = false
2323
let forceUpdateManager: ForceUpdateManager?
2424

25-
init(forceUpdateManager: ForceUpdateManager? = nil) {
25+
init(forceUpdateManager: ForceUpdateManager?) {
2626
self.forceUpdateManager = forceUpdateManager
2727
APIConfiguration.shared.environment = .production
2828
}
@@ -233,5 +233,5 @@ struct PosmLoginView: View {
233233
}
234234

235235
#Preview {
236-
PosmLoginView()
236+
PosmLoginView(forceUpdateManager: nil)
237237
}

GoInfoGame/GoInfoGame/Network/APIConfiguration.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,18 +10,18 @@ import Foundation
1010
class APIConfiguration {
1111
static let shared = APIConfiguration()
1212

13-
private let environmentKey = "APIEnvironment"
13+
static let environmentKey = "APIEnvironment"
1414

1515
var environment: APIEnvironment {
1616
get {
17-
if let savedValue = UserDefaults.standard.string(forKey: environmentKey),
17+
if let savedValue = UserDefaults.standard.string(forKey: APIConfiguration.environmentKey),
1818
let savedEnvironment = APIEnvironment(rawValue: savedValue) {
1919
return savedEnvironment
2020
}
2121
return .production // default value
2222
}
2323
set {
24-
UserDefaults.standard.set(newValue.rawValue, forKey: environmentKey)
24+
UserDefaults.standard.set(newValue.rawValue, forKey: APIConfiguration.environmentKey)
2525
}
2626
}
2727

GoInfoGame/GoInfoGame/Network/APIHandler/NetworkManager.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ class NetworkManager: NetworkHandler {
131131
DispatchQueue.main.async {
132132
if let window = UIApplication.window() {
133133
Utilities.clearAllData()
134-
window.rootViewController = UIHostingController(rootView: PosmLoginView())
134+
window.rootViewController = UIHostingController(rootView: PosmLoginView(forceUpdateManager: ForceUpdateManager()))
135135
DispatchQueue.main.asyncAfter(deadline: .now() + 1) {
136136
NotificationCenter.default.post(name: Notification.Name("SessionExpired"), object: nil)
137137
}

GoInfoGame/GoInfoGame/Network/ApiManager.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ class ApiManager {
164164
DispatchQueue.main.async {
165165
if let window = UIApplication.window() {
166166
Utilities.clearAllData()
167-
window.rootViewController = UIHostingController(rootView: PosmLoginView())
167+
window.rootViewController = UIHostingController(rootView: PosmLoginView(forceUpdateManager: ForceUpdateManager()))
168168
DispatchQueue.main.asyncAfter(deadline: .now() + 1) {
169169
NotificationCenter.default.post(name: Notification.Name("SessionExpired"), object: nil)
170170
}

GoInfoGame/GoInfoGame/UI/InitialView/InitialView.swift

Lines changed: 18 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -76,33 +76,26 @@ struct WorkspacesListView: View {
7676
@State private var showAlert = false
7777

7878
@State private var alertMessage = ""
79+
@State private var autoRedirectToMapViewError: String?
7980

8081
var body: some View {
8182

82-
if viewModel.workspaces?.count == 1 {
83-
if let selectedWorkspace = viewModel.workspaces?.first {
84-
VStack {
85-
if !shouldNavigateToMapView {
86-
ActivityView(activityText: "Fetching workspace data...")
87-
Spacer()
88-
}
89-
}
90-
.onAppear {
91-
viewModel.fetchLongQuestsFor(workspaceId: "\(selectedWorkspace.id)") { success, errorMessage in
92-
if success {
93-
self.selectedWorkspace = selectedWorkspace
94-
let workspaceId = "\(selectedWorkspace.id)"
95-
_ = KeychainManager.save(key: "workspaceID", data: workspaceId)
96-
DispatchQueue.main.async {
97-
shouldNavigateToMapView = true
98-
}
99-
} else {
100-
DispatchQueue.main.async {
101-
alertMessage = errorMessage ?? "Something went wrong. Please pick another workspace."
102-
showAlert = true
103-
shouldNavigateToMapView = false
104-
}
83+
if viewModel.workspaces?.count == 1,
84+
let selectedWorkspace = viewModel.workspaces?.first,
85+
autoRedirectToMapViewError == nil {
86+
VStack {
87+
}
88+
.onAppear {
89+
viewModel.fetchLongQuestsFor(workspaceId: "\(selectedWorkspace.id)") { success, errorMessage, workspace in
90+
if success {
91+
self.selectedWorkspace = workspace
92+
let workspaceId = "\(selectedWorkspace.id)"
93+
_ = KeychainManager.save(key: "workspaceID", data: workspaceId)
94+
DispatchQueue.main.async {
95+
shouldNavigateToMapView = true
10596
}
97+
} else {
98+
autoRedirectToMapViewError = errorMessage ?? "Something went wrong. Please pick another workspace."
10699
}
107100
}
108101
}
@@ -164,10 +157,10 @@ struct WorkspacesListView: View {
164157
ForEach(viewModel.workspaces?.filter({$0.type == "osw" && $0.externalAppAccess == 1}) ?? [], id: \.id) { workspace in
165158
Button {
166159
viewModel.checkAndDeleteWorkspaceDB(workspaceId: "\(workspace.id)")
167-
viewModel.fetchLongQuestsFor(workspaceId: "\(workspace.id)", completion: { success, errorMessage in
160+
viewModel.fetchLongQuestsFor(workspaceId: "\(workspace.id)", completion: { success, errorMessage, ws in
168161
if success {
169162
shouldNavigateToMapView = true
170-
selectedWorkspace = workspace
163+
selectedWorkspace = ws
171164

172165
let workspaceId = "\(workspace.id)"
173166
_ = KeychainManager.save(key: "workspaceID", data: workspaceId)

GoInfoGame/GoInfoGame/UI/InitialView/InitialViewController.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,6 @@ import Foundation
99
import SwiftUI
1010
class InitialViewController: UIHostingController<PosmLoginView> {
1111
required init?(coder aDecoder: NSCoder) {
12-
super.init(coder: aDecoder, rootView: PosmLoginView())
12+
super.init(coder: aDecoder, rootView: PosmLoginView(forceUpdateManager: ForceUpdateManager()))
1313
}
1414
}

0 commit comments

Comments
 (0)