@@ -89,13 +89,14 @@ fun PluviaMain(
89
89
mutableStateOf(MessageDialogState (false ))
90
90
}
91
91
var annoyingDialogShown by rememberSaveable { mutableStateOf(false ) }
92
+ var hasCrashedRecently by rememberSaveable { mutableStateOf(PrefManager .recentlyCrashed) }
92
93
93
94
val setLoadingDialogVisible: (Boolean ) -> Unit = { loadingDialogVisible = it }
94
95
val setLoadingProgress: (Float ) -> Unit = { loadingProgress = it }
95
96
val setMessageDialogState: (MessageDialogState ) -> Unit = { msgDialogState = it }
96
97
97
98
LaunchedEffect (navController) {
98
- Timber .i( " navController changed" )
99
+ Timber .i(" navController changed" )
99
100
if (! hasLaunched) {
100
101
hasLaunched = true
101
102
Timber .i(" Creating on destination changed listener" )
@@ -175,7 +176,23 @@ fun PluviaMain(
175
176
// TODO: add preference for first screen on login
176
177
Timber .i(" Navigating to library" )
177
178
navController.navigate(PluviaScreen .Home .name)
178
- if (! (PrefManager .tipped || BuildConfig .GOLD ) && ! annoyingDialogShown) {
179
+
180
+ // If a crash happen, lets not ask for a tip yet.
181
+ // Instead, ask the user to contribute their issues to be addressed.
182
+ if (! annoyingDialogShown && hasCrashedRecently) {
183
+ annoyingDialogShown = true
184
+ msgDialogState = MessageDialogState (
185
+ visible = true ,
186
+ type = DialogType .CRASH ,
187
+ title = " Recent Crash" ,
188
+ message = " Sorry about that!\n " +
189
+ " It would be nice to know about the recent issue you've had.\n " +
190
+ " You can view and export the most recent crash log in the app's settings " +
191
+ " and attach it as a Github issue in the project's repository.\n " +
192
+ " Link to the Github repo is also in settings!" ,
193
+ confirmBtnText = " OK" ,
194
+ )
195
+ } else if (! (PrefManager .tipped || BuildConfig .GOLD ) && ! annoyingDialogShown) {
179
196
annoyingDialogShown = true
180
197
msgDialogState = MessageDialogState (
181
198
visible = true ,
@@ -266,6 +283,7 @@ fun PluviaMain(
266
283
msgDialogState = MessageDialogState (visible = false )
267
284
}
268
285
}
286
+
269
287
DialogType .SYNC_CONFLICT -> {
270
288
onConfirmClick = {
271
289
preLaunchApp(
@@ -295,6 +313,7 @@ fun PluviaMain(
295
313
msgDialogState = MessageDialogState (false )
296
314
}
297
315
}
316
+
298
317
DialogType .SYNC_FAIL -> {
299
318
onDismissClick = {
300
319
setMessageDialogState(MessageDialogState (false ))
@@ -304,6 +323,7 @@ fun PluviaMain(
304
323
}
305
324
onConfirmClick = null
306
325
}
326
+
307
327
DialogType .PENDING_UPLOAD_IN_PROGRESS -> {
308
328
onDismissClick = {
309
329
setMessageDialogState(MessageDialogState (false ))
@@ -313,6 +333,7 @@ fun PluviaMain(
313
333
}
314
334
onConfirmClick = null
315
335
}
336
+
316
337
DialogType .PENDING_UPLOAD -> {
317
338
onConfirmClick = {
318
339
setMessageDialogState(MessageDialogState (false ))
@@ -333,6 +354,7 @@ fun PluviaMain(
333
354
setMessageDialogState(MessageDialogState (false ))
334
355
}
335
356
}
357
+
336
358
DialogType .APP_SESSION_ACTIVE -> {
337
359
onConfirmClick = {
338
360
setMessageDialogState(MessageDialogState (false ))
@@ -353,6 +375,7 @@ fun PluviaMain(
353
375
setMessageDialogState(MessageDialogState (false ))
354
376
}
355
377
}
378
+
356
379
DialogType .APP_SESSION_SUSPENDED -> {
357
380
onDismissClick = {
358
381
setMessageDialogState(MessageDialogState (false ))
@@ -362,6 +385,7 @@ fun PluviaMain(
362
385
}
363
386
onConfirmClick = null
364
387
}
388
+
365
389
DialogType .PENDING_OPERATION_NONE -> {
366
390
onDismissClick = {
367
391
setMessageDialogState(MessageDialogState (false ))
@@ -371,6 +395,7 @@ fun PluviaMain(
371
395
}
372
396
onConfirmClick = null
373
397
}
398
+
374
399
DialogType .MULTIPLE_PENDING_OPERATIONS -> {
375
400
onDismissClick = {
376
401
setMessageDialogState(MessageDialogState (false ))
@@ -380,6 +405,21 @@ fun PluviaMain(
380
405
}
381
406
onConfirmClick = null
382
407
}
408
+
409
+ DialogType .CRASH -> {
410
+ onDismissClick = null
411
+ onDismissRequest = {
412
+ PrefManager .recentlyCrashed = false
413
+ hasCrashedRecently = false
414
+ setMessageDialogState(MessageDialogState (false ))
415
+ }
416
+ onConfirmClick = {
417
+ PrefManager .recentlyCrashed = false
418
+ hasCrashedRecently = false
419
+ setMessageDialogState(MessageDialogState (false ))
420
+ }
421
+ }
422
+
383
423
else -> {
384
424
onDismissRequest = null
385
425
onDismissClick = null
0 commit comments