File tree 5 files changed +10
-13
lines changed
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 Original file line number Diff line number Diff line change @@ -50,8 +50,8 @@ actual class FirebaseUser internal constructor(val android: com.google.firebase.
50
50
actual suspend fun updatePhoneNumber (credential : PhoneAuthCredential ) = android.updatePhoneNumber(credential.android).await().run { Unit }
51
51
actual suspend fun updateProfile (displayName : String? , photoUrl : String? ) {
52
52
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) } }
55
55
.build()
56
56
android.updateProfile(request).await()
57
57
}
Original file line number Diff line number Diff line change 4
4
5
5
package dev.gitlive.firebase.auth
6
6
7
- // workaround for https://youtrack.jetbrains.com/issue/KT-48836
8
- internal val UNCHANGED = " "
9
-
10
7
expect class FirebaseUser {
11
8
val uid: String
12
9
val displayName: String?
@@ -32,7 +29,7 @@ expect class FirebaseUser {
32
29
suspend fun updateEmail (email : String )
33
30
suspend fun updatePassword (password : String )
34
31
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 )
36
33
suspend fun verifyBeforeUpdateEmail (newEmail : String , actionCodeSettings : ActionCodeSettings ? = null)
37
34
}
38
35
Original file line number Diff line number Diff line change @@ -69,8 +69,8 @@ actual class FirebaseUser internal constructor(val ios: FIRUser) {
69
69
actual suspend fun updatePhoneNumber (credential : PhoneAuthCredential ) = ios.await { updatePhoneNumberCredential(credential.ios, it) }.run { Unit }
70
70
actual suspend fun updateProfile (displayName : String? , photoUrl : String? ) {
71
71
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) }) }
74
74
ios.await { request.commitChangesWithCompletion(it) }
75
75
}
76
76
actual suspend fun verifyBeforeUpdateEmail (newEmail : String , actionCodeSettings : ActionCodeSettings ? ) = ios.await {
Original file line number Diff line number Diff line change @@ -46,9 +46,9 @@ actual class FirebaseUser internal constructor(val js: User) {
46
46
actual suspend fun updatePassword (password : String ) = rethrow { updatePassword(js, password).await() }
47
47
actual suspend fun updatePhoneNumber (credential : PhoneAuthCredential ) = rethrow { updatePhoneNumber(js, credential.js).await() }
48
48
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,
52
52
)
53
53
updateProfile(js, json(* request.toTypedArray())).await()
54
54
}
Original file line number Diff line number Diff line change @@ -48,8 +48,8 @@ actual class FirebaseUser internal constructor(val android: com.google.firebase.
48
48
actual suspend fun updatePhoneNumber (credential : PhoneAuthCredential ) = android.updatePhoneNumber(credential.android).await().run { Unit }
49
49
actual suspend fun updateProfile (displayName : String? , photoUrl : String? ) {
50
50
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) }) }
53
53
.build()
54
54
android.updateProfile(request).await()
55
55
}
You can’t perform that action at this time.
0 commit comments