mirror of
https://github.com/cheeaun/phanpy.git
synced 2025-03-31 13:43:41 +03:00
Better error state for Account sheet
Some accounts… can't be resolved by the API
This commit is contained in:
parent
285f8b46f2
commit
dda83c7834
1 changed files with 141 additions and 130 deletions
|
@ -41,10 +41,8 @@ function Account({ account }) {
|
||||||
setUIState('default');
|
setUIState('default');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
alert('Account not found');
|
|
||||||
setUIState('error');
|
setUIState('error');
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
alert(err);
|
|
||||||
console.error(err);
|
console.error(err);
|
||||||
setUIState('error');
|
setUIState('error');
|
||||||
}
|
}
|
||||||
|
@ -123,7 +121,17 @@ function Account({ account }) {
|
||||||
id="account-container"
|
id="account-container"
|
||||||
class={`sheet ${uiState === 'loading' ? 'skeleton' : ''}`}
|
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>
|
<header>
|
||||||
<Avatar size="xxxl" />
|
<Avatar size="xxxl" />
|
||||||
|
@ -142,6 +150,7 @@ function Account({ account }) {
|
||||||
</main>
|
</main>
|
||||||
</>
|
</>
|
||||||
) : (
|
) : (
|
||||||
|
info && (
|
||||||
<>
|
<>
|
||||||
<header>
|
<header>
|
||||||
<Avatar url={avatar} size="xxxl" />
|
<Avatar url={avatar} size="xxxl" />
|
||||||
|
@ -236,12 +245,13 @@ function Account({ account }) {
|
||||||
: 'Are you sure that you want to unfollow this account?',
|
: 'Are you sure that you want to unfollow this account?',
|
||||||
);
|
);
|
||||||
if (yes) {
|
if (yes) {
|
||||||
newRelationship = await masto.v1.accounts.unfollow(
|
newRelationship =
|
||||||
id,
|
await masto.v1.accounts.unfollow(id);
|
||||||
);
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
newRelationship = await masto.v1.accounts.follow(id);
|
newRelationship = await masto.v1.accounts.follow(
|
||||||
|
id,
|
||||||
|
);
|
||||||
}
|
}
|
||||||
if (newRelationship) setRelationship(newRelationship);
|
if (newRelationship) setRelationship(newRelationship);
|
||||||
setRelationshipUIState('default');
|
setRelationshipUIState('default');
|
||||||
|
@ -274,6 +284,7 @@ function Account({ account }) {
|
||||||
</p>
|
</p>
|
||||||
</main>
|
</main>
|
||||||
</>
|
</>
|
||||||
|
)
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
|
Loading…
Add table
Reference in a new issue