Skip to content

Commit

Permalink
add some judgement when app lauch first time
Browse files Browse the repository at this point in the history
  • Loading branch information
mcfans committed Jun 4, 2017
1 parent 0391486 commit 5b8c196
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
8 changes: 6 additions & 2 deletions ShadowsocksX-NG/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -512,7 +512,9 @@ class AppDelegate: NSObject, NSApplicationDelegate, NSUserNotificationCenterDele
serverMenuText += " - \(latency) ms"
}
else{
serverMenuText += " - failed"
if !neverSpeedTestBefore {
serverMenuText += " - failed"
}
}
}
}
Expand Down Expand Up @@ -622,7 +624,9 @@ class AppDelegate: NSObject, NSApplicationDelegate, NSUserNotificationCenterDele
if let latency = p.latency{
item.title += " - \(latency) ms"
}else{
item.title += " - failed"
if !neverSpeedTestBefore {
item.title += " - failed"
}
}
if mgr.activeProfileId == p.uuid {
item.state = 1
Expand Down
6 changes: 6 additions & 0 deletions ShadowsocksX-NG/PingClient.swift
Original file line number Diff line number Diff line change
Expand Up @@ -131,8 +131,11 @@ class PingServers:NSObject{
}



func ping(_ i:Int=0){

neverSpeedTestBefore = false

var result:[(Int,Double)] = []

for k in 0..<SerMgr.profiles.count {
Expand All @@ -152,6 +155,7 @@ class PingServers:NSObject{
}



})
}
// after two seconds ,time out
Expand Down Expand Up @@ -222,3 +226,5 @@ func synchronized(lock: AnyObject, closure: () -> ()) {
func cancel(_ task: Task?) {
task?(true)
}

var neverSpeedTestBefore:Bool = true

0 comments on commit 5b8c196

Please sign in to comment.