Skip to content

Commit 03e8702

Browse files
committed
Removed the UNCHANGED logic from update profile
Should work on K2
1 parent e727265 commit 03e8702

File tree

5 files changed

+10
-13
lines changed
  • firebase-auth/src
    • androidMain/kotlin/dev/gitlive/firebase/auth
    • commonMain/kotlin/dev/gitlive/firebase/auth
    • iosMain/kotlin/dev/gitlive/firebase/auth
    • jsMain/kotlin/dev/gitlive/firebase/auth
    • jvmMain/kotlin/dev/gitlive/firebase/auth

5 files changed

+10
-13
lines changed

firebase-auth/src/androidMain/kotlin/dev/gitlive/firebase/auth/user.kt

+2-2
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,8 @@ actual class FirebaseUser internal constructor(val android: com.google.firebase.
5050
actual suspend fun updatePhoneNumber(credential: PhoneAuthCredential) = android.updatePhoneNumber(credential.android).await().run { Unit }
5151
actual suspend fun updateProfile(displayName: String?, photoUrl: String?) {
5252
val request = UserProfileChangeRequest.Builder()
53-
.apply { if(displayName !== UNCHANGED) setDisplayName(displayName) }
54-
.apply { if(photoUrl !== UNCHANGED) photoUri = photoUrl?.let { Uri.parse(it) } }
53+
.apply { setDisplayName(displayName) }
54+
.apply { photoUri = photoUrl?.let { Uri.parse(it) } }
5555
.build()
5656
android.updateProfile(request).await()
5757
}

firebase-auth/src/commonMain/kotlin/dev/gitlive/firebase/auth/user.kt

+1-4
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,6 @@
44

55
package dev.gitlive.firebase.auth
66

7-
//workaround for https://youtrack.jetbrains.com/issue/KT-48836
8-
internal val UNCHANGED = ""
9-
107
expect class FirebaseUser {
118
val uid: String
129
val displayName: String?
@@ -32,7 +29,7 @@ expect class FirebaseUser {
3229
suspend fun updateEmail(email: String)
3330
suspend fun updatePassword(password: String)
3431
suspend fun updatePhoneNumber(credential: PhoneAuthCredential)
35-
suspend fun updateProfile(displayName: String? = UNCHANGED, photoUrl: String? = UNCHANGED)
32+
suspend fun updateProfile(displayName: String? = this.displayName, photoUrl: String? = this.photoURL)
3633
suspend fun verifyBeforeUpdateEmail(newEmail: String, actionCodeSettings: ActionCodeSettings? = null)
3734
}
3835

firebase-auth/src/iosMain/kotlin/dev/gitlive/firebase/auth/user.kt

+2-2
Original file line numberDiff line numberDiff line change
@@ -69,8 +69,8 @@ actual class FirebaseUser internal constructor(val ios: FIRUser) {
6969
actual suspend fun updatePhoneNumber(credential: PhoneAuthCredential) = ios.await { updatePhoneNumberCredential(credential.ios, it) }.run { Unit }
7070
actual suspend fun updateProfile(displayName: String?, photoUrl: String?) {
7171
val request = ios.profileChangeRequest()
72-
.apply { if(displayName !== UNCHANGED) setDisplayName(displayName) }
73-
.apply { if(photoUrl !== UNCHANGED) setPhotoURL(photoUrl?.let { NSURL.URLWithString(it) }) }
72+
.apply { setDisplayName(displayName) }
73+
.apply { setPhotoURL(photoUrl?.let { NSURL.URLWithString(it) }) }
7474
ios.await { request.commitChangesWithCompletion(it) }
7575
}
7676
actual suspend fun verifyBeforeUpdateEmail(newEmail: String, actionCodeSettings: ActionCodeSettings?) = ios.await {

firebase-auth/src/jsMain/kotlin/dev/gitlive/firebase/auth/user.kt

+3-3
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,9 @@ actual class FirebaseUser internal constructor(val js: User) {
4646
actual suspend fun updatePassword(password: String) = rethrow { updatePassword(js, password).await() }
4747
actual suspend fun updatePhoneNumber(credential: PhoneAuthCredential) = rethrow { updatePhoneNumber(js, credential.js).await() }
4848
actual suspend fun updateProfile(displayName: String?, photoUrl: String?): Unit = rethrow {
49-
val request = listOfNotNull(
50-
displayName.takeUnless { it === UNCHANGED }?.let { "displayName" to it },
51-
photoUrl.takeUnless { it === UNCHANGED }?.let { "photoURL" to it }
49+
val request = listOf(
50+
"displayName" to displayName,
51+
"photoURL" to photoUrl,
5252
)
5353
updateProfile(js, json(*request.toTypedArray())).await()
5454
}

firebase-auth/src/jvmMain/kotlin/dev/gitlive/firebase/auth/user.kt

+2-2
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,8 @@ actual class FirebaseUser internal constructor(val android: com.google.firebase.
4848
actual suspend fun updatePhoneNumber(credential: PhoneAuthCredential) = android.updatePhoneNumber(credential.android).await().run { Unit }
4949
actual suspend fun updateProfile(displayName: String?, photoUrl: String?) {
5050
val request = UserProfileChangeRequest.Builder()
51-
.apply { if(displayName !== UNCHANGED) setDisplayName(displayName) }
52-
.apply { if(photoUrl !== UNCHANGED) setPhotoUri(photoUrl?.let { Uri.parse(it) }) }
51+
.apply { setDisplayName(displayName) }
52+
.apply { setPhotoUri(photoUrl?.let { Uri.parse(it) }) }
5353
.build()
5454
android.updateProfile(request).await()
5555
}

0 commit comments

Comments
 (0)