Skip to content

Commit 899e136

Browse files
committed
Move remaining UserPersistent- objects to WordPressShared
They had to be moved in bulk because of circular dependencies.
1 parent 04533be commit 899e136

File tree

44 files changed

+97
-56
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+97
-56
lines changed
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
import Foundation
2+
3+
public typealias UserPersistentRepository = UserPersistentRepositoryReader & UserPersistentRepositoryWriter & UserPersistentRepositoryUtility
4+
5+
extension UserDefaults: UserPersistentRepository {}
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
public protocol UserPersistentRepositoryUtility: AnyObject {
2+
var onboardingNotificationsPromptDisplayed: Bool { get set }
3+
var notificationPrimerAlertWasDisplayed: Bool { get set }
4+
}
5+
6+
public enum UPRUConstants {
7+
static let promptKey = "onboarding_notifications_prompt_displayed"
8+
static let questionKey = "onboarding_question_selection"
9+
static let notificationPrimerAlertWasDisplayed = "NotificationPrimerAlertWasDisplayed"
10+
public static let notificationsTabAccessCount = "NotificationsTabAccessCount"
11+
public static let notificationPrimerInlineWasAcknowledged = "notificationPrimerInlineWasAcknowledged"
12+
public static let secondNotificationsAlertCount = "secondNotificationsAlertCount"
13+
public static let hasShownCustomAppIconUpgradeAlert = "custom-app-icon-upgrade-alert-shown"
14+
public static let savedPostsPromoWasDisplayed = "SavedPostsV1PromoWasDisplayed"
15+
public static let currentAnnouncementsKey = "currentAnnouncements"
16+
public static let currentAnnouncementsDateKey = "currentAnnouncementsDate"
17+
public static let announcementsVersionDisplayedKey = "announcementsVersionDisplayed"
18+
public static let isJPContentImportCompleteKey = "jetpackContentImportComplete"
19+
public static let jetpackContentMigrationStateKey = "jetpackContentMigrationState"
20+
public static let mediaAspectRatioModeEnabledKey = "mediaAspectRatioModeEnabled"
21+
public static let readerSidebarSelectionKey = "readerSidebarSelectionKey"
22+
public static let isReaderSelectedKey = "isReaderSelectedKey"
23+
public static let readerSearchHistoryKey = "readerSearchHistoryKey"
24+
public static let readerDidSelectInterestsKey = "readerDidSelectInterestsKey"
25+
}
26+
27+
public extension UserPersistentRepositoryUtility {
28+
var onboardingNotificationsPromptDisplayed: Bool {
29+
get {
30+
UserPersistentStoreFactory.instance().bool(forKey: UPRUConstants.promptKey)
31+
}
32+
set {
33+
UserPersistentStoreFactory.instance().set(newValue, forKey: UPRUConstants.promptKey)
34+
}
35+
}
36+
37+
var notificationPrimerAlertWasDisplayed: Bool {
38+
get {
39+
UserPersistentStoreFactory.instance().bool(forKey: UPRUConstants.notificationPrimerAlertWasDisplayed)
40+
}
41+
set {
42+
UserPersistentStoreFactory.instance().set(newValue, forKey: UPRUConstants.notificationPrimerAlertWasDisplayed)
43+
}
44+
}
45+
}

Modules/Sources/WordPressShared/UserPersistentRepository/UserPersistentRepositoryWriter.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
protocol UserPersistentRepositoryWriter: KeyValueDatabase {
1+
public protocol UserPersistentRepositoryWriter: KeyValueDatabase {
22
func set(_ value: Any?, forKey key: String)
33
func set(_ value: Int, forKey key: String)
44
func set(_ value: Float, forKey key: String)

WordPress/Classes/Stores/UserPersistentStoreFactory.swift renamed to Modules/Sources/WordPressShared/UserPersistentRepository/UserPersistentStoreFactory.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,13 @@ import Foundation
66
/// If it is evident that this kind of thing is no longer needed after migration is complete, we can remove this
77
/// and update call-sites to call `standard` directly.
88
@objc
9-
final class UserPersistentStoreFactory: NSObject {
10-
static func instance() -> UserPersistentRepository {
9+
public final class UserPersistentStoreFactory: NSObject {
10+
public static func instance() -> UserPersistentRepository {
1111
UserDefaults.standard
1212
}
1313

1414
@objc
15-
static func userDefaultsInstance() -> UserDefaults {
15+
public static func userDefaultsInstance() -> UserDefaults {
1616
return UserDefaults.standard
1717
}
1818
}

WordPress/Classes/Models/UserSettings.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import Foundation
2+
import WordPressShared
23

34
struct UserSettings {
45
/// Stores all `UserSettings` keys.

WordPress/Classes/Services/AppUpdate/AppUpdateCoordinator.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import Foundation
2+
import WordPressShared
23

34
struct AppUpdateType {
45
let appStoreInfo: AppStoreLookupResponse.AppStoreInfo

WordPress/Classes/Services/NotificationSettingsService.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import Foundation
22
import WordPressKit
3+
import WordPressShared
34

45
/// This service encapsulates the Restful API related to WordPress Notifications.
56
///

WordPress/Classes/Stores/RemoteConfigStore.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import Foundation
2+
import WordPressShared
23

34
fileprivate extension DispatchQueue {
45
static let remoteConfigStoreQueue = DispatchQueue(label: "remote-config-store-queue")

WordPress/Classes/Stores/UserPersistentRepository.swift

Lines changed: 0 additions & 5 deletions
This file was deleted.

WordPress/Classes/Stores/UserPersistentRepositoryUtility.swift

Lines changed: 1 addition & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -1,50 +1,6 @@
1-
import Foundation
2-
3-
private enum UPRUConstants {
4-
static let promptKey = "onboarding_notifications_prompt_displayed"
5-
static let questionKey = "onboarding_question_selection"
6-
static let notificationPrimerAlertWasDisplayed = "NotificationPrimerAlertWasDisplayed"
7-
static let notificationsTabAccessCount = "NotificationsTabAccessCount"
8-
static let notificationPrimerInlineWasAcknowledged = "notificationPrimerInlineWasAcknowledged"
9-
static let secondNotificationsAlertCount = "secondNotificationsAlertCount"
10-
static let hasShownCustomAppIconUpgradeAlert = "custom-app-icon-upgrade-alert-shown"
11-
static let savedPostsPromoWasDisplayed = "SavedPostsV1PromoWasDisplayed"
12-
static let currentAnnouncementsKey = "currentAnnouncements"
13-
static let currentAnnouncementsDateKey = "currentAnnouncementsDate"
14-
static let announcementsVersionDisplayedKey = "announcementsVersionDisplayed"
15-
static let isJPContentImportCompleteKey = "jetpackContentImportComplete"
16-
static let jetpackContentMigrationStateKey = "jetpackContentMigrationState"
17-
static let mediaAspectRatioModeEnabledKey = "mediaAspectRatioModeEnabled"
18-
static let readerSidebarSelectionKey = "readerSidebarSelectionKey"
19-
static let isReaderSelectedKey = "isReaderSelectedKey"
20-
static let readerSearchHistoryKey = "readerSearchHistoryKey"
21-
static let readerDidSelectInterestsKey = "readerDidSelectInterestsKey"
22-
}
23-
24-
protocol UserPersistentRepositoryUtility: AnyObject {
25-
var onboardingNotificationsPromptDisplayed: Bool { get set }
26-
var notificationPrimerAlertWasDisplayed: Bool { get set }
27-
}
1+
import WordPressShared
282

293
extension UserPersistentRepositoryUtility {
30-
var onboardingNotificationsPromptDisplayed: Bool {
31-
get {
32-
UserPersistentStoreFactory.instance().bool(forKey: UPRUConstants.promptKey)
33-
}
34-
set {
35-
UserPersistentStoreFactory.instance().set(newValue, forKey: UPRUConstants.promptKey)
36-
}
37-
}
38-
39-
var notificationPrimerAlertWasDisplayed: Bool {
40-
get {
41-
UserPersistentStoreFactory.instance().bool(forKey: UPRUConstants.notificationPrimerAlertWasDisplayed)
42-
}
43-
set {
44-
UserPersistentStoreFactory.instance().set(newValue, forKey: UPRUConstants.notificationPrimerAlertWasDisplayed)
45-
}
46-
}
47-
484
var notificationsTabAccessCount: Int {
495
get {
506
UserPersistentStoreFactory.instance().integer(forKey: UPRUConstants.notificationsTabAccessCount)

WordPress/Classes/System/Root View/RootViewPresenter.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import Foundation
2+
import WordPressShared
23

34
protocol RootViewPresenter: AnyObject {
45
var rootViewController: UIViewController { get }

WordPress/Classes/Utility/AppAppearance.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import UIKit
2+
import WordPressShared
23

34
/// Encapsulates UIUserInterfaceStyle getting and setting for the app's
45
/// main window. Allows users to override the interface style for the app.

WordPress/Classes/Utility/BackgroundTasks/WeeklyRoundupBackgroundTask.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import CoreData
22
import Foundation
33
import WordPressData
4+
import WordPressShared
45

56
/// The main data provider for Weekly Roundup information.
67
///

WordPress/Classes/Utility/KeychainTools.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import Foundation
22
import Security
3+
import WordPressShared
34

45
private let keychainDebugWipeArgument = "WipeKeychainItem"
56

WordPress/Classes/Utility/Migration/ContentMigrationCoordinator.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import WordPressShared
2+
13
/// Encapsulates logic related to content migration from WordPress to Jetpack.
24
///
35
@objc class ContentMigrationCoordinator: NSObject {

WordPress/Classes/Utility/OverlayFrequencyTracker.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import Foundation
2+
import WordPressShared
23

34
protocol OverlaySource {
45
var key: String { get }

WordPress/Classes/ViewRelated/Blog/Blog Dashboard/Cards/DashboardJetpackSocialCardCell.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import SwiftUI
22
import AutomatticTracks
3+
import WordPressShared
34

45
class DashboardJetpackSocialCardCell: DashboardCollectionViewCell {
56

WordPress/Classes/ViewRelated/Blog/Blog Dashboard/Service/BlogDashboardPersonalizationService.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import Foundation
2+
import WordPressShared
23

34
/// `BlogDashboardPersonalizable` is a protocol that defines the requirements for personalizing blog dashboard items.
45
/// It provides properties to access personalization key and settings scope specific to the blog dashboard.

WordPress/Classes/ViewRelated/Blog/Blog Dashboard/Service/BlogDashboardService.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import Foundation
22
import WordPressKit
3+
import WordPressShared
34

45
final class BlogDashboardService {
56

WordPress/Classes/ViewRelated/Blog/BloggingReminders/BloggingRemindersFlow.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import UIKit
22
import WordPressFlux
3+
import WordPressShared
34
import WordPressUI
45

56
final class BloggingRemindersFlow {

WordPress/Classes/ViewRelated/Blog/Onboarding Questions Prompt/OnboardingEnableNotificationsViewController.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import UIKit
2+
import WordPressShared
23

34
class OnboardingEnableNotificationsViewController: UIViewController {
45
@IBOutlet weak var titleLabel: UILabel!

WordPress/Classes/ViewRelated/Developer/WeeklyRoundupDebugScreen.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import BackgroundTasks
22
import SwiftUI
3+
import WordPressShared
34

45
struct BlueButton: ButtonStyle {
56
func makeBody(configuration: Configuration) -> some View {

WordPress/Classes/ViewRelated/Jetpack/Branding/Menu Card/JetpackBrandingMenuCardPresenter.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import Foundation
2+
import WordPressShared
23

34
class JetpackBrandingMenuCardPresenter {
45

WordPress/Classes/ViewRelated/Jetpack/Install/JetpackInstallPluginHelper.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import WordPressShared
2+
13
@objc
24
class JetpackInstallPluginHelper: NSObject {
35

WordPress/Classes/ViewRelated/Me/App Settings/Boolean User Defaults/BooleanUserDefaultsDebugViewModel.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import Combine
22
import SwiftUI
33
import WordPressData
4+
import WordPressShared
45

56
final class BooleanUserDefaultsDebugViewModel: ObservableObject {
67

WordPress/Classes/ViewRelated/NUX/Helpers/WordPressAuthenticationManager.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import Foundation
22
import SFHFKeychainUtils
33
import WordPressAuthenticator
4+
import WordPressShared
45
import Gridicons
56
import UIKit
67

WordPress/Classes/ViewRelated/Notifications/Controllers/NotificationsViewController+PushPrimer.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import WordPressShared
2+
13
// MARK: - Push Notification Primer
24
//
35
extension NotificationsViewController {

WordPress/Classes/ViewRelated/Notifications/Controllers/NotificationsViewController/NotificationsViewModel.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import AutomatticTracks
22
import WordPressData
3+
import WordPressShared
34
import Foundation
45

56
final class NotificationsViewModel {

WordPress/Classes/ViewRelated/Post/PostSettingsViewController+JetpackSocial.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import SwiftUI
22
import AutomatticTracks
3+
import WordPressShared
34

45
extension PostSettingsViewController {
56

WordPress/Classes/ViewRelated/Post/Prepublishing/PrepublishingViewController.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import UIKit
22
import Combine
33
import SwiftUI
44
import WordPressData
5+
import WordPressShared
56
import WordPressUI
67

78
enum PrepublishingSheetResult {

WordPress/Classes/ViewRelated/Stats/Helpers/SiteStatsInformation.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import Foundation
2+
import WordPressShared
23

34
/// Singleton class to contain site related information for Stats.
45
///

WordPress/Classes/ViewRelated/Stats/Insights/SiteStatsPinnedItemStore.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import Foundation
2+
import WordPressShared
23

34
// A protocol to constrain Site Stats pinned items together
45
protocol SiteStatsPinnable { /* not implemented */ }

WordPress/Classes/ViewRelated/Stats/SiteStatsDashboardViewController.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import UIKit
2+
import WordPressShared
23

34
enum StatsTabType: Int, FilterTabBarItem, CaseIterable {
45
case insights = 0

WordPress/Classes/ViewRelated/Support/SupportConfiguration.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import Foundation
2+
import WordPressShared
23

34
enum SupportConfiguration {
45
case zendesk

WordPress/Classes/ViewRelated/Support/SupportTableViewController.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import UIKit
22
import WordPressAuthenticator
3+
import WordPressShared
34

45
class SupportTableViewController: UITableViewController {
56

WordPress/Classes/ViewRelated/System/Fancy Alerts/FancyAlertViewController+AppIcons.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import UIKit
2+
import WordPressShared
23
import WordPressUI
34

45
extension FancyAlertViewController {

WordPress/Classes/ViewRelated/System/Fancy Alerts/FancyAlertViewController+SavedPosts.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import UIKit
22
import Gridicons
3+
import WordPressShared
34
import WordPressUI
45

56
extension FancyAlertViewController {

WordPress/Classes/ViewRelated/System/Floating Create Button/CreateButtonCoordinator.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import Gridicons
22
import WordPressFlux
3+
import WordPressShared
34
import WordPressUI
45

56
@objc class CreateButtonCoordinator: NSObject {

WordPress/Classes/ViewRelated/WhatsNew/Data store/Cache/AnnouncementsCache.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import WordPressKit
2+
import WordPressShared
23

34
/// Generic feature announcement cache
45
protocol AnnouncementsCache {

WordPress/Jetpack/Classes/System/JetpackWindowManager.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import Combine
22
import Foundation
3+
import WordPressShared
34

45
class JetpackWindowManager: WindowManager {
56

WordPress/Jetpack/Classes/ViewRelated/WordPress-to-Jetpack Migration/Common/Navigation/MigrationFlowCoordinator.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import Combine
22
import UserNotifications
3+
import WordPressShared
34

45
/// Coordinator for the migration to jetpack flow
56
final class MigrationFlowCoordinator: ObservableObject {

WordPress/Jetpack/Classes/ViewRelated/WordPress-to-Jetpack Migration/Success card/MigrationSuccessCardView.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import UIKit
2+
import WordPressShared
23

34
@objc
45
class MigrationSuccessCardView: UIView {

WordPress/WordPressTest/Blog Dashboard/Cards/DashboardJetpackSocialCardCellTests.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import WordPressShared
12
import XCTest
23
@testable import WordPress
34

@@ -66,6 +67,7 @@ class DashboardJetpackSocialCardCellTests: CoreDataTestCase {
6667
// Given
6768
let blog = createTestBlog()
6869
let dotComID = try XCTUnwrap(blog.dotComID)
70+
// FIXME: Using this production type in the test will mess the global state
6971
let repository = UserPersistentStoreFactory.instance()
7072
let key = DashboardJetpackSocialCardCell.Constants.hideNoConnectionViewKey
7173

WordPress/WordPressTest/InMemoryUserDefaults.swift

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
import Foundation
2-
@testable import WordPress
1+
import WordPressShared
32

43
class InMemoryUserDefaults: UserPersistentRepository {
54

0 commit comments

Comments
 (0)