Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
M
matrix-android-sdk
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Circles
matrix-android-sdk
Commits
6c620d92
Commit
6c620d92
authored
1 year ago
by
Taras
Browse files
Options
Downloads
Patches
Plain Diff
Fix merge
parent
a3a42524
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/room/timeline/TimelineEvent.kt
+6
-30
6 additions, 30 deletions
...ix/android/sdk/api/session/room/timeline/TimelineEvent.kt
with
6 additions
and
30 deletions
matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/room/timeline/TimelineEvent.kt
+
6
−
30
View file @
6c620d92
...
@@ -28,7 +28,6 @@ import org.matrix.android.sdk.api.session.events.model.isLiveLocation
...
@@ -28,7 +28,6 @@ import org.matrix.android.sdk.api.session.events.model.isLiveLocation
import
org.matrix.android.sdk.api.session.events.model.isPoll
import
org.matrix.android.sdk.api.session.events.model.isPoll
import
org.matrix.android.sdk.api.session.events.model.isReply
import
org.matrix.android.sdk.api.session.events.model.isReply
import
org.matrix.android.sdk.api.session.events.model.isSticker
import
org.matrix.android.sdk.api.session.events.model.isSticker
import
org.matrix.android.sdk.api.session.events.model.toContent
import
org.matrix.android.sdk.api.session.events.model.toModel
import
org.matrix.android.sdk.api.session.events.model.toModel
import
org.matrix.android.sdk.api.session.room.model.EventAnnotationsSummary
import
org.matrix.android.sdk.api.session.room.model.EventAnnotationsSummary
import
org.matrix.android.sdk.api.session.room.model.ReadReceipt
import
org.matrix.android.sdk.api.session.room.model.ReadReceipt
...
@@ -145,16 +144,16 @@ fun TimelineEvent.getEditedEventId(): String? {
...
@@ -145,16 +144,16 @@ fun TimelineEvent.getEditedEventId(): String? {
*/
*/
fun
TimelineEvent
.
getLastMessageContent
():
MessageContent
?
{
fun
TimelineEvent
.
getLastMessageContent
():
MessageContent
?
{
return
when
(
root
.
getClearType
())
{
return
when
(
root
.
getClearType
())
{
EventType
.
STICKER
->
root
.
getClearContent
().
toModel
<
MessageStickerContent
>()
EventType
.
STICKER
->
root
.
getClearContent
().
toModel
<
MessageStickerContent
>()
// XXX
// XXX
// Polls/Beacon are not message contents like others as there is no msgtype subtype to discriminate moshi parsing
// Polls/Beacon are not message contents like others as there is no msgtype subtype to discriminate moshi parsing
// so toModel<MessageContent> won't parse them correctly
// so toModel<MessageContent> won't parse them correctly
// It's discriminated on event type instead. Maybe it shouldn't be MessageContent at all to avoid confusion?
// It's discriminated on event type instead. Maybe it shouldn't be MessageContent at all to avoid confusion?
in
EventType
.
POLL_START
.
values
->
(
getLastPollEditNewContent
()
?:
root
.
getClearContent
()).
toModel
<
MessagePollContent
>()
in
EventType
.
POLL_START
.
values
->
(
getLastPollEditNewContent
()
?:
root
.
getClearContent
()).
toModel
<
MessagePollContent
>()
in
EventType
.
POLL_END
.
values
->
(
getLastPollEditNewContent
()
?:
root
.
getClearContent
()).
toModel
<
MessageEndPollContent
>()
in
EventType
.
POLL_END
.
values
->
(
getLastPollEditNewContent
()
?:
root
.
getClearContent
()).
toModel
<
MessageEndPollContent
>()
in
EventType
.
STATE_ROOM_BEACON_INFO
.
values
->
(
getLastEditNewContent
()
?:
root
.
getClearContent
()).
toModel
<
MessageBeaconInfoContent
>()
in
EventType
.
STATE_ROOM_BEACON_INFO
.
values
->
(
getLastEditNewContent
()
?:
root
.
getClearContent
()).
toModel
<
MessageBeaconInfoContent
>()
in
EventType
.
BEACON_LOCATION_DATA
.
values
->
(
getLastEditNewContent
()
?:
root
.
getClearContent
()).
toModel
<
MessageBeaconLocationDataContent
>()
in
EventType
.
BEACON_LOCATION_DATA
.
values
->
(
getLastEditNewContent
()
?:
root
.
getClearContent
()).
toModel
<
MessageBeaconLocationDataContent
>()
else
->
(
getLastEditNewContent
()
?:
root
.
getClearContent
()).
toModel
()
else
->
(
getLastEditNewContent
()
?:
root
.
getClearContent
()).
toModel
()
}
}
}
}
...
@@ -177,30 +176,7 @@ private fun ensureCorrectFormattedBodyInTextReply(messageTextContent: MessageTex
...
@@ -177,30 +176,7 @@ private fun ensureCorrectFormattedBodyInTextReply(messageTextContent: MessageTex
format
=
MessageFormat
.
FORMAT_MATRIX_HTML
,
format
=
MessageFormat
.
FORMAT_MATRIX_HTML
,
)
)
}
}
else
->
messageTextContent
else
->
messageTextContent
}
}
private
fun
TimelineEvent
.
getLastPollEditNewContent
():
Content
?
{
return
annotations
?.
editSummary
?.
latestEdit
?.
getClearContent
()
?.
toModel
<
MessagePollContent
>()
?.
newContent
}
/**
* Not every client sends a formatted body in the last edited event since this is not required in the
* [Matrix specification](https://spec.matrix.org/v1.4/client-server-api/#applying-mnew_content).
* We must ensure there is one so that it is still considered as a reply when rendering the message.
*/
private
fun
ensureCorrectFormattedBodyInTextReply
(
messageTextContent
:
MessageTextContent
,
previousFormattedBody
:
String
):
MessageTextContent
{
return
when
{
messageTextContent
.
formattedBody
.
isNullOrEmpty
()
&&
previousFormattedBody
.
contains
(
MX_REPLY_END_TAG
)
->
{
// take previous formatted body with the new body content
val
newFormattedBody
=
previousFormattedBody
.
replaceAfterLast
(
MX_REPLY_END_TAG
,
messageTextContent
.
body
)
messageTextContent
.
copy
(
formattedBody
=
newFormattedBody
,
format
=
MessageFormat
.
FORMAT_MATRIX_HTML
,
)
}
else
->
messageTextContent
}
}
}
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment