Skip to content

Commit

Permalink
#26 show update activity indicator
Browse files Browse the repository at this point in the history
  • Loading branch information
Ehlen, David committed Mar 7, 2019
1 parent 3acdbc4 commit dfa2a30
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 3 deletions.
4 changes: 2 additions & 2 deletions Capture/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>0.9.2</string>
<string>0.9.3</string>
<key>CFBundleVersion</key>
<string>0.9.2</string>
<string>0.9.3</string>
<key>LSMinimumSystemVersion</key>
<string>$(MACOSX_DEPLOYMENT_TARGET)</string>
<key>NSHumanReadableCopyright</key>
Expand Down
16 changes: 15 additions & 1 deletion Capture/Preferences/View/GeneralPreferencesViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,13 @@ import Cocoa
import KeyHolder
import Magnet
import os
import PromiseKit

class GeneralPreferencesViewController: PreferencesViewController {

// MARK: - Properties
@IBOutlet private weak var stopRecordingShortcutRecordView: RecordView!
@IBOutlet private weak var updateActivityIndicator: NSProgressIndicator!

// MARK: - Initialize
override func loadView() {
Expand All @@ -17,14 +19,26 @@ class GeneralPreferencesViewController: PreferencesViewController {
prepareHotKeys()
}

@IBAction func userRequestedAnExplicitUpdateCheck(_ sender: Any) {
@IBAction func userRequestedAnExplicitUpdateCheck(_ sender: NSButton) {
let delegate = NSApplication.shared.delegate as? AppDelegate

updateActivityIndicator.startAnimation(nil)
updateActivityIndicator.isHidden = false
sender.isEnabled = false

delegate?.updater.check().catch(policy: .allErrors) { error in
self.updateActivityIndicator.stopAnimation(nil)
sender.isEnabled = true

if error.isCancelled {
showAlert(title: "alreadyUpToDateTitle".localized, message: ErrorMessageProvider.string(for: AppUpdaterError.alreadyUpToDate))
} else {
self.presentError(NSError.create(from: AppUpdaterError.failure(error.localizedDescription)))
}
}.finally {
self.updateActivityIndicator.stopAnimation(nil)
self.updateActivityIndicator.isHidden = true
sender.isEnabled = true
}
}
}
Expand Down
6 changes: 6 additions & 0 deletions Capture/Preferences/View/Preferences.storyboard
Original file line number Diff line number Diff line change
Expand Up @@ -141,16 +141,21 @@
<color key="backgroundColor" name="textBackgroundColor" catalog="System" colorSpace="catalog"/>
</textFieldCell>
</textField>
<progressIndicator hidden="YES" wantsLayer="YES" horizontalHuggingPriority="750" verticalHuggingPriority="750" maxValue="100" displayedWhenStopped="NO" bezeled="NO" indeterminate="YES" controlSize="small" style="spinning" translatesAutoresizingMaskIntoConstraints="NO" id="aCH-uL-5ms">
<rect key="frame" x="351" y="61" width="16" height="16"/>
</progressIndicator>
</subviews>
<constraints>
<constraint firstAttribute="trailing" secondItem="btq-nd-DrW" secondAttribute="trailing" constant="20" id="078-OX-KBz"/>
<constraint firstItem="xix-mN-5C6" firstAttribute="leading" secondItem="IDG-1b-v6d" secondAttribute="trailing" constant="10" id="3UI-KT-DWK"/>
<constraint firstAttribute="trailing" secondItem="Maz-20-LlC" secondAttribute="trailing" constant="20" id="41h-OP-eMs"/>
<constraint firstItem="K7Z-TW-8U8" firstAttribute="centerY" secondItem="UDU-Gc-nF1" secondAttribute="centerY" id="7fS-hS-Mf1"/>
<constraint firstItem="aCH-uL-5ms" firstAttribute="leading" secondItem="OBT-6X-HhQ" secondAttribute="trailing" constant="8" id="89v-xc-R4n"/>
<constraint firstItem="btq-nd-DrW" firstAttribute="leading" secondItem="IDG-1b-v6d" secondAttribute="leading" id="8Cv-GA-lj2"/>
<constraint firstItem="Y8G-g4-hdo" firstAttribute="leading" secondItem="4Ei-kU-JuY" secondAttribute="leading" constant="20" id="AgO-fd-4zk"/>
<constraint firstItem="BYr-zV-DCp" firstAttribute="top" secondItem="Maz-20-LlC" secondAttribute="bottom" constant="20" id="Bro-qe-PVH"/>
<constraint firstItem="Maz-20-LlC" firstAttribute="top" secondItem="K7Z-TW-8U8" secondAttribute="bottom" constant="10" id="DlR-2F-fjH"/>
<constraint firstItem="aCH-uL-5ms" firstAttribute="centerY" secondItem="OBT-6X-HhQ" secondAttribute="centerY" id="EJV-Ud-3Sa"/>
<constraint firstItem="IDG-1b-v6d" firstAttribute="top" secondItem="4Ei-kU-JuY" secondAttribute="top" constant="20" id="Exg-sT-rCA"/>
<constraint firstItem="Y8G-g4-hdo" firstAttribute="top" secondItem="OBT-6X-HhQ" secondAttribute="bottom" constant="10" id="FL5-cX-QmI"/>
<constraint firstItem="OBT-6X-HhQ" firstAttribute="leading" secondItem="BYr-zV-DCp" secondAttribute="trailing" constant="10" id="OFT-n9-A8z"/>
Expand All @@ -169,6 +174,7 @@
</view>
<connections>
<outlet property="stopRecordingShortcutRecordView" destination="K7Z-TW-8U8" id="v6c-pU-Fzg"/>
<outlet property="updateActivityIndicator" destination="aCH-uL-5ms" id="qBn-Wk-ExD"/>
</connections>
</viewController>
<customObject id="FvE-cN-eWk" userLabel="First Responder" customClass="NSResponder" sceneMemberID="firstResponder"/>
Expand Down

0 comments on commit dfa2a30

Please sign in to comment.