Fix crash with null lastStatus in Conversations (#1042)
This commit is contained in:
parent
fe1e9f4100
commit
fdc66288b1
3 changed files with 6 additions and 5 deletions
|
@ -182,5 +182,5 @@ fun Conversation.toEntity(accountId: Long) =
|
|||
id,
|
||||
accounts.map { it.toEntity() },
|
||||
unread,
|
||||
lastStatus.toEntity()
|
||||
lastStatus!!.toEntity()
|
||||
)
|
||||
|
|
|
@ -103,8 +103,9 @@ class ConversationsRepository @Inject constructor(val mastodonApi: MastodonApi,
|
|||
}
|
||||
|
||||
private fun insertResultIntoDb(accountId: Long, result: List<Conversation>?) {
|
||||
result?.let { conversations ->
|
||||
db.conversationDao().insert(conversations.map { it.toEntity(accountId) })
|
||||
}
|
||||
result?.filter { it.lastStatus != null }
|
||||
?.map{ it.toEntity(accountId) }
|
||||
?.let { db.conversationDao().insert(it) }
|
||||
|
||||
}
|
||||
}
|
|
@ -20,6 +20,6 @@ import com.google.gson.annotations.SerializedName
|
|||
data class Conversation(
|
||||
val id: String,
|
||||
val accounts: List<Account>,
|
||||
@SerializedName("last_status") val lastStatus: Status,
|
||||
@SerializedName("last_status") val lastStatus: Status?, // should never be null, but apparently its possible https://github.com/tuskyapp/Tusky/issues/1038
|
||||
val unread: Boolean
|
||||
)
|
Loading…
Reference in a new issue