Skip to content

Commit 3488473

Browse files
committed
Merge tag 'null_conversation_body_crash' into develop
2 parents ed206e3 + 06e8b13 commit 3488473

File tree

2 files changed

+23
-18
lines changed

2 files changed

+23
-18
lines changed

app/build.gradle

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@ android {
1919
applicationId "tech.bigfig.roma"
2020
minSdkVersion 21
2121
targetSdkVersion 28
22-
versionCode 95
23-
versionName "8.1"
22+
versionCode 96
23+
versionName "8.1.1"
2424
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
2525
vectorDrawables.useSupportLibrary = true
2626

app/src/main/java/tech/bigfig/roma/components/conversation/ConversationsRepository.kt

Lines changed: 21 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -40,28 +40,33 @@ class ConversationsRepository @Inject constructor(val mastodonApi: MastodonApi,
4040
val conversations = HashMap<String, Status>()
4141
val conversationsRecentFirst = HashMap<Date, Status>()
4242
var lastFetchedId = ""
43+
val conversationList = ArrayList<Conversation>()
4344

44-
for (status in body?.reversed()!!) {
45-
if (lastFetchedId.isBlank()) lastFetchedId = status.id
46-
status.pleroma?.conversation_id?.let { id -> conversations[id] = status }
47-
}
45+
body?.let {
46+
for (status in body.reversed()) {
47+
if (lastFetchedId.isBlank()) lastFetchedId = status.id
48+
status.pleroma?.conversation_id?.let { id -> conversations[id] = status }
49+
}
4850

49-
for (entry in conversations.entries) {
50-
entry.let { entry.value.createdAt.let { it1 -> conversationsRecentFirst.put(it1, entry.value) } }
51-
}
51+
for (entry in conversations.entries) {
52+
entry.let { entry.value.createdAt.let { it1 -> conversationsRecentFirst.put(it1, entry.value) } }
53+
}
5254

53-
val conversationList = ArrayList<Conversation>()
55+
for (entry in conversationsRecentFirst.toSortedMap(reverseOrder())) {
5456

55-
for (entry in conversationsRecentFirst.toSortedMap(reverseOrder())) {
57+
entry.value.pleroma?.conversation_id.let {
5658

57-
val convoToAdd = Conversation(
58-
id = entry.value.pleroma?.conversation_id!!,
59-
accounts = getAccountObjects(mastodonApi, entry.value.mentions),
60-
lastStatus = entry.value,
61-
unread = false
62-
)
59+
entry.value.pleroma?.conversation_id?.let { it1 ->
6360

64-
conversationList.add(convoToAdd)
61+
conversationList.add(Conversation(
62+
id = it1,
63+
accounts = getAccountObjects(mastodonApi, entry.value.mentions),
64+
lastStatus = entry.value,
65+
unread = false)
66+
)
67+
}
68+
}
69+
}
6570
}
6671

6772
return ConversationHolder(lastFetchedId, conversationList)

0 commit comments

Comments
 (0)