-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Reset core data for older beta builds
Previous builds were using mock data that was being returned from the server. Now that the server is returning actual users' lists, they are seeing the cached mock data from before. For this build, we'll reset core data to clear out the old mock data. https://getpocket.atlassian.net/browse/IN-79
- Loading branch information
1 parent
40db18f
commit f1e428b
Showing
3 changed files
with
54 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
// This Source Code Form is subject to the terms of the Mozilla Public | ||
// License, v. 2.0. If a copy of the MPL was not distributed with this | ||
// file, You can obtain one at http://mozilla.org/MPL/2.0/. | ||
|
||
import Foundation | ||
import Sync | ||
import SwiftUI | ||
|
||
|
||
struct StaticDataCleaner { | ||
private let bundle: Bundle | ||
private let source: Source | ||
|
||
@AppStorage("hasClearedStaticData") | ||
private var hasClearedStaticData: Bool = false | ||
|
||
init(bundle: Bundle, source: Source) { | ||
self.bundle = bundle | ||
self.source = source | ||
} | ||
|
||
private var currentBuildNumber: Int? { | ||
guard let buildNumberString = bundle.infoDictionary?["CFBundleVersion"] as? String, | ||
let buildNumber = Int(buildNumberString) else { | ||
return nil | ||
} | ||
|
||
return buildNumber | ||
} | ||
|
||
func clearIfNecessary() { | ||
guard let buildNumber = currentBuildNumber else { | ||
return | ||
} | ||
|
||
if buildNumber <= 70, !hasClearedStaticData { | ||
source.clear() | ||
hasClearedStaticData = true | ||
} | ||
} | ||
} |