Create UserDataSource.getUserOrDefault().
This commit is contained in:
parent
5a2d74443d
commit
032fa37b64
@ -66,6 +66,8 @@ internal class UserDataSource @Inject constructor(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun getUserOrDefault(userId: String): User = getUser(userId) ?: User(userId)
|
||||||
|
|
||||||
fun getUserLive(userId: String): LiveData<Optional<User>> {
|
fun getUserLive(userId: String): LiveData<Optional<User>> {
|
||||||
val liveData = monarchy.findAllMappedWithChanges(
|
val liveData = monarchy.findAllMappedWithChanges(
|
||||||
{ UserEntity.where(it, userId) },
|
{ UserEntity.where(it, userId) },
|
||||||
|
@ -74,7 +74,7 @@ internal class WidgetFactory @Inject constructor(
|
|||||||
// Ref: https://github.com/matrix-org/matrix-widget-api/blob/master/src/templating/url-template.ts#L29-L33
|
// Ref: https://github.com/matrix-org/matrix-widget-api/blob/master/src/templating/url-template.ts#L29-L33
|
||||||
fun computeURL(widget: Widget, isLightTheme: Boolean): String? {
|
fun computeURL(widget: Widget, isLightTheme: Boolean): String? {
|
||||||
var computedUrl = widget.widgetContent.url ?: return null
|
var computedUrl = widget.widgetContent.url ?: return null
|
||||||
val myUser = userDataSource.getUser(userId) ?: User(userId)
|
val myUser = userDataSource.getUserOrDefault(userId)
|
||||||
|
|
||||||
val keyValue = widget.widgetContent.data.mapKeys { "\$${it.key}" }.toMutableMap()
|
val keyValue = widget.widgetContent.data.mapKeys { "\$${it.key}" }.toMutableMap()
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user