OSDN Git Service

関数名を変更
[kcd/KCD.git] / KCD / NyukyoDockStatus.swift
index 423cb26..8d62200 100644 (file)
@@ -62,21 +62,24 @@ final class NyukyoDockStatus: NSObject {
         unbind(NSBindingName(#keyPath(completeTime)))
     }
     
+    private func invalidate() {
+        
+        name = nil
+        time = nil
+    }
+    
     private func updateState() {
         
         guard let state = state as? Int,
             let stat = DockState(rawValue: state) else {
                 
-                print("unknown State")
-                return
+                return Logger.shared.log("unknown State")
         }
         
         if stat == .empty {
             
             didNotify = false
-            name = nil
-            time = nil
-            
+            invalidate()
             return
         }
         
@@ -105,15 +108,14 @@ final class NyukyoDockStatus: NSObject {
         
         guard let completeTime = completeTime as? Int else {
             
-            self.name = nil
-            time = nil
+            invalidate()
             return
         }
         
         let compTime = TimeInterval(Int(completeTime / 1_000))
         let diff = compTime - Date().timeIntervalSince1970
         
-        realTime = diff < 0 ? 0 : diff
+        realTime = max(0, diff)
         
         if didNotify { return }
         if diff >= 1 * 60 { return }