Skip to content

Commit 7675438

Browse files
authored
Remove auto signup (#154)
* Remove all references * Remove kubernetes scheme and auto signup * Bump version to proper
1 parent ae2a94a commit 7675438

File tree

23 files changed

+14
-266
lines changed

23 files changed

+14
-266
lines changed

App/Core/Factories/PopupFactory.swift

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -115,24 +115,6 @@ class PopupFactory {
115115
)
116116
}
117117

118-
func autoSignupEnabled() -> Popup {
119-
Popup(
120-
type: .info,
121-
title: NSLocalizedString("Automatic signup", comment: ""),
122-
message: NSLocalizedString(
123-
"Automatic exam/event signup has been enabled, but make sure you are always registered for exams through your institution.",
124-
comment: "")
125-
)
126-
}
127-
128-
func autoSignupDisabled() -> Popup {
129-
Popup(
130-
type: .info,
131-
title: NSLocalizedString("Automatic signup", comment: ""),
132-
message: NSLocalizedString("Automatic exam/event signup has been disabled.", comment: "")
133-
)
134-
}
135-
136118
func genericError() -> Popup {
137119
Popup(type: .error, title: NSLocalizedString("Something went wrong", comment: ""))
138120
}

App/Core/NetworkSettings/NetworkSettings.swift

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,6 @@ struct NetworkSettings {
2222
static let development = NetworkSettings(
2323
port: 7036, scheme: "http", tumbleUrl: "localhost"
2424
)
25-
26-
// Port forward whatever the backend service is to port 80
27-
static let kubernetes = NetworkSettings(
28-
port: 32157, scheme: "http", tumbleUrl: "localhost"
29-
)
3025
}
3126

3227
let port: Int

App/Data/Repository/Preferences/PreferenceManager.swift

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ class PreferenceManager: ObservableObject {
1616
@Published var userOnboarded: Bool
1717
@Published var authSchoolId: Int
1818
@Published var appearance: AppearanceType // Using AppearanceType directly
19-
@Published var autoSignup: Bool
2019
@Published var notificationOffset: NotificationOffset // Using NotificationOffset directly
2120
@Published var language: String
2221
@Published var viewTypeIndex: Int
@@ -31,7 +30,6 @@ class PreferenceManager: ObservableObject {
3130
onboardingPreference: OnboardingPreference = OnboardingPreference(),
3231
authSchoolPreference: AuthSchoolPreference = AuthSchoolPreference(),
3332
appearancePreference: AppearancePreference = AppearancePreference(),
34-
autoSignupPreference: AutoSignupPreference = AutoSignupPreference(),
3533
notificationOffsetPreference: NotificationOffsetPreference = NotificationOffsetPreference(),
3634
languagePreference: LanguagePreference = LanguagePreference(),
3735
viewTypePreference: ViewTypeIndexPreference = ViewTypeIndexPreference(),
@@ -43,7 +41,6 @@ class PreferenceManager: ObservableObject {
4341
self.userOnboarded = onboardingPreference.get()
4442
self.authSchoolId = authSchoolPreference.get()
4543
self.appearance = AppearanceType.fromRawValue(appearancePreference.get()) ?? .system // Convert String to enum
46-
self.autoSignup = autoSignupPreference.get()
4744
self.notificationOffset = NotificationOffset(rawValue: notificationOffsetPreference.get()) ?? .hour // Convert Int to enum
4845
self.language = languagePreference.get()
4946
self.viewTypeIndex = viewTypePreference.get()
@@ -56,7 +53,6 @@ class PreferenceManager: ObservableObject {
5653
bindPreference($userOnboarded, initialValue: userOnboarded, to: onboardingPreference)
5754
bindPreference($authSchoolId, initialValue: authSchoolId, to: authSchoolPreference)
5855
bindEnumPreference($appearance, initialValue: appearance, to: appearancePreference) // Special handling for AppearanceType
59-
bindPreference($autoSignup, initialValue: autoSignup, to: autoSignupPreference)
6056
bindEnumPreference($notificationOffset, initialValue: notificationOffset, to: notificationOffsetPreference) // Special handling for NotificationOffset
6157
bindPreference($language, initialValue: language, to: languagePreference)
6258
bindPreference($viewTypeIndex, initialValue: viewTypeIndex, to: viewTypePreference)

App/Data/Repository/Preferences/Services/AutoSingupPreference.swift

Lines changed: 0 additions & 22 deletions
This file was deleted.

App/Domain/Model/Preferences/SharedPreferenceKey.swift

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ enum SharedPreferenceKey: String {
1313
case userOnboarded = "user_onboarded"
1414
case locale = "locale"
1515
case notificationOffset = "notification_offset"
16-
case autoSignup = "auto_signup"
1716
case viewType = "view_type"
1817
case networkSettings = "network_settings"
1918
case lastUpdated = "last_updated"

App/Extensions/Presentation/Types/NetworkExtensions.swift

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,6 @@ extension NetworkSettings {
1515
switch resolvedEnvironment {
1616
case "development":
1717
self = Environments.development
18-
case "kubernetes":
19-
self = Environments.kubernetes
2018
default:
2119
self = Environments.production
2220
}

App/Observables/ViewModels/AccountViewModel.swift

Lines changed: 4 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ final class AccountViewModel: ObservableObject {
2929
@Published var resourceDetailsSheetModel: ResourceDetailSheetModel? = nil
3030
@Published var examDetailSheetModel: ExamDetailSheetModel? = nil
3131
@Published var authSchoolId: Int = -1
32-
@Published var autoSignupEnabled: Bool = false
3332
@Published var registeredForExams: Bool = false
3433
@Published var currentUser: String = ""
3534

@@ -81,25 +80,16 @@ final class AccountViewModel: ObservableObject {
8180
private func setupPublishers() {
8281
let authStatusPublisher = userController.$authStatus.receive(on: RunLoop.main)
8382
let authSchoolIdPublisher = preferenceManager.$authSchoolId.receive(on: RunLoop.main)
84-
let autoSignupPublisher = preferenceManager.$autoSignup.receive(on: RunLoop.main)
8583
let currentUserPublisher = preferenceManager.$currentUser.receive(on: RunLoop.main)
8684

87-
Publishers.CombineLatest4(authStatusPublisher, authSchoolIdPublisher, autoSignupPublisher, currentUserPublisher)
88-
.sink { [weak self] authStatus, authSchoolId, autoSignupEnabled, currentUser in
85+
Publishers.CombineLatest3(authStatusPublisher, authSchoolIdPublisher, currentUserPublisher)
86+
.sink { [weak self] authStatus, authSchoolId, currentUser in
8987
guard let self else { return }
9088

9189
DispatchQueue.main.async {
9290
self.authStatus = authStatus
9391
self.authSchoolId = authSchoolId
94-
self.autoSignupEnabled = autoSignupEnabled
9592
self.currentUser = currentUser
96-
97-
if authStatus == .authorized && !self.registeredForExams && self.autoSignupEnabled {
98-
Task.detached(priority: .userInitiated) {
99-
AppLogger.shared.debug("Auto signup is \(autoSignupEnabled), registering for exams")
100-
await self.registerAutoSignup()
101-
}
102-
}
10393
}
10494
}
10595
.store(in: &cancellables)
@@ -241,18 +231,6 @@ final class AccountViewModel: ObservableObject {
241231
}
242232
}
243233

244-
/// Registers the user for automatic event/exam signup,
245-
/// and attempts to sign up for any currently available exams/events
246-
func toggleAutoSignup(value: Bool) {
247-
preferenceManager.autoSignup.toggle()
248-
if value && !self.registeredForExams {
249-
Task {
250-
await registerAutoSignup()
251-
}
252-
getResourcesAndEvents()
253-
}
254-
}
255-
256234
/// Decides if there are any user bookings for the current user, and if so attempts
257235
/// to schedule any confirmation notifications for those bookings
258236
func checkNotificationsForUserBookings(bookings: Response.KronoxUserBookings? = nil) async {
@@ -273,8 +251,8 @@ final class AccountViewModel: ObservableObject {
273251
}
274252
} catch {
275253
AppLogger.shared.debug("\(error)")
276-
DispatchQueue.main.async {
277-
self.bookingSectionState = .error
254+
DispatchQueue.main.async { [weak self] in
255+
self?.bookingSectionState = .error
278256
}
279257
}
280258
}
@@ -298,21 +276,6 @@ final class AccountViewModel: ObservableObject {
298276
}
299277
}
300278
}
301-
302-
/// Registers for any available events through auto signup
303-
func registerAutoSignup() async {
304-
AppLogger.shared.debug("Attempting to automatically sign up for exams")
305-
do {
306-
let request = Endpoint.registerAllEvents(schoolId: String(authSchoolId))
307-
let _: Response.KronoxEventRegistration?
308-
= try await kronoxManager.put(
309-
request, refreshToken: userController.refreshToken?.value,
310-
sessionDetails: userController.sessionDetails?.value, body: NetworkRequest.Empty())
311-
self.registeredForExams = true
312-
} catch {
313-
AppLogger.shared.error("Failed to sign up for exams: \(error)")
314-
}
315-
}
316279

317280
/// Sets current user, updates tokens in keychain, updates user resources
318281
func setCurrentUser(to user: String) async {

App/Observables/ViewModels/SettingsViewModel.swift

Lines changed: 2 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -40,14 +40,6 @@ final class SettingsViewModel: ObservableObject {
4040
}
4141
}
4242
}
43-
@Published var autoSignup: Bool = false {
44-
didSet {
45-
if oldValue != autoSignup {
46-
AppLogger.shared.debug("Auto signup is \(autoSignup)")
47-
self.setAutoSignup(value: autoSignup)
48-
}
49-
}
50-
}
5143
@Published var openEventFromWidget: Bool = true {
5244
didSet {
5345
if oldValue != openEventFromWidget {
@@ -69,7 +61,6 @@ final class SettingsViewModel: ObservableObject {
6961
let authSchoolIdPublisher = preferenceManager.$authSchoolId.receive(on: RunLoop.main)
7062
let appearancePublisher = preferenceManager.$appearance.receive(on: RunLoop.main)
7163
let notificationOffsetPublisher = preferenceManager.$notificationOffset.receive(on: RunLoop.main)
72-
let autoSignupPublisher = preferenceManager.$autoSignup.receive(on: RunLoop.main)
7364
let openEventFromWidgetPublisher = preferenceManager.$openEventFromWidget.receive(on: RunLoop.main)
7465
let authStatusPublisher = userController.$authStatus.receive(on: RunLoop.main)
7566

@@ -83,9 +74,8 @@ final class SettingsViewModel: ObservableObject {
8374
}
8475
.store(in: &cancellables)
8576

86-
Publishers.CombineLatest3(autoSignupPublisher, authStatusPublisher, openEventFromWidgetPublisher)
87-
.sink { [weak self] autoSignup, authStatus, openEventFromWidget in
88-
self?.autoSignup = autoSignup
77+
Publishers.CombineLatest(authStatusPublisher, openEventFromWidgetPublisher)
78+
.sink { [weak self] authStatus, openEventFromWidget in
8979
self?.authStatus = authStatus
9080
self?.openEventFromWidget = openEventFromWidget
9181
}
@@ -193,10 +183,6 @@ final class SettingsViewModel: ObservableObject {
193183
func setNotificationOffset(offset: NotificationOffset) {
194184
preferenceManager.notificationOffset = offset
195185
}
196-
197-
func setAutoSignup(value: Bool) {
198-
preferenceManager.autoSignup = value
199-
}
200186

201187
func setOpenEventFromWidget(value: Bool) {
202188
preferenceManager.openEventFromWidget = value

App/Presentation/Views/Settings/Preferences/PreferenceSettings.swift

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -60,15 +60,6 @@ struct PreferenceSettings: View {
6060
leadingIconBackgroundColor: Color(uiColor: UIColor.systemTeal),
6161
condition: $viewModel.openEventFromWidget
6262
)
63-
if viewModel.authStatus == .authorized {
64-
Divider()
65-
SettingsToggleButton(
66-
title: NSLocalizedString("Automatic exam signup", comment: ""),
67-
leadingIcon: "paperclip",
68-
leadingIconBackgroundColor: .primary,
69-
condition: $viewModel.autoSignup
70-
)
71-
}
7263
}
7364
}
7465
}

Assets/ar.lproj/Localizable.strings

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -345,12 +345,6 @@
345345

346346
"We couldn't unbook the specified resource"="لم نتمكن من إلغاء حجز المصدر المحدد";
347347

348-
"Automatic signup"="التسجيل التلقائي";
349-
350-
"Automatic exam/event signup has been enabled, but make sure you are always registered for exams through your institution."="تم تمكين التسجيل التلقائي للاختبارات/الأحداث، ولكن تأكد من تسجيلك دائمًا للاختبارات من خلال مؤسستك.";
351-
352-
"Automatic exam/event signup has been disabled."="تم تعطيل التسجيل التلقائي للاختبارات/الأحداث.";
353-
354348
"See all"="عرض الكل";
355349

356350
"Book more"="حجز المزيد";

0 commit comments

Comments
 (0)