Skip to content

Commit

Permalink
Merge pull request #668 from JohnCoates/revert-649-synchronize
Browse files Browse the repository at this point in the history
Revert "Removes not needed synchronize method"
  • Loading branch information
glouel authored Nov 19, 2018
2 parents e084ad5 + fa03b3c commit 95e7b90
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 6 deletions.
12 changes: 11 additions & 1 deletion Aerial/Source/Controllers/Preferences.swift
Original file line number Diff line number Diff line change
Expand Up @@ -650,10 +650,15 @@ final class Preferences {
return !removed
}

func setVideo(videoID: String, inRotation: Bool) {
func setVideo(videoID: String, inRotation: Bool,
synchronize: Bool = true) {
let key = "remove\(videoID)"
let removed = !inRotation
userDefaults.set(removed, forKey: key)

if synchronize {
self.synchronize()
}
}

// MARK: - Setting, Getting
Expand Down Expand Up @@ -685,5 +690,10 @@ final class Preferences {
} else {
userDefaults.set(value, forKey: key)
}
synchronize()
}

func synchronize() {
userDefaults.synchronize()
}
} //swiftlint:disable:this file_length
30 changes: 25 additions & 5 deletions Aerial/Source/Controllers/PreferencesWindowController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -641,6 +641,7 @@ final class PreferencesWindowController: NSWindowController, NSOutlineViewDataSo
@IBAction func popupVideoFormatChange(_ sender: NSPopUpButton) {
debugLog("UI popupVideoFormat: \(sender.indexOfSelectedItem)")
preferences.videoFormat = sender.indexOfSelectedItem
preferences.synchronize()
outlineView.reloadData()
}

Expand All @@ -655,11 +656,13 @@ final class PreferencesWindowController: NSWindowController, NSOutlineViewDataSo
@IBAction func multiMonitorModePopupChange(_ sender: NSPopUpButton) {
debugLog("UI multiMonitorMode: \(sender.indexOfSelectedItem)")
preferences.multiMonitorMode = sender.indexOfSelectedItem
preferences.synchronize()
}

@IBAction func fadeInOutModePopupChange(_ sender: NSPopUpButton) {
debugLog("UI fadeInOutMode: \(sender.indexOfSelectedItem)")
preferences.fadeMode = sender.indexOfSelectedItem
preferences.synchronize()
}

func updateDownloads(done: Int, total: Int, progress: Double) {
Expand Down Expand Up @@ -834,6 +837,7 @@ final class PreferencesWindowController: NSWindowController, NSOutlineViewDataSo
@IBAction func descriptionModePopupChange(_ sender: NSPopUpButton) {
debugLog("UI descriptionMode: \(sender.indexOfSelectedItem)")
preferences.showDescriptionsMode = sender.indexOfSelectedItem
preferences.synchronize()
}

@IBAction func fontPickerClick(_ sender: NSButton?) {
Expand Down Expand Up @@ -936,11 +940,13 @@ final class PreferencesWindowController: NSWindowController, NSOutlineViewDataSo
@IBAction func fadeInOutTextModePopupChange(_ sender: NSPopUpButton) {
debugLog("UI fadeInOutTextMode: \(sender.indexOfSelectedItem)")
preferences.fadeModeText = sender.indexOfSelectedItem
preferences.synchronize()
}

@IBAction func extraCornerPopupChange(_ sender: NSPopUpButton) {
debugLog("UI extraCorner: \(sender.indexOfSelectedItem)")
preferences.extraCorner = sender.indexOfSelectedItem
preferences.synchronize()
}

@IBAction func changeMarginsToCornerClick(_ sender: NSButton) {
Expand Down Expand Up @@ -1398,11 +1404,16 @@ final class PreferencesWindowController: NSWindowController, NSOutlineViewDataSo

for video in videos {
if video.url4KHEVC != "" {
preferences.setVideo(videoID: video.id, inRotation: true)
preferences.setVideo(videoID: video.id,
inRotation: true,
synchronize: false)
} else {
preferences.setVideo(videoID: video.id, inRotation: false)
preferences.setVideo(videoID: video.id,
inRotation: false,
synchronize: false)
}
}
preferences.synchronize()

outlineView.reloadData()
}
Expand All @@ -1414,11 +1425,16 @@ final class PreferencesWindowController: NSWindowController, NSOutlineViewDataSo

for video in videos {
if video.isAvailableOffline {
preferences.setVideo(videoID: video.id, inRotation: true)
preferences.setVideo(videoID: video.id,
inRotation: true,
synchronize: false)
} else {
preferences.setVideo(videoID: video.id, inRotation: false)
preferences.setVideo(videoID: video.id,
inRotation: false,
synchronize: false)
}
}
preferences.synchronize()

outlineView.reloadData()
}
Expand Down Expand Up @@ -1461,8 +1477,11 @@ final class PreferencesWindowController: NSWindowController, NSOutlineViewDataSo
}

for video in videos {
preferences.setVideo(videoID: video.id, inRotation: inRotation)
preferences.setVideo(videoID: video.id,
inRotation: inRotation,
synchronize: false)
}
preferences.synchronize()

outlineView.reloadData()
}
Expand Down Expand Up @@ -1862,6 +1881,7 @@ extension PreferencesWindowController: NSFontChanging {
// Update our label
extraMessageFontLabel.stringValue = preferences.extraFontName! + ", \(preferences.extraFontSize!) pt"
}
preferences.synchronize()
}
}

Expand Down

0 comments on commit 95e7b90

Please sign in to comment.