improved `in_reply_to` displaying

This commit is contained in:
Mariotaku Lee 2017-04-27 14:02:57 +08:00
parent 680b888f62
commit 8283c03bdb
No known key found for this signature in database
GPG Key ID: 15C10F89D7C33535
1 changed files with 10 additions and 1 deletions

View File

@ -81,7 +81,7 @@ fun Status.toParcelable(accountKey: UserKey): ParcelableStatus {
result.favorite_count = status.favouritesCount
result.in_reply_to_status_id = status.inReplyToId
result.in_reply_to_user_key = status.inReplyToAccountId?.let { UserKey(it, accountKey.host) }
result.in_reply_to_user_key = status.inReplyToAccountId?.let { UserKey(it, null) }
val account = status.account
result.user_key = account.getKey(accountKey.host)
@ -102,6 +102,15 @@ fun Status.toParcelable(accountKey: UserKey): ParcelableStatus {
extras.display_text_range = calculateDisplayTextRange(result.spans, result.media)
// Try to complete mastodon `in_reply_to` info
val inReplyToMention = result.mentions?.firstOrNull {
it.key.id == result.in_reply_to_user_key?.id
}
if (inReplyToMention != null) {
result.in_reply_to_name = inReplyToMention.name
result.in_reply_to_screen_name = inReplyToMention.screen_name
}
result.extras = extras
return result
}