fix: not found handling for user profile

Signed-off-by: Infi <wingit@geist.ga>
This commit is contained in:
Infi 2023-08-30 03:05:50 +05:00
parent 5ede657f7e
commit 56ba789ca4
2 changed files with 11 additions and 0 deletions

View File

@ -47,11 +47,15 @@ fun UserContextSheet(
val server = RevoltAPI.serverCache[serverId]
var profile by remember { mutableStateOf<Profile?>(null) }
var profileNotFound by remember { mutableStateOf(false) }
LaunchedEffect(user) {
try {
user?.id?.let { fetchUserProfile(it) }?.let { profile = it }
} catch (e: Error) {
if (e.message == "NotFound") {
profileNotFound = true
}
e.printStackTrace()
}
}
@ -110,6 +114,12 @@ fun UserContextSheet(
} else if (profile != null) {
Text(
text = stringResource(id = R.string.user_context_sheet_bio_empty),
color = LocalContentColor.current.copy(alpha = 0.6f)
)
} else if (profileNotFound) {
Text(
text = stringResource(id = R.string.user_context_sheet_bio_not_found),
color = LocalContentColor.current.copy(alpha = 0.6f)
)
} else {
Box(contentAlignment = Alignment.Center, modifier = Modifier.fillMaxWidth()) {

View File

@ -227,6 +227,7 @@
<string name="user_context_sheet_category_bio">Bio</string>
<string name="user_context_sheet_bio_empty">This user hasn\'t set a bio yet.</string>
<string name="user_context_sheet_bio_not_found">This user\'s bio could not be fetched. Please verify you share a server or are friends.</string>
<string name="user_context_sheet_category_roles">Roles</string>
<string name="add_server_sheet_title">Add a server</string>