forked from shadowfacts/Tusker
Fix crash when setting SegmentedPageViewController pages to [] after failing to decode pinned timelines
This commit is contained in:
parent
ee630cf9df
commit
ad0a9ecafe
|
@ -24,15 +24,17 @@ public final class AccountPreferences: NSManagedObject {
|
||||||
@NSManaged var createdAt: Date
|
@NSManaged var createdAt: Date
|
||||||
@NSManaged var pinnedTimelinesData: Data?
|
@NSManaged var pinnedTimelinesData: Data?
|
||||||
|
|
||||||
@LazilyDecoding(from: \AccountPreferences.pinnedTimelinesData, fallback: [])
|
@LazilyDecoding(from: \AccountPreferences.pinnedTimelinesData, fallback: AccountPreferences.defaultPinnedTimelines)
|
||||||
var pinnedTimelines: [PinnedTimeline]
|
var pinnedTimelines: [PinnedTimeline]
|
||||||
|
|
||||||
static func `default`(account: LocalData.UserAccountInfo, context: NSManagedObjectContext) -> AccountPreferences {
|
static func `default`(account: LocalData.UserAccountInfo, context: NSManagedObjectContext) -> AccountPreferences {
|
||||||
let prefs = AccountPreferences(context: context)
|
let prefs = AccountPreferences(context: context)
|
||||||
prefs.accountID = account.id
|
prefs.accountID = account.id
|
||||||
prefs.createdAt = Date()
|
prefs.createdAt = Date()
|
||||||
prefs.pinnedTimelines = [.home, .public(local: true), .public(local: false)]
|
prefs.pinnedTimelines = Self.defaultPinnedTimelines
|
||||||
return prefs
|
return prefs
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static let defaultPinnedTimelines = [PinnedTimeline.home, .public(local: true), .public(local: false)]
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue