Skip to content

Commit

Permalink
Update code to match changes in firebase/firebase-ios-sdk#9101
Browse files Browse the repository at this point in the history
  • Loading branch information
peterfriese committed Feb 4, 2022
1 parent 73ed490 commit 80197e0
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 46 deletions.
10 changes: 10 additions & 0 deletions FirestoreCodableSamples.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@
887A4A7F2608EA7E009ACBB1 /* MappingEnumsScreen.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MappingEnumsScreen.swift; sourceTree = "<group>"; };
887DD2B325C47A23003F7A99 /* Book.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Book.swift; sourceTree = "<group>"; };
888F881325C46A9C00DCE039 /* GoogleService-Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = "GoogleService-Info.plist"; sourceTree = "<group>"; };
88BBF4452790B29800A6D1A7 /* firebase-ios-sdk */ = {isa = PBXFileReference; lastKnownFileType = wrapper; name = "firebase-ios-sdk"; path = "../../../Projects/Incubation/Firebase/firebase-documentsnapshot-typing/firebase-ios-sdk"; sourceTree = "<group>"; };
/* End PBXFileReference section */

/* Begin PBXFrameworksBuildPhase section */
Expand All @@ -78,6 +79,7 @@
8845BD6D25C46965002AEC45 = {
isa = PBXGroup;
children = (
88BBF4442790B29800A6D1A7 /* Packages */,
8845BD7825C46965002AEC45 /* FirestoreCodableSamples */,
8845BD7725C46965002AEC45 /* Products */,
887DD2AD25C479FD003F7A99 /* Frameworks */,
Expand Down Expand Up @@ -178,6 +180,14 @@
path = ViewModels;
sourceTree = "<group>";
};
88BBF4442790B29800A6D1A7 /* Packages */ = {
isa = PBXGroup;
children = (
88BBF4452790B29800A6D1A7 /* firebase-ios-sdk */,
);
name = Packages;
sourceTree = "<group>";
};
/* End PBXGroup section */

/* Begin PBXNativeTarget section */
Expand Down
14 changes: 3 additions & 11 deletions FirestoreCodableSamples/Screens/CustomizeMappingScreen.swift
Original file line number Diff line number Diff line change
Expand Up @@ -38,17 +38,9 @@ class CustomizeMappingViewModel: ObservableObject {

switch result {
case .success(let programmingLanguage):
if let programmingLanguage = programmingLanguage {
// A ProgrammingLanguage value was successfully initialized from the DocumentSnapshot.
self?.errorMessage = nil
return programmingLanguage
}
else {
// A nil value was successfully initialized from the DocumentSnapshot,
// or the DocumentSnapshot was nil.
self?.errorMessage = "Document doesn't exist."
return nil
}
// A ProgrammingLanguage value was successfully initialized from the DocumentSnapshot.
self?.errorMessage = nil
return programmingLanguage
case .failure(let error):
// A Book value could not be initialized from the DocumentSnapshot.
switch error {
Expand Down
17 changes: 4 additions & 13 deletions FirestoreCodableSamples/Screens/MappingColorsScreen.swift
Original file line number Diff line number Diff line change
Expand Up @@ -35,22 +35,13 @@ class MappingColorsViewModel: ObservableObject {

self?.colorEntries = documents.compactMap { queryDocumentSnapshot in
let result = Result { try queryDocumentSnapshot.data(as: ColorEntry.self) }

switch result {
case .success(let colorEntry):
if let colorEntry = colorEntry {
// A ColorEntry value was successfully initialized from the DocumentSnapshot.
self?.errorMessage = nil
return colorEntry
}
else {
// A nil value was successfully initialized from the DocumentSnapshot,
// or the DocumentSnapshot was nil.
self?.errorMessage = "Document doesn't exist."
return nil
}
// A ColorEntry value was successfully initialized from the DocumentSnapshot.
self?.errorMessage = nil
return colorEntry
case .failure(let error):
// A Book value could not be initialized from the DocumentSnapshot.
// A ColorEntry value could not be initialized from the DocumentSnapshot.
switch error {
case DecodingError.typeMismatch(_, let context):
self?.errorMessage = "\(error.localizedDescription): \(context.debugDescription)"
Expand Down
14 changes: 3 additions & 11 deletions FirestoreCodableSamples/Screens/MappingEnumsScreen.swift
Original file line number Diff line number Diff line change
Expand Up @@ -76,17 +76,9 @@ class MappingEnumsViewModel: ObservableObject {

switch result {
case .success(let article):
if let article = article {
// An Article value was successfully initialized from the DocumentSnapshot.
self?.errorMessage = nil
return article
}
else {
// A nil value was successfully initialized from the DocumentSnapshot,
// or the DocumentSnapshot was nil.
self?.errorMessage = "Document doesn't exist."
return nil
}
// An Article value was successfully initialized from the DocumentSnapshot.
self?.errorMessage = nil
return article
case .failure(let error):
// An Article value could not be initialized from the DocumentSnapshot.
switch error {
Expand Down
14 changes: 3 additions & 11 deletions FirestoreCodableSamples/Screens/MappingGeoPointsScreen.swift
Original file line number Diff line number Diff line change
Expand Up @@ -82,17 +82,9 @@ class MappingGeoPointsViewModel: ObservableObject {

switch result {
case .success(let office):
if let office = office {
// An Office value was successfully initialized from the DocumentSnapshot.
self?.errorMessage = nil
return office
}
else {
// A nil value was successfully initialized from the DocumentSnapshot,
// or the DocumentSnapshot was nil.
self?.errorMessage = "Document doesn't exist."
return nil
}
// An Office value was successfully initialized from the DocumentSnapshot.
self?.errorMessage = nil
return office
case .failure(let error):
// An Office value could not be initialized from the DocumentSnapshot.
switch error {
Expand Down

0 comments on commit 80197e0

Please sign in to comment.