Skip to content

Commit

Permalink
refactor: extract shared directory update logic
Browse files Browse the repository at this point in the history
  • Loading branch information
ACTCD committed Jan 3, 2025
1 parent 4bc3707 commit e6c920d
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions xcode/App-Shared/ViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,10 @@ class ViewController: PlatformViewController, WKNavigationDelegate, WKScriptMess
func updateEnableLoggerState() {
self.webView.evaluateJavaScript("webapp.switchLogger(\(Preferences.enableLogger),\(Preferences.promptLogger))")
}

func updateCurrentDirectory() {
self.webView.evaluateJavaScript("webapp.updateDirectory('\(getCurrentScriptsDirectoryString())')")
}

#if os(macOS)
deinit {
Expand Down Expand Up @@ -268,7 +272,7 @@ extension ViewController: UIDocumentPickerDelegate {

func changeSaveLocationHandler(_ url: URL) {
Preferences.scriptsDirectoryUrl = url
webView.evaluateJavaScript("webapp.updateDirectory('\(getCurrentScriptsDirectoryString())')")
self.updateCurrentDirectory()
}

func exportLogFiles() {
Expand Down Expand Up @@ -367,7 +371,7 @@ extension ViewController {
// try set new save location path to bookmark
guard setSaveLocationURL(url: url) else { return }
// update user interface text display
self.webView.evaluateJavaScript("webapp.updateDirectory('\(getCurrentScriptsDirectoryString())')")
self.updateCurrentDirectory()
// notify browser extension of relevant updates
sendExtensionMessage(
name: "SAVE_LOCATION_CHANGED",
Expand Down

0 comments on commit e6c920d

Please sign in to comment.