Skip to content
This repository was archived by the owner on Sep 23, 2024. It is now read-only.

Commit c47095c

Browse files
committed
⚠️ Start to fix subclass name issue
1 parent 11c532a commit c47095c

File tree

3 files changed

+18
-13
lines changed

3 files changed

+18
-13
lines changed

Sources/EasyFirebase/Services/Auth/EasyUser.swift

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -84,11 +84,6 @@ open class EasyUser: IndexedDocument {
8484
/// The user's email address.
8585
public internal(set) var email: String
8686

87-
/// The user's username.
88-
///
89-
/// This value is automatically generated based on the user's email upon account creation.
90-
public internal(set) var username: String
91-
9287
/// The user's display name.
9388
///
9489
/// This value is automatically updated to a suggested display name when an account is created.
@@ -100,6 +95,13 @@ open class EasyUser: IndexedDocument {
10095
/// You can specify a default profile image by setting `EasyAuth.defaultProfileImageURLs`.
10196
public var profileImageURL: URL?
10297

98+
// MARK: - Objective C Exposed Mixed Properties
99+
100+
/// The user's username.
101+
///
102+
/// This value is automatically generated based on the user's email upon account creation.
103+
@objc public internal(set) var username: String
104+
103105
// MARK: - Inherited Properties
104106

105107
public var index: Int?
@@ -200,10 +202,11 @@ public extension EasyUser {
200202
- parameter suggestionGenerator: A function that takes in a username and provides a new username (hopefully unique). See **Discussion** for more information.
201203
- parameter completion: The completion handler. See **Discussion** for more information.
202204
*/
203-
func safelyUpdateUsername(to newUsername: String,
204-
suggesting suggestionGenerator: @escaping (String) -> String = defaultSuggestionGenerator,
205-
completion: @escaping (Error?, String?) -> Void) {
206-
EasyAuth.checkUsernameAvailable(newUsername, forUserType: Self.self) { available in
205+
func safelyUpdateUsername<T>(to newUsername: String,
206+
ofType type: T.Type,
207+
suggesting suggestionGenerator: @escaping (String) -> String = defaultSuggestionGenerator,
208+
completion: @escaping (Error?, String?) -> Void) where T: EasyUser {
209+
EasyAuth.checkUsernameAvailable(newUsername, forUserType: T.self) { available in
207210
if available {
208211
self.unsafelyUpdateUsername(to: newUsername) { error in
209212
completion(error, nil)
@@ -227,7 +230,7 @@ public extension EasyUser {
227230
*/
228231
func unsafelyUpdateUsername(to newUsername: String, completion: @escaping (Error?) -> Void = { _ in }) {
229232
self.username = newUsername
230-
set(\.username)
233+
set(\.username, completion: completion)
231234
}
232235

233236
/**

Sources/EasyFirebase/Services/Firestore/Querying.swift

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,8 @@ extension EasyFirestore {
9999
}
100100

101101
private static func `where`<T, V>(_ conditions: [Condition<T, V>], order: Order?, limit: Int?, completion: @escaping ([T]) -> Void) where T: Document {
102-
let collection = db.collection(String(describing: T.self))
102+
let collectionName = String(describing: T.self)
103+
let collection = db.collection(collectionName)
103104
guard conditions.count > 0 else { return }
104105
var query: Query = conditions.first!.apply(to: collection)
105106
for condition in conditions.dropFirst() {
@@ -126,8 +127,8 @@ extension EasyFirestore {
126127
if let object = object {
127128
arr.append(object)
128129
}
129-
completion(arr)
130130
}
131+
completion(arr)
131132
}
132133
})
133134
}

Sources/EasyFirebase/Services/Firestore/Storage.swift

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,8 @@ extension EasyFirestore {
5151
*/
5252
public static func set<T, U>(_ path: KeyPath<T, U>, in document: T, completion: @escaping (Error?) -> Void = { _ in }) where T: Document, U: Codable {
5353
let value = document[keyPath: path]
54-
db.collection(String(describing: T.self)).document(document.id).updateData([path.string: value], completion: completion)
54+
let collectionName = String(describing: T.self)
55+
db.collection(collectionName).document(document.id).updateData([path.string: value], completion: completion)
5556
}
5657

5758
/**

0 commit comments

Comments
 (0)