Skip to content

Commit 5795ae0

Browse files
committed
PR changes: indentation and whitespace
1 parent 77fc0f0 commit 5795ae0

File tree

2 files changed

+27
-19
lines changed

2 files changed

+27
-19
lines changed
Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,23 @@
11
/// Represents one of several durations for skipping backwards and forwards.
22
public enum BackForwardSkipDuration: TimeInterval {
3-
case fiveSeconds = 5
4-
case tenSeconds = 10
5-
case fifteenSeconds = 15
6-
case thirtySeconds = 30
7-
8-
public init(seconds: TimeInterval) {
9-
switch seconds {
10-
case 5:
11-
self = .fiveSeconds
12-
case 10:
13-
self = .tenSeconds
14-
case 15:
15-
self = .fifteenSeconds
16-
case 30:
17-
self = .thirtySeconds
18-
default:
19-
assertionFailure("Expected a duration of `BackForwardSkipDuration`; received \(seconds)")
20-
self = .thirtySeconds
3+
case fiveSeconds = 5
4+
case tenSeconds = 10
5+
case fifteenSeconds = 15
6+
case thirtySeconds = 30
7+
8+
public init(seconds: TimeInterval) {
9+
switch seconds {
10+
case 5:
11+
self = .fiveSeconds
12+
case 10:
13+
self = .tenSeconds
14+
case 15:
15+
self = .fifteenSeconds
16+
case 30:
17+
self = .thirtySeconds
18+
default:
19+
assertionFailure("Expected a duration of `BackForwardSkipDuration`; received \(seconds)")
20+
self = .thirtySeconds
21+
}
2122
}
22-
}
2323
}

WWDC/Preferences.swift

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,14 @@ final class Preferences {
162162

163163
var skipBackAndForwardDuration: BackForwardSkipDuration {
164164
get {
165+
// Migrate from legacy 30/15 preference if needed.
166+
let migrationKey = "backForwardSkipMigrated"
167+
if !defaults.bool(forKey: migrationKey) {
168+
let duration: BackForwardSkipDuration = defaults.bool(forKey: "skipBackAndForwardBy30Seconds") ? .thirtySeconds : .fifteenSeconds
169+
defaults.set(duration.rawValue, forKey: #function)
170+
171+
defaults.set(true, forKey: migrationKey)
172+
}
165173
return BackForwardSkipDuration(seconds: defaults.double(forKey: #function))
166174
}
167175
set {

0 commit comments

Comments
 (0)