Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prevent crash on creating automation from a server controlled iOS Action #2590

Merged
merged 1 commit into from
Feb 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion Sources/App/Settings/ActionConfigurator.swift
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,9 @@
private func saveAndAutomate() {
if form.validate().count == 0 {
Current.Log.verbose("Category form is valid, calling dismiss callback!")
shouldSave = true
if !action.isServerControlled {
shouldSave = true
}

Check warning on line 310 in Sources/App/Settings/ActionConfigurator.swift

View check run for this annotation

Codecov / codecov/patch

Sources/App/Settings/ActionConfigurator.swift#L308-L310

Added lines #L308 - L310 were not covered by tests
shouldOpenAutomationEditor = true
onDismissCallback?(self)
}
Expand Down
20 changes: 11 additions & 9 deletions Sources/App/Settings/SettingsDetailViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -716,6 +716,17 @@
_ = vc.navigationController?.popViewController(animated: true)

if let vc = vc as? ActionConfigurator {
defer {
if vc.shouldOpenAutomationEditor {
vc.navigationController?.dismiss(animated: true, completion: {
Current.sceneManager.webViewWindowControllerPromise.then(\.webViewControllerPromise)
.done { controller in
controller.openActionAutomationEditor(actionId: vc.action.ID)
}
})
}
}

Check warning on line 729 in Sources/App/Settings/SettingsDetailViewController.swift

View check run for this annotation

Codecov / codecov/patch

Sources/App/Settings/SettingsDetailViewController.swift#L719-L729

Added lines #L719 - L729 were not covered by tests
if vc.shouldSave == false {
Current.Log.verbose("Not saving action to DB and returning early!")
return
Expand All @@ -734,15 +745,6 @@
}.done {
self?.updatePositions()
}.cauterize()

if vc.shouldOpenAutomationEditor {
vc.navigationController?.dismiss(animated: true, completion: {
Current.sceneManager.webViewWindowControllerPromise.then(\.webViewControllerPromise)
.done { controller in
controller.openActionAutomationEditor(actionId: vc.action.ID)
}
})
}
}
})
}
Expand Down
Loading