@@ -163,8 +163,11 @@ class ThreadFragment : Fragment() {
163
163
_binding = null
164
164
}
165
165
166
- fun resetThreadBackupCache () {
167
- threadViewModel.resetThreadBackupCache()
166
+ fun resetThreadState () = with (threadViewModel) {
167
+ isExpandedMap = mutableMapOf ()
168
+ isThemeTheSameMap = mutableMapOf ()
169
+ hasSuperCollapsedBlockBeenClicked = false
170
+ verticalScroll = null
168
171
}
169
172
170
173
private fun setupUi () = with (binding) {
@@ -205,11 +208,11 @@ class ThreadFragment : Fragment() {
205
208
}
206
209
}
207
210
208
- private fun setupAdapter () = with (binding.messagesList ) {
211
+ private fun setupAdapter () = with (threadViewModel ) {
209
212
210
- adapter = ThreadAdapter (
213
+ binding.messagesList. adapter = ThreadAdapter (
211
214
shouldLoadDistantResources = shouldLoadDistantResources(),
212
- isCalendarEventExpandedMap = threadViewModel. isCalendarEventExpandedMap,
215
+ isCalendarEventExpandedMap = isCalendarEventExpandedMap,
213
216
threadAdapterState = object : ThreadAdapterState {
214
217
override var isExpandedMap by threadViewModel::isExpandedMap
215
218
override var isThemeTheSameMap by threadViewModel::isThemeTheSameMap
@@ -234,7 +237,7 @@ class ThreadFragment : Fragment() {
234
237
},
235
238
onDeleteDraftClicked = { message ->
236
239
trackMessageActionsEvent(" deleteDraft" )
237
- mainViewModel.currentMailbox.value?.let { mailbox -> threadViewModel. deleteDraft(message, mailbox) }
240
+ mainViewModel.currentMailbox.value?.let { mailbox -> deleteDraft(message, mailbox) }
238
241
},
239
242
onAttachmentClicked = {
240
243
trackAttachmentActionsEvent(" open" )
@@ -276,13 +279,13 @@ class ThreadFragment : Fragment() {
276
279
navigateToDownloadProgressDialog(attachment, attachmentIntentType, ThreadFragment ::class .java.name)
277
280
},
278
281
replyToCalendarEvent = { attendanceState, message ->
279
- threadViewModel. replyToCalendarEvent(
282
+ replyToCalendarEvent(
280
283
attendanceState,
281
284
message,
282
285
).observe(viewLifecycleOwner) { successfullyUpdated ->
283
286
if (successfullyUpdated) {
284
287
snackbarManager.setValue(getString(R .string.snackbarCalendarChoiceSent))
285
- threadViewModel. fetchCalendarEvents(listOf (message), forceFetch = true )
288
+ fetchCalendarEvents(listOf (message), forceFetch = true )
286
289
} else {
287
290
snackbarManager.setValue(getString(R .string.errorCalendarChoiceCouldNotBeSent))
288
291
threadAdapter.undoUserAttendanceClick(message)
@@ -307,14 +310,14 @@ class ThreadFragment : Fragment() {
307
310
),
308
311
)
309
312
310
- addItemDecoration(
313
+ binding.messagesList. addItemDecoration(
311
314
DividerItemDecorator (
312
315
divider = InsetDrawable (dividerDrawable(context), 0 ),
313
316
shouldIgnoreView = { view -> view.tag == ThreadAdapter .IGNORE_DIVIDER_TAG },
314
317
),
315
318
)
316
319
317
- recycledViewPool.setMaxRecycledViews(0 , 0 )
320
+ binding.messagesList. recycledViewPool.setMaxRecycledViews(0 , 0 )
318
321
threadAdapter.stateRestorationPolicy = StateRestorationPolicy .PREVENT_WHEN_EMPTY
319
322
}
320
323
0 commit comments