mirror of
https://github.com/element-hq/element-android
synced 2024-11-27 11:59:12 +03:00
Support $matrix_widget_id parameter.
This commit is contained in:
parent
fef0404ac7
commit
06be3e691d
2 changed files with 4 additions and 2 deletions
|
@ -13,6 +13,7 @@ Bugfix 🐛:
|
|||
- UrlPreview should be updated when the url is edited and changed (#2678)
|
||||
- When receiving a new pepper from identity server, use it on the next hash lookup (#2708)
|
||||
- Crashes reported by PlayStore (new in 1.0.14) (#2707)
|
||||
- Widgets: Support $matrix_widget_id parameter (#2748)
|
||||
|
||||
Translations 🗣:
|
||||
-
|
||||
|
|
|
@ -53,7 +53,7 @@ internal class WidgetFactory @Inject constructor(private val userDataSource: Use
|
|||
}
|
||||
}
|
||||
val isAddedByMe = widgetEvent.senderId == userId
|
||||
val computedUrl = widgetContent.computeURL(widgetEvent.roomId)
|
||||
val computedUrl = widgetContent.computeURL(widgetEvent.roomId, widgetId)
|
||||
return Widget(
|
||||
widgetContent = widgetContent,
|
||||
event = widgetEvent,
|
||||
|
@ -65,13 +65,14 @@ internal class WidgetFactory @Inject constructor(private val userDataSource: Use
|
|||
)
|
||||
}
|
||||
|
||||
private fun WidgetContent.computeURL(roomId: String?): String? {
|
||||
private fun WidgetContent.computeURL(roomId: String?, widgetId: String): String? {
|
||||
var computedUrl = url ?: return null
|
||||
val myUser = userDataSource.getUser(userId)
|
||||
computedUrl = computedUrl
|
||||
.replace("\$matrix_user_id", userId)
|
||||
.replace("\$matrix_display_name", myUser?.displayName ?: userId)
|
||||
.replace("\$matrix_avatar_url", myUser?.avatarUrl ?: "")
|
||||
.replace("\$matrix_widget_id", widgetId)
|
||||
|
||||
if (roomId != null) {
|
||||
computedUrl = computedUrl.replace("\$matrix_room_id", roomId)
|
||||
|
|
Loading…
Reference in a new issue