Skip to content

Commit

Permalink
fix qrcode not refresh issue
Browse files Browse the repository at this point in the history
  • Loading branch information
fuji246 committed Apr 19, 2022
1 parent d4e4100 commit d1e5211
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 15 deletions.
30 changes: 16 additions & 14 deletions LomoAgent/PreferencesWindow.swift
Original file line number Diff line number Diff line change
Expand Up @@ -317,22 +317,24 @@ class PreferencesWindow: NSWindowController, NSWindowDelegate {
}

func generateQRCode() {
if let lomodService = getLomodService() {
imageQRCode.wantsLayer = true
if let addresses = lomodService.getListenIPs() {
if let firstAddr = addresses.first {
let url = "http://\(firstAddr):\(portTextField.stringValue)"
guard let data = url.data(using: String.Encoding.utf8, allowLossyConversion: false) else {
return
DispatchQueue.main.async {
if let lomodService = getLomodService() {
self.imageQRCode.wantsLayer = true
if let addresses = lomodService.getListenIPs() {
if let firstAddr = addresses.first {
let url = "http://\(firstAddr):\(self.portTextField.stringValue)"
guard let data = url.data(using: String.Encoding.utf8, allowLossyConversion: false) else {
return
}
self.ipTextField.stringValue = firstAddr
self.userTipsLabel.textColor = .labelColor
self.userTipsLabel.stringValue = userTipsScanQRCode
self.imageQRCode.image = QRCodeImageWith(data: data, size: self.imageQRCode.frame.size.width)
}
ipTextField.stringValue = firstAddr
userTipsLabel.textColor = .labelColor
userTipsLabel.stringValue = userTipsScanQRCode
imageQRCode.image = QRCodeImageWith(data: data, size: imageQRCode.frame.size.width)
} else {
self.userTipsLabel.textColor = .red
self.userTipsLabel.stringValue = userTipsConfigureHomeDirAndWaitStart
}
} else {
userTipsLabel.textColor = .red
userTipsLabel.stringValue = userTipsNeedConfigureHomeDir
}
}
}
Expand Down
5 changes: 4 additions & 1 deletion LomoAgent/StatusMenuController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,10 @@ class StatusMenuController: NSObject {

lomodService.checkServerStatus { (systemInfo, connectErr) in
if connectErr == nil {
lomodService.getUserList()

DispatchQueue.main.async {
lomodService.getUserList()
}

if let ipList = lomodService.getListenIPs() {
if let firstIp = ipList.first, firstIp != self.listenIp {
Expand Down

0 comments on commit d1e5211

Please sign in to comment.