Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
mbrandonw committed Apr 14, 2024
1 parent bc53d51 commit 57e74cf
Show file tree
Hide file tree
Showing 8 changed files with 17 additions and 21 deletions.
5 changes: 1 addition & 4 deletions Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -112,10 +112,7 @@ var package = Package(
),
.target(
name: "ServerConfig",
dependencies: [
"ApiClient",
"Build",
]
dependencies: ["Build"]
),
.target(
name: "ServerRouter",
Expand Down
3 changes: 1 addition & 2 deletions Sources/ActiveGamesFeature/ActiveGamesView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -340,8 +340,7 @@ private let relativeDateFormatter = RelativeDateTimeFormatter()

struct ActiveGamesView_Previews: PreviewProvider {
static var previews: some View {
@Shared(.savedGames) var savedGames = SavedGamesState()
savedGames = SavedGamesState(
@Shared(.savedGames) var savedGames = SavedGamesState(
dailyChallengeUnlimited: update(.mock) {
$0?.moves = [.highScoringMove]
$0?.gameContext = .dailyChallenge(.init(rawValue: .dailyChallengeId))
Expand Down
6 changes: 3 additions & 3 deletions Sources/AppFeature/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import Build
@Reducer
public struct AppDelegateReducer {
public struct State: Equatable {
@Shared(.build) var build = Build()
public init() {}
}

Expand All @@ -25,6 +24,7 @@ public struct AppDelegateReducer {
@Dependency(\.remoteNotifications.register) var registerForRemoteNotifications
@Dependency(\.applicationClient.setUserInterfaceStyle) var setUserInterfaceStyle
@Dependency(\.userNotifications) var userNotifications
@Shared(.build) var build = Build()

public init() {}

Expand Down Expand Up @@ -84,14 +84,14 @@ public struct AppDelegateReducer {

case let .didRegisterForRemoteNotifications(.success(tokenData)):
let token = tokenData.map { String(format: "%02.2hhx", $0) }.joined()
return .run { [build = state.build] _ in
return .run { _ in
let settings = await self.userNotifications.getNotificationSettings()
_ = try await self.apiClient.apiRequest(
route: .push(
.register(
.init(
authorizationStatus: .init(rawValue: settings.authorizationStatus.rawValue),
build: build.number,
build: self.build.number,
token: token
)
)
Expand Down
8 changes: 4 additions & 4 deletions Sources/AppFeature/AppView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@ public struct AppReducer {
public struct State: Equatable {
public var appDelegate: AppDelegateReducer.State
@Presents public var destination: Destination.State?
@Shared(.hasShownFirstLaunchOnboarding) var hasShownFirstLaunchOnboarding = false
@SharedReader(.hasShownFirstLaunchOnboarding) var hasShownFirstLaunchOnboarding = false
public var home: Home.State
@Shared(.installationTime) var installationTime = Date().timeIntervalSince1970
@Shared(.installationTime) var installationTime = 0
@SharedReader(.serverConfig) var serverConfig = ServerConfig()
@Shared(.savedGames) var savedGames = SavedGamesState()

Expand Down Expand Up @@ -238,8 +238,8 @@ public struct AppReducer {
remoteNotifications: self.remoteNotifications,
userNotifications: self.userNotifications
)
async let refresh = serverConfig.persistence.reload()
_ = try await (register, refresh)
async let refresh: Void = serverConfig.persistence.reload()
_ = await (register, refresh)
} catch: { _, _ in
}

Expand Down
2 changes: 1 addition & 1 deletion Sources/ChangelogFeature/ChangelogView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,12 @@ import UIApplicationClient
public struct ChangelogReducer {
@ObservableState
public struct State: Equatable {
@SharedReader(.build) var build = Build()
public var changelog: IdentifiedArrayOf<Change.State>
public var currentBuild: Build.Number
public var isRequestInFlight: Bool
public var isUpdateButtonVisible: Bool
@SharedReader(.serverConfig) var serverConfig = ServerConfig()
@Shared(.build) var build = Build()

public init(
changelog: IdentifiedArrayOf<Change.State> = [],
Expand Down
8 changes: 4 additions & 4 deletions Sources/ClientModels/AppStoragePersistenceKeys.swift
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
import ComposableArchitecture

extension PersistenceKey where Self == AppStorageKey<Double> {
extension PersistenceReaderKey where Self == AppStorageKey<Double> {
public static var installationTime: Self {
appStorage("installationTimeKey")
}
}
extension PersistenceKey where Self == AppStorageKey<Bool> {
extension PersistenceReaderKey where Self == AppStorageKey<Bool> {
public static var hasShownFirstLaunchOnboarding: Self {
AppStorageKey("hasShownFirstLaunchOnboardingKey")
}
}
extension PersistenceKey where Self == AppStorageKey<Int> {
extension PersistenceReaderKey where Self == AppStorageKey<Int> {
public static var multiplayerOpensCount: Self {
AppStorageKey("multiplayerOpensCount")
}
}
extension PersistenceKey where Self == AppStorageKey<Double> {
extension PersistenceReaderKey where Self == AppStorageKey<Double> {
public static var lastReviewRequest: Self {
AppStorageKey("last-review-request-timeinterval")
}
Expand Down
2 changes: 1 addition & 1 deletion Sources/ClientModels/SavedGamesState.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public struct SavedGamesState: Codable, Equatable {
}
}

extension PersistenceKey where Self == FileStorageKey<SavedGamesState> {
extension PersistenceReaderKey where Self == FileStorageKey<SavedGamesState> {
public static var savedGames: Self {
fileStorage(.documentsDirectory.appending(path: "saved-games.json"))
}
Expand Down
4 changes: 2 additions & 2 deletions Sources/HomeFeature/Home.swift
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ public struct Home {
@Dependency(\.mainRunLoop.now.date) var now
@Dependency(\.audioPlayer.play) var playSound
@Dependency(\.timeZone) var timeZone
@SharedReader(.serverConfig) var serverConfig = ServerConfig()

public init() {}

Expand Down Expand Up @@ -293,7 +294,6 @@ public struct Home {
)
await send(.authenticationResponse(currentPlayerEnvelope))

@SharedReader(.serverConfig) var serverConfig = ServerConfig()
async let serverConfigResponse: Void = $serverConfig.persistence.reload()

async let dailyChallengeResponse: Void = send(
Expand Down Expand Up @@ -324,7 +324,7 @@ public struct Home {
}
)
)
_ = try await (
_ = await (
serverConfigResponse, dailyChallengeResponse, weekInReviewResponse, activeMatchesResponse
)
} catch {}
Expand Down

0 comments on commit 57e74cf

Please sign in to comment.