Skip to content

Commit

Permalink
fix: Use User.id.value instead of User.id.toString()
Browse files Browse the repository at this point in the history
I had implicitly assumed that a value class wrapping a String would
simply return the wrapped String in a toString() call, but this is not
the case.

Fixes #62
  • Loading branch information
Joseph Cooper committed Mar 10, 2023
1 parent 46c3dd0 commit 13aea2c
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ class FirebaseChartsService(
}

private fun FirebaseFirestore.mapsCollection(user: User) =
collection("users").document(user.id.toString()).collection("maps")
collection("users").document(user.id.value).collection("maps")
}

/*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,6 @@ import com.squareup.workflow1.ui.WorkflowUiExperimentalApi

internal val UserDetailsViewFactory: ViewFactory<UserDetailsScreen> =
LayoutRunner.bind(LayoutUserDetailsBinding::inflate) { userDetailsScreen, _ ->
userId.text = userDetailsScreen.user.id.id
userId.text = userDetailsScreen.user.id.value
this.btnSignOut.setOnClickListener { userDetailsScreen.onLogOutClicked() }
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ private object MapModelProperties {

public object ChartModelToMapSerializer : ToMapSerializer<UnsavedChartModel> {
override operator fun invoke(model: UnsavedChartModel): Map<String, String> =
hashMapOf(TITLE to model.title, USER_ID to model.userId.id)
hashMapOf(TITLE to model.title, USER_ID to model.userId.value)
}

public fun UnsavedChartModel.serializedToMap(): Map<String, Any?> = ChartModelToMapSerializer(this)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package com.omricat.maplibrarian.model

import kotlinx.serialization.Serializable

@Serializable @JvmInline public value class UserUid(public val id: String)
@Serializable @JvmInline public value class UserUid(public val value: String)

public interface User {
public val displayName: String
Expand Down

0 comments on commit 13aea2c

Please sign in to comment.