fix: not found handling for user profile
Signed-off-by: Infi <wingit@geist.ga>
This commit is contained in:
parent
5ede657f7e
commit
56ba789ca4
|
|
@ -47,11 +47,15 @@ fun UserContextSheet(
|
||||||
val server = RevoltAPI.serverCache[serverId]
|
val server = RevoltAPI.serverCache[serverId]
|
||||||
|
|
||||||
var profile by remember { mutableStateOf<Profile?>(null) }
|
var profile by remember { mutableStateOf<Profile?>(null) }
|
||||||
|
var profileNotFound by remember { mutableStateOf(false) }
|
||||||
|
|
||||||
LaunchedEffect(user) {
|
LaunchedEffect(user) {
|
||||||
try {
|
try {
|
||||||
user?.id?.let { fetchUserProfile(it) }?.let { profile = it }
|
user?.id?.let { fetchUserProfile(it) }?.let { profile = it }
|
||||||
} catch (e: Error) {
|
} catch (e: Error) {
|
||||||
|
if (e.message == "NotFound") {
|
||||||
|
profileNotFound = true
|
||||||
|
}
|
||||||
e.printStackTrace()
|
e.printStackTrace()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -110,6 +114,12 @@ fun UserContextSheet(
|
||||||
} else if (profile != null) {
|
} else if (profile != null) {
|
||||||
Text(
|
Text(
|
||||||
text = stringResource(id = R.string.user_context_sheet_bio_empty),
|
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 {
|
} else {
|
||||||
Box(contentAlignment = Alignment.Center, modifier = Modifier.fillMaxWidth()) {
|
Box(contentAlignment = Alignment.Center, modifier = Modifier.fillMaxWidth()) {
|
||||||
|
|
|
||||||
|
|
@ -227,6 +227,7 @@
|
||||||
|
|
||||||
<string name="user_context_sheet_category_bio">Bio</string>
|
<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_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="user_context_sheet_category_roles">Roles</string>
|
||||||
|
|
||||||
<string name="add_server_sheet_title">Add a server</string>
|
<string name="add_server_sheet_title">Add a server</string>
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue