Repository navigation
fix: show the sync error instead of an empty inbox #19
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,13 @@ | ||
| package com.bansify.mail.ui.navigation | ||
|
|
||
| import androidx.compose.foundation.layout.Column | ||
| import androidx.compose.foundation.layout.Row | ||
| import androidx.compose.foundation.layout.fillMaxWidth | ||
| import androidx.compose.material3.MaterialTheme | ||
| import androidx.compose.material3.Surface | ||
| import androidx.compose.material3.Text | ||
| import androidx.compose.material3.TextButton | ||
| import androidx.compose.ui.Alignment | ||
| import androidx.compose.runtime.Composable | ||
| import androidx.compose.foundation.layout.fillMaxSize | ||
| import androidx.compose.ui.unit.dp | ||
|
|
@@ -108,10 +116,33 @@ fun MailNavGraph( | |
| return | ||
| } | ||
|
|
||
| NavHost( | ||
| navController = navController, | ||
| startDestination = InboxRoute | ||
| ) { | ||
| Column(modifier = Modifier.fillMaxSize()) { | ||
| // A failed sync used to leave the inbox silently empty; surface the reason instead. | ||
| uiState.syncError?.let { message -> | ||
| Surface( | ||
| color = MaterialTheme.colorScheme.errorContainer, | ||
| modifier = Modifier.fillMaxWidth(), | ||
| ) { | ||
| Row( | ||
| modifier = Modifier.padding(horizontal = 16.dp, vertical = 10.dp), | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Keep the banner content outside system insets.
|
||
| verticalAlignment = Alignment.CenterVertically, | ||
| ) { | ||
| Text( | ||
| text = message, | ||
| style = MaterialTheme.typography.bodySmall, | ||
| color = MaterialTheme.colorScheme.onErrorContainer, | ||
| modifier = Modifier.weight(1f), | ||
|
Comment on lines
+130
to
+134
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Limit the banner height for long error messages.
|
||
| ) | ||
| TextButton(onClick = { viewModel.refreshCurrentFolder(showSpinner = true) }) { | ||
| Text("Retry") | ||
| } | ||
| } | ||
| } | ||
| } | ||
| NavHost( | ||
| navController = navController, | ||
| startDestination = InboxRoute | ||
| ) { | ||
| composable<InboxRoute> { | ||
| InboxScreen( | ||
| uiState = uiState, | ||
|
|
@@ -292,4 +323,5 @@ fun MailNavGraph( | |
| ) | ||
| } | ||
| } | ||
| } | ||
| } | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Include the server message in sync errors.
If a 500 response contains
{"error":"database_error","message":"Database unavailable"}, the banner shows the status and error code, but notDatabase unavailable.toApiExceptiondoes not read themessagefield. Include the server message when present so the banner exposes the response detail.