Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Always notify Account when FirestoreAccountStorage receives snapshot #49

Merged
merged 3 commits into from
Dec 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/build-and-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ jobs:
setupfirebaseemulator: true
path: Tests/UITests
customcommand: |
firebase emulators:exec 'set -o pipefail && xcodebuild test -project UITests.xcodeproj -scheme TestApp -destination "platform=iOS Simulator,name=iPhone 15 Pro" -resultBundlePath UITests.xcresult -derivedDataPath ".derivedData" CODE_SIGN_IDENTITY="" CODE_SIGNING_REQUIRED=NO -skipPackagePluginValidation -skipMacroValidation | xcbeautify'
firebase emulators:exec 'set -o pipefail && xcodebuild test -project UITests.xcodeproj -scheme TestApp -destination "platform=iOS Simulator,name=iPhone 16 Pro" -resultBundlePath UITests.xcresult -derivedDataPath ".derivedData" CODE_SIGN_IDENTITY="" CODE_SIGNING_REQUIRED=NO -skipPackagePluginValidation -skipMacroValidation | xcbeautify'
uploadcoveragereport:
name: Upload Coverage Report
needs: [buildandtest, buildandtestuitests]
Expand Down
2 changes: 1 addition & 1 deletion Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ let package = Package(
.package(url: "https://github.com/StanfordSpezi/SpeziFoundation", from: "2.0.0"),
.package(url: "https://github.com/StanfordSpezi/Spezi", from: "1.7.1"),
.package(url: "https://github.com/StanfordSpezi/SpeziViews", from: "1.6.0"),
.package(url: "https://github.com/StanfordSpezi/SpeziAccount", from: "2.0.0"),
.package(url: "https://github.com/StanfordSpezi/SpeziAccount", from: "2.1.1"),
.package(url: "https://github.com/firebase/firebase-ios-sdk", from: "11.0.0"),
.package(url: "https://github.com/apple/swift-atomics.git", from: "1.2.0")
] + swiftLintPackage(),
Expand Down
5 changes: 4 additions & 1 deletion Sources/SpeziFirebaseAccount/FirebaseAccountService.swift
Original file line number Diff line number Diff line change
Expand Up @@ -529,7 +529,7 @@
try await mapFirebaseAccountError {
if modifications.modifiedDetails.contains(AccountKeys.userId) {
logger.debug("updateEmail(to:) for user.")
try await currentUser.updateEmail(to: modifications.modifiedDetails.userId)

Check warning on line 532 in Sources/SpeziFirebaseAccount/FirebaseAccountService.swift

View workflow job for this annotation

GitHub Actions / Build and Test Swift Package / Test using xcodebuild or run fastlane

'updateEmail(to:)' is deprecated: `updateEmail` is deprecated and will be removed in a future release. Use sendEmailVerification(beforeUpdatingEmail:) instead.

Check warning on line 532 in Sources/SpeziFirebaseAccount/FirebaseAccountService.swift

View workflow job for this annotation

GitHub Actions / Build and Test UI Tests / Test using xcodebuild or run fastlane

'updateEmail(to:)' is deprecated: `updateEmail` is deprecated and will be removed in a future release. Use sendEmailVerification(beforeUpdatingEmail:) instead.
}

if let password = modifications.modifiedDetails.password {
Expand Down Expand Up @@ -659,7 +659,10 @@
actionSemaphore.signal()
}

let details = buildUser(user, isNewUser: false, mergeWith: details)
// make sure to keep the `newUser` flag
let consideredNewUser = account.details?.isNewUser ?? false

let details = buildUser(user, isNewUser: consideredNewUser, mergeWith: details)
logger.debug("Update user details due to updates in the externally stored account details.")
account.supplyUserDetails(details)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -163,10 +163,6 @@ public actor FirestoreAccountStorage: AccountStorageProvider {

let details = buildAccountDetails(from: snapshot, keys: Array(keys))

guard !details.isEmpty else {
return
}

let localCache = localCache
await localCache.communicateRemoteChanges(for: accountId, details)

Expand Down
6 changes: 3 additions & 3 deletions Sources/SpeziFirestore/DocumentReference+AsyncAwait.swift
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ extension DocumentReference {
/// - isolation: The actor isolation to inherit.
/// - value: An instance of `Encodable` to be encoded to a document.
/// - encoder: An encoder instance to use to run the encoding.
public func setData<T: Encodable>( // swiftlint:disable:this function_default_parameter_at_end
public func setData<T: Encodable>(
isolation: isolated (any Actor)? = #isolation,
from value: T,
encoder: FirebaseFirestore.Firestore.Encoder = FirebaseFirestore.Firestore.Encoder()
Expand Down Expand Up @@ -110,7 +110,7 @@ extension DocumentReference {
/// - merge: Whether to merge the provided `Encodable` into any existing
/// document.
/// - encoder: An encoder instance to use to run the encoding.
public func setData<T: Encodable>( // swiftlint:disable:this function_default_parameter_at_end
public func setData<T: Encodable>(
isolation: isolated (any Actor)? = #isolation,
from value: T,
merge: Bool,
Expand Down Expand Up @@ -145,7 +145,7 @@ extension DocumentReference {
/// merge. Fields can contain dots to reference nested fields within the
/// document.
/// - encoder: An encoder instance to use to run the encoding.
public func setData<T: Encodable>( // swiftlint:disable:this function_default_parameter_at_end
public func setData<T: Encodable>(
isolation: isolated (any Actor)? = #isolation,
from value: T,
mergeFields: [Any],
Expand Down
Loading