Skip to content

Commit

Permalink
dont refresh prefs so much
Browse files Browse the repository at this point in the history
  • Loading branch information
twocanoes committed May 27, 2023
1 parent b64496b commit 91ee8dc
Show file tree
Hide file tree
Showing 8 changed files with 17 additions and 24 deletions.
9 changes: 0 additions & 9 deletions DefaultsOverride.swift
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,6 @@ public class DefaultsOverride: UserDefaults {

let scriptRes=cliTask(prefScriptPath)

TCSLogWithMark(scriptRes)
if scriptRes.count==0{
TCSLogErrorWithMark("script did not return anything")
return
Expand Down Expand Up @@ -169,7 +168,6 @@ public class DefaultsOverride: UserDefaults {
return UserDefaults.standard.float(forKey: defaultName)
}
override public func double(forKey defaultName: String) -> Double {
TCSLogWithMark()

if let defaultName = cachedPrefs[defaultName] as? Double {
return defaultName
Expand All @@ -180,13 +178,6 @@ public class DefaultsOverride: UserDefaults {
override public func bool(forKey defaultName: String) -> Bool {
TCSLogWithMark()

if cachedPrefs.count != 0 {
TCSLogWithMark("got prefs")

}
else {
TCSLogWithMark("No prefs")
}
if let defaultName = cachedPrefs[defaultName] as? Bool {
return defaultName
}
Expand Down
11 changes: 4 additions & 7 deletions XCredsLoginPlugIn/LoginWindow/LoginWebViewWindowController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -62,14 +62,13 @@ class LoginWebViewWindowController: WebViewWindowController {

func setupLoginWindowAppearance() {
DispatchQueue.main.async {
// TCSLogWithMark("webview frame is \(self.webView.frame.debugDescription)")

DefaultsOverride.standardOverride.refreshCachedPrefs()

TCSLogWithMark("setting up window...")

self.window?.level = .normal
self.window?.orderFrontRegardless()
self.window?.makeKeyAndOrderFront(self)

self.window?.backgroundColor = NSColor.blue

Expand Down Expand Up @@ -116,9 +115,6 @@ class LoginWebViewWindowController: WebViewWindowController {
TCSLogWithMark()
self.webView.frame=NSMakeRect((screenWidth-CGFloat(loginWindowWidth))/2,(screenHeight-CGFloat(loginWindowHeight))/2, CGFloat(loginWindowWidth), CGFloat(loginWindowHeight))
TCSLogWithMark()
// BackgroundImage


}
// self.window?.setFrame(NSMakeRect((screenWidth-CGFloat(width))/2,(screenHeight-CGFloat(height))/2, CGFloat(width), CGFloat(height)), display: true, animate: false)
// }
Expand Down Expand Up @@ -154,12 +150,12 @@ class LoginWebViewWindowController: WebViewWindowController {
context.duration = 1.0
context.allowsImplicitAnimation = true
self.webView?.animator().alphaValue = 0.0
// self.window?.setFrame(NSMakeRect(0, 0, 100, 100), display: true, animate: true)
}, completionHandler: {
DispatchQueue.main.async{
self.webView?.alphaValue = 0.0

self.window?.close()
self.delegate?.allowLogin()

}
})
}
Expand Down Expand Up @@ -419,6 +415,7 @@ class LoginWebViewWindowController: WebViewWindowController {
// }
//
DispatchQueue.main.async{
TCSLogWithMark("calling allowLogin")

self.delegate?.allowLogin()

Expand Down
2 changes: 1 addition & 1 deletion XCredsLoginPlugIn/LoginWindow/LoginWindowControls.xib
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@
<rect key="frame" x="397" y="0.0" width="90" height="48"/>
<buttonCell key="cell" type="bevel" bezelStyle="rounded" image="loginwindow" imagePosition="above" alignment="center" imageScaling="proportionallyDown" inset="2" id="c0y-fU-B6x">
<behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
<string key="title">Standard
<string key="title">Switch
Login Window</string>
<font key="font" metaFont="system"/>
</buttonCell>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,8 @@ class LoginWindowControlsWindowController: NSWindowController {

@IBAction func refreshButtonPressed(_ sender: Any) {
TCSLogWithMark("refreshButtonPressed")
DefaultsOverride.standardOverride.refreshCachedPrefs()

guard let delegate = delegate else {
TCSLogWithMark("No delegate set for refresh")
return
Expand Down Expand Up @@ -204,6 +206,7 @@ class LoginWindowControlsWindowController: NSWindowController {
return
}
delegate.setContextString(type: kAuthorizationEnvironmentUsername, value: SpecialUsers.shutdown.rawValue)
TCSLogWithMark("calling allowLogin")

delegate.allowLogin()
}
Expand Down
2 changes: 2 additions & 0 deletions XCredsLoginPlugIn/Mechanisms/XCredsBaseMechanism.swift
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,8 @@ protocol XCredsMechanismProtocol {
func allowLogin() {
TCSLogWithMark("\(#function) \(#file):\(#line)")
let error = mechCallbacks.SetResult(mechEngine, .allow)
TCSLogWithMark("\(#function) \(#file):\(#line)")

if error != noErr {
TCSLogErrorWithMark("Error: \(error)")
}
Expand Down
2 changes: 1 addition & 1 deletion XCredsLoginPlugIn/Mechanisms/XCredsLoginMechanism.swift
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ import Cocoa
TCSLogWithMark("Dismissing loginWindowWindowController")
loginWebViewWindowController?.loginTransition()
}
TCSLogWithMark("calling super allowLogin")
TCSLogWithMark("calling allowLogin")
super.allowLogin()
}
override func denyLogin() {
Expand Down
12 changes: 6 additions & 6 deletions xCreds.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -1091,7 +1091,7 @@
CLANG_ENABLE_MODULES = YES;
CODE_SIGN_STYLE = Automatic;
COMBINE_HIDPI_IMAGES = YES;
CURRENT_PROJECT_VERSION = 4058;
CURRENT_PROJECT_VERSION = 4067;
DEFINES_MODULE = YES;
DEVELOPMENT_TEAM = UXP6YEHSPW;
FRAMEWORK_SEARCH_PATHS = (
Expand Down Expand Up @@ -1128,7 +1128,7 @@
CLANG_ENABLE_MODULES = YES;
CODE_SIGN_STYLE = Automatic;
COMBINE_HIDPI_IMAGES = YES;
CURRENT_PROJECT_VERSION = 4058;
CURRENT_PROJECT_VERSION = 4067;
DEFINES_MODULE = YES;
DEVELOPMENT_TEAM = UXP6YEHSPW;
FRAMEWORK_SEARCH_PATHS = (
Expand Down Expand Up @@ -1193,7 +1193,7 @@
CODE_SIGN_ENTITLEMENTS = "XCreds Login Overlay/XCreds_Login_Overlay.entitlements";
CODE_SIGN_STYLE = Automatic;
COMBINE_HIDPI_IMAGES = YES;
CURRENT_PROJECT_VERSION = 4058;
CURRENT_PROJECT_VERSION = 4067;
DEVELOPMENT_TEAM = UXP6YEHSPW;
ENABLE_HARDENED_RUNTIME = YES;
FRAMEWORK_SEARCH_PATHS = (
Expand Down Expand Up @@ -1229,7 +1229,7 @@
CODE_SIGN_ENTITLEMENTS = "XCreds Login Overlay/XCreds_Login_Overlay.entitlements";
CODE_SIGN_STYLE = Automatic;
COMBINE_HIDPI_IMAGES = YES;
CURRENT_PROJECT_VERSION = 4058;
CURRENT_PROJECT_VERSION = 4067;
DEVELOPMENT_TEAM = UXP6YEHSPW;
ENABLE_HARDENED_RUNTIME = YES;
FRAMEWORK_SEARCH_PATHS = (
Expand Down Expand Up @@ -1378,7 +1378,7 @@
CODE_SIGN_ENTITLEMENTS = XCreds/xCreds.entitlements;
CODE_SIGN_STYLE = Automatic;
COMBINE_HIDPI_IMAGES = YES;
CURRENT_PROJECT_VERSION = 4058;
CURRENT_PROJECT_VERSION = 4067;
DEVELOPMENT_TEAM = UXP6YEHSPW;
ENABLE_HARDENED_RUNTIME = YES;
FRAMEWORK_SEARCH_PATHS = (
Expand Down Expand Up @@ -1413,7 +1413,7 @@
CODE_SIGN_ENTITLEMENTS = XCreds/xCreds.entitlements;
CODE_SIGN_STYLE = Automatic;
COMBINE_HIDPI_IMAGES = YES;
CURRENT_PROJECT_VERSION = 4058;
CURRENT_PROJECT_VERSION = 4067;
DEVELOPMENT_TEAM = UXP6YEHSPW;
ENABLE_HARDENED_RUNTIME = YES;
FRAMEWORK_SEARCH_PATHS = (
Expand Down
Binary file not shown.

0 comments on commit 91ee8dc

Please sign in to comment.