[#1360] Shared state is broken on older ios versions

- Fixes for iOS 16 and older
This commit is contained in:
Lukas Korba 2024-09-26 12:08:17 +02:00
parent 98ccc6a235
commit 9fe249ee1b
7 changed files with 119 additions and 107 deletions

View File

@ -6,6 +6,11 @@ directly impact users rather than highlighting other crucial architectural updat
## [Unreleased] ## [Unreleased]
### Fixed
- Splash screen animation is blocked by the main thread on iOS 16 and older.
- Inactive hide balances button on iOS 16 and older.
- Inactive close button in the exchange rate hint bubble on iOS 16 and older.
## 1.2 build 9 (2024-09-17) ## 1.2 build 9 (2024-09-17)
### Fixed ### Fixed

View File

@ -26,7 +26,7 @@ class ExchangeRateProvider {
init() { init() {
if !_XCTIsTesting { if !_XCTIsTesting {
@Dependency (\.sdkSynchronizer) var sdkSynchronizer @Dependency(\.sdkSynchronizer) var sdkSynchronizer
cancellable = sdkSynchronizer.exchangeRateUSDStream().sink { [weak self] result in cancellable = sdkSynchronizer.exchangeRateUSDStream().sink { [weak self] result in
self?.resolveResult(result) self?.resolveResult(result)
@ -37,7 +37,7 @@ class ExchangeRateProvider {
func refreshExchangeRateUSD() { func refreshExchangeRateUSD() {
if !_XCTIsTesting { if !_XCTIsTesting {
// guard the feature is opted-in by a user // guard the feature is opted-in by a user
@Dependency (\.userStoredPreferences) var userStoredPreferences @Dependency(\.userStoredPreferences) var userStoredPreferences
guard let exchangeRate = userStoredPreferences.exchangeRate(), exchangeRate.automatic else { guard let exchangeRate = userStoredPreferences.exchangeRate(), exchangeRate.automatic else {
return return
@ -47,7 +47,7 @@ class ExchangeRateProvider {
return return
} }
@Dependency (\.sdkSynchronizer) var sdkSynchronizer @Dependency(\.sdkSynchronizer) var sdkSynchronizer
sdkSynchronizer.refreshExchangeRateUSD() sdkSynchronizer.refreshExchangeRateUSD()
} }
@ -69,7 +69,7 @@ class ExchangeRateProvider {
latestRate = result latestRate = result
@Dependency (\.zcashSDKEnvironment) var zcashSDKEnvironment @Dependency(\.zcashSDKEnvironment) var zcashSDKEnvironment
if isStale if isStale
&& result.state != .fetching && result.state != .fetching
@ -88,7 +88,7 @@ class ExchangeRateProvider {
} }
if latestRate.state == .success { if latestRate.state == .success {
@Dependency (\.zcashSDKEnvironment) var zcashSDKEnvironment @Dependency(\.zcashSDKEnvironment) var zcashSDKEnvironment
isStale = false isStale = false

View File

@ -115,6 +115,7 @@ extension Root {
case .splashFinished: case .splashFinished:
state.splashAppeared = true state.splashAppeared = true
exchangeRate.refreshExchangeRateUSD()
return .none return .none
case .tabs, .initialization, .onboarding, .sandbox, .updateStateAfterConfigUpdate, .alert, .phraseDisplay, .synchronizerStateChanged, case .tabs, .initialization, .onboarding, .sandbox, .updateStateAfterConfigUpdate, .alert, .phraseDisplay, .synchronizerStateChanged,

View File

@ -158,7 +158,6 @@ extension Root {
guard sdkSynchronizer.latestState().syncStatus.isPrepared else { guard sdkSynchronizer.latestState().syncStatus.isPrepared else {
return .none return .none
} }
exchangeRate.refreshExchangeRateUSD()
return .run { [state] send in return .run { [state] send in
do { do {
try await sdkSynchronizer.start(true) try await sdkSynchronizer.start(true)
@ -294,7 +293,6 @@ extension Root {
case .initialization(.initializationSuccessfullyDone(let uAddress)): case .initialization(.initializationSuccessfullyDone(let uAddress)):
state.tabsState.addressDetailsState.uAddress = uAddress state.tabsState.addressDetailsState.uAddress = uAddress
state.tabsState.settingsState.advancedSettingsState.uAddress = uAddress state.tabsState.settingsState.advancedSettingsState.uAddress = uAddress
exchangeRate.refreshExchangeRateUSD()
return .merge( return .merge(
.send(.initialization(.registerForSynchronizersUpdate)), .send(.initialization(.registerForSynchronizersUpdate)),
.publisher { .publisher {

View File

@ -146,6 +146,7 @@ public struct TabsView: View {
.zashiTitle { navBarView(store.selectedTab) } .zashiTitle { navBarView(store.selectedTab) }
.walletStatusPanel() .walletStatusPanel()
.overlayPreferenceValue(BoundsPreferenceKey.self) { preferences in .overlayPreferenceValue(BoundsPreferenceKey.self) { preferences in
WithPerceptionTracking {
if store.isRateTooltipEnabled { if store.isRateTooltipEnabled {
GeometryReader { geometry in GeometryReader { geometry in
preferences.map { preferences.map {
@ -161,7 +162,9 @@ public struct TabsView: View {
} }
} }
} }
}
.overlayPreferenceValue(ExchangeRateFeaturePreferenceKey.self) { preferences in .overlayPreferenceValue(ExchangeRateFeaturePreferenceKey.self) { preferences in
WithPerceptionTracking {
if store.isRateEducationEnabled { if store.isRateEducationEnabled {
GeometryReader { geometry in GeometryReader { geometry in
preferences.map { preferences.map {
@ -239,6 +242,7 @@ public struct TabsView: View {
} }
} }
} }
}
@ViewBuilder private func navBarView(_ tab: Tabs.State.Tab) -> some View { @ViewBuilder private func navBarView(_ tab: Tabs.State.Tab) -> some View {
switch tab { switch tab {

View File

@ -62,6 +62,7 @@ public struct ZatoshiRepresentationView: View {
} }
public var body: some View { public var body: some View {
WithPerceptionTracking {
HStack { HStack {
if isFee { if isFee {
Text(zatoshiStringRepresentation.feeFormat) Text(zatoshiStringRepresentation.feeFormat)
@ -91,6 +92,7 @@ public struct ZatoshiRepresentationView: View {
} }
} }
} }
}
} }
#Preview { #Preview {

View File

@ -15,6 +15,7 @@ struct HiddenIfSetModifier: ViewModifier {
@Shared(.appStorage(.sensitiveContent)) var isSensitiveContentHidden = false @Shared(.appStorage(.sensitiveContent)) var isSensitiveContentHidden = false
func body(content: Content) -> some View { func body(content: Content) -> some View {
WithPerceptionTracking {
VStack(spacing: 0) { VStack(spacing: 0) {
if isSensitiveContentHidden { if isSensitiveContentHidden {
Text(L10n.General.hideBalancesMostStandalone) Text(L10n.General.hideBalancesMostStandalone)
@ -23,6 +24,7 @@ struct HiddenIfSetModifier: ViewModifier {
} }
} }
} }
}
} }
extension Text { extension Text {