mirror of
https://github.com/SchildiChat/SchildiChat-android.git
synced 2025-03-28 16:59:01 +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
CHANGES.md
matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/widgets/helper
|
@ -13,6 +13,7 @@ Bugfix 🐛:
|
||||||
- UrlPreview should be updated when the url is edited and changed (#2678)
|
- 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)
|
- 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)
|
- Crashes reported by PlayStore (new in 1.0.14) (#2707)
|
||||||
|
- Widgets: Support $matrix_widget_id parameter (#2748)
|
||||||
|
|
||||||
Translations 🗣:
|
Translations 🗣:
|
||||||
-
|
-
|
||||||
|
|
|
@ -53,7 +53,7 @@ internal class WidgetFactory @Inject constructor(private val userDataSource: Use
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
val isAddedByMe = widgetEvent.senderId == userId
|
val isAddedByMe = widgetEvent.senderId == userId
|
||||||
val computedUrl = widgetContent.computeURL(widgetEvent.roomId)
|
val computedUrl = widgetContent.computeURL(widgetEvent.roomId, widgetId)
|
||||||
return Widget(
|
return Widget(
|
||||||
widgetContent = widgetContent,
|
widgetContent = widgetContent,
|
||||||
event = widgetEvent,
|
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
|
var computedUrl = url ?: return null
|
||||||
val myUser = userDataSource.getUser(userId)
|
val myUser = userDataSource.getUser(userId)
|
||||||
computedUrl = computedUrl
|
computedUrl = computedUrl
|
||||||
.replace("\$matrix_user_id", userId)
|
.replace("\$matrix_user_id", userId)
|
||||||
.replace("\$matrix_display_name", myUser?.displayName ?: userId)
|
.replace("\$matrix_display_name", myUser?.displayName ?: userId)
|
||||||
.replace("\$matrix_avatar_url", myUser?.avatarUrl ?: "")
|
.replace("\$matrix_avatar_url", myUser?.avatarUrl ?: "")
|
||||||
|
.replace("\$matrix_widget_id", widgetId)
|
||||||
|
|
||||||
if (roomId != null) {
|
if (roomId != null) {
|
||||||
computedUrl = computedUrl.replace("\$matrix_room_id", roomId)
|
computedUrl = computedUrl.replace("\$matrix_room_id", roomId)
|
||||||
|
|
Loading…
Add table
Reference in a new issue