Repo // Ensure BookmarkMangager.

This commit is contained in:
ShikiSuen 2022-08-31 11:26:33 +08:00
parent 18596d5275
commit f300305f85
3 changed files with 33 additions and 32 deletions

View File

@ -354,7 +354,7 @@ enum mgrLangModel {
folderPath?.ensureTrailingSlash()
}
let isFolderWritable = FileManager.default.isWritableFile(atPath: folderPath ?? "")
// IME.prtDebugIntel("mgrLM: Exist: \(folderExist), IsFolder: \(isFolder.boolValue), isWritable: \(isFolderWritable)")
if ((folderExist && !isFolder.boolValue) || !folderExist) || !isFolderWritable {
return false
}
@ -423,6 +423,7 @@ enum mgrLangModel {
return userDictPathDefault
}
if mgrPrefs.ifSpecifiedUserDataPathExistsInPlist() {
BookmarkManager.shared.loadBookmarks()
if mgrLangModel.checkIfSpecifiedUserDataFolderValid(userDictPathSpecified) {
return userDictPathSpecified
} else {

View File

@ -72,23 +72,23 @@ struct suiPrefPaneDictionary: View {
if let window = ctlPrefUI.shared.controller.window {
IME.dlgOpenPath.beginSheetModal(for: window) { result in
if result == NSApplication.ModalResponse.OK {
if IME.dlgOpenPath.url != nil {
// CommonDialog
//
var newPath = IME.dlgOpenPath.url!.path
newPath.ensureTrailingSlash()
if mgrLangModel.checkIfSpecifiedUserDataFolderValid(newPath) {
mgrPrefs.userDataFolderSpecified = newPath
tbxUserDataPathSpecified = mgrPrefs.userDataFolderSpecified
IME.initLangModels(userOnly: true)
(NSApplication.shared.delegate as! AppDelegate).updateStreamHelperPath()
} else {
clsSFX.beep()
if !bolPreviousFolderValidity {
mgrPrefs.resetSpecifiedUserDataFolder()
}
return
guard let url = IME.dlgOpenPath.url else { return }
// CommonDialog
//
var newPath = url.path
newPath.ensureTrailingSlash()
if mgrLangModel.checkIfSpecifiedUserDataFolderValid(newPath) {
mgrPrefs.userDataFolderSpecified = newPath
tbxUserDataPathSpecified = mgrPrefs.userDataFolderSpecified
BookmarkManager.shared.saveBookmark(for: url)
IME.initLangModels(userOnly: true)
(NSApplication.shared.delegate as! AppDelegate).updateStreamHelperPath()
} else {
clsSFX.beep()
if !bolPreviousFolderValidity {
mgrPrefs.resetSpecifiedUserDataFolder()
}
return
}
} else {
if !bolPreviousFolderValidity {

View File

@ -293,22 +293,22 @@ class ctlPrefWindow: NSWindowController {
IME.dlgOpenPath.beginSheetModal(for: window) { result in
if result == NSApplication.ModalResponse.OK {
if IME.dlgOpenPath.url != nil {
// CommonDialog
//
var newPath = IME.dlgOpenPath.url!.path
newPath.ensureTrailingSlash()
if mgrLangModel.checkIfSpecifiedUserDataFolderValid(newPath) {
mgrPrefs.userDataFolderSpecified = newPath
IME.initLangModels(userOnly: true)
(NSApplication.shared.delegate as! AppDelegate).updateStreamHelperPath()
} else {
clsSFX.beep()
if !bolPreviousFolderValidity {
mgrPrefs.resetSpecifiedUserDataFolder()
}
return
guard let url = IME.dlgOpenPath.url else { return }
// CommonDialog
//
var newPath = url.path
newPath.ensureTrailingSlash()
if mgrLangModel.checkIfSpecifiedUserDataFolderValid(newPath) {
mgrPrefs.userDataFolderSpecified = newPath
BookmarkManager.shared.saveBookmark(for: url)
IME.initLangModels(userOnly: true)
(NSApplication.shared.delegate as! AppDelegate).updateStreamHelperPath()
} else {
clsSFX.beep()
if !bolPreviousFolderValidity {
mgrPrefs.resetSpecifiedUserDataFolder()
}
return
}
} else {
if !bolPreviousFolderValidity {