File tree Expand file tree Collapse file tree 2 files changed +27
-19
lines changed
ConfUIFoundation/Source/Util Expand file tree Collapse file tree 2 files changed +27
-19
lines changed Original file line number Diff line number Diff line change 1
1
/// Represents one of several durations for skipping backwards and forwards.
2
2
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
+ }
21
22
}
22
- }
23
23
}
Original file line number Diff line number Diff line change @@ -162,6 +162,14 @@ final class Preferences {
162
162
163
163
var skipBackAndForwardDuration : BackForwardSkipDuration {
164
164
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
+ }
165
173
return BackForwardSkipDuration ( seconds: defaults. double ( forKey: #function) )
166
174
}
167
175
set {
You can’t perform that action at this time.
0 commit comments