mirror of
https://github.com/Novaloop-AG/element-x-android.git
synced 2026-11-03 16:10:00 +00:00
Try fixing 'Timeline Event object has already been destroyed' (#5675)
This will display a fallback notification. I don't see how the current code could cause it, but I tried to re-structure it a bit so we don't have nested `use` usages and `timestamp` is fetched ahead of time.
This commit is contained in:
committed by
GitHub
parent
2b08cb77ee
commit
d6e0489701
+3
-2
@@ -39,6 +39,7 @@ class NotificationMapper(
|
|||||||
isDirect = item.roomInfo.isDirect,
|
isDirect = item.roomInfo.isDirect,
|
||||||
activeMembersCount = item.roomInfo.joinedMembersCount.toInt(),
|
activeMembersCount = item.roomInfo.joinedMembersCount.toInt(),
|
||||||
)
|
)
|
||||||
|
val timestamp = item.timestamp() ?: clock.epochMillis()
|
||||||
NotificationData(
|
NotificationData(
|
||||||
sessionId = sessionId,
|
sessionId = sessionId,
|
||||||
eventId = eventId,
|
eventId = eventId,
|
||||||
@@ -53,8 +54,8 @@ class NotificationMapper(
|
|||||||
isDm = isDm,
|
isDm = isDm,
|
||||||
isEncrypted = item.roomInfo.isEncrypted.orFalse(),
|
isEncrypted = item.roomInfo.isEncrypted.orFalse(),
|
||||||
isNoisy = item.isNoisy.orFalse(),
|
isNoisy = item.isNoisy.orFalse(),
|
||||||
timestamp = item.timestamp() ?: clock.epochMillis(),
|
timestamp = timestamp,
|
||||||
content = item.event.use { notificationContentMapper.map(it) }.getOrThrow(),
|
content = notificationContentMapper.map(item.event).getOrThrow(),
|
||||||
hasMention = item.hasMention.orFalse(),
|
hasMention = item.hasMention.orFalse(),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
+2
-1
@@ -25,8 +25,9 @@ class TimelineEventToNotificationContentMapper {
|
|||||||
fun map(timelineEvent: TimelineEvent): Result<NotificationContent> {
|
fun map(timelineEvent: TimelineEvent): Result<NotificationContent> {
|
||||||
return runCatchingExceptions {
|
return runCatchingExceptions {
|
||||||
timelineEvent.use {
|
timelineEvent.use {
|
||||||
|
val senderId = UserId(timelineEvent.senderId())
|
||||||
timelineEvent.eventType().use { eventType ->
|
timelineEvent.eventType().use { eventType ->
|
||||||
eventType.toContent(senderId = UserId(timelineEvent.senderId()))
|
eventType.toContent(senderId = senderId)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user