@@ -192,34 +192,8 @@ class ScheduleRemindersFragment :
192192 ToolbarType .INTERNAL_NON_COLLAPSIBLE -> setupInternalFragmentToolbar(isCollapsible = false )
193193 }
194194
195- // Set up add button
196195 binding.floatingActionButtonAdd.setOnClickListener { addReminder() }
197-
198- // Troubleshoot snackbar: shown persistently when checks find a warning/error.
199- // Tapping "Fix" opens the full troubleshooting screen.
200- lifecycleScope.launch {
201- troubleshootingViewModel.state
202- .flowWithLifecycle(viewLifecycleOwner.lifecycle, Lifecycle .State .STARTED )
203- .collect { state ->
204- val message =
205- when (state.summaryStatus) {
206- SummaryStatus .Ok , SummaryStatus .Warning -> {
207- troubleshootingSnackbar?.dismiss()
208- troubleshootingSnackbar = null
209- return @collect
210- }
211- SummaryStatus .Error -> " Reminders are unavailable"
212- }
213- if (troubleshootingSnackbar?.isShown == true ) {
214- troubleshootingSnackbar?.setText(message)
215- return @collect
216- }
217- troubleshootingSnackbar =
218- showSnackbar(text = message, duration = Snackbar .LENGTH_INDEFINITE ) {
219- setAction(" Fix" ) { openTroubleshootingScreen() }
220- }
221- }
222- }
196+ lifecycleScope.launch { setupTroubleshootingSnackbar() }
223197
224198 // Set up recycler view
225199 binding.recyclerView.layoutManager = LinearLayoutManager (requireContext())
@@ -249,6 +223,34 @@ class ScheduleRemindersFragment :
249223 super .onDestroyView()
250224 }
251225
226+ /* *
227+ * Sets up the troubleshooting snackbar which is shown persistently when checks find a warning/error.
228+ * Tapping "Fix" opens the full troubleshooting screen.
229+ */
230+ private suspend fun setupTroubleshootingSnackbar () {
231+ troubleshootingViewModel.state
232+ .flowWithLifecycle(viewLifecycleOwner.lifecycle, Lifecycle .State .STARTED )
233+ .collect { state ->
234+ val message =
235+ when (state.summaryStatus) {
236+ SummaryStatus .Ok , SummaryStatus .Warning -> {
237+ troubleshootingSnackbar?.dismiss()
238+ troubleshootingSnackbar = null
239+ return @collect
240+ }
241+ SummaryStatus .Error -> " Reminders are unavailable"
242+ }
243+ if (troubleshootingSnackbar?.isShown == true ) {
244+ troubleshootingSnackbar?.setText(message)
245+ return @collect
246+ }
247+ troubleshootingSnackbar =
248+ showSnackbar(text = message, duration = Snackbar .LENGTH_INDEFINITE ) {
249+ setAction(" Fix" ) { openTroubleshootingScreen() }
250+ }
251+ }
252+ }
253+
252254 private fun setupExternalActivityToolbar () {
253255 binding.appbar.isVisible = false
254256 requireAnkiActivity().apply {
0 commit comments