Better error state for Account sheet

Some accounts… can't be resolved by the API
This commit is contained in:
Lim Chee Aun 2023-01-26 11:26:24 +08:00
parent 285f8b46f2
commit dda83c7834

View file

@ -41,10 +41,8 @@ function Account({ account }) {
setUIState('default');
return;
}
alert('Account not found');
setUIState('error');
} catch (err) {
alert(err);
console.error(err);
setUIState('error');
}
@ -123,7 +121,17 @@ function Account({ account }) {
id="account-container"
class={`sheet ${uiState === 'loading' ? 'skeleton' : ''}`}
>
{!info || uiState === 'loading' ? (
{uiState === 'error' && (
<div class="ui-state">
<p>Unable to load account.</p>
<p>
<a href={account} target="_blank">
Go to account page <Icon icon="external" />
</a>
</p>
</div>
)}
{uiState === 'loading' ? (
<>
<header>
<Avatar size="xxxl" />
@ -142,6 +150,7 @@ function Account({ account }) {
</main>
</>
) : (
info && (
<>
<header>
<Avatar url={avatar} size="xxxl" />
@ -236,12 +245,13 @@ function Account({ account }) {
: 'Are you sure that you want to unfollow this account?',
);
if (yes) {
newRelationship = await masto.v1.accounts.unfollow(
id,
);
newRelationship =
await masto.v1.accounts.unfollow(id);
}
} else {
newRelationship = await masto.v1.accounts.follow(id);
newRelationship = await masto.v1.accounts.follow(
id,
);
}
if (newRelationship) setRelationship(newRelationship);
setRelationshipUIState('default');
@ -274,6 +284,7 @@ function Account({ account }) {
</p>
</main>
</>
)
)}
</div>
);