From dda83c7834c7892b3bf37aef04892af6e23ff93a Mon Sep 17 00:00:00 2001 From: Lim Chee Aun Date: Thu, 26 Jan 2023 11:26:24 +0800 Subject: [PATCH] Better error state for Account sheet MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Some accounts… can't be resolved by the API --- src/components/account.jsx | 271 +++++++++++++++++++------------------ 1 file changed, 141 insertions(+), 130 deletions(-) diff --git a/src/components/account.jsx b/src/components/account.jsx index 10c0b6a8..b8a764aa 100644 --- a/src/components/account.jsx +++ b/src/components/account.jsx @@ -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' && ( +
+

Unable to load account.

+

+ + Go to account page + +

+
+ )} + {uiState === 'loading' ? ( <>
@@ -142,138 +150,141 @@ function Account({ account }) { ) : ( - <> -
- - -
-
- {bot && ( - <> - - Automated - - - )} -
- {fields?.length > 0 && ( - - )} -

- - {shortenNumber(statusesCount)}{' '} - Posts - - - {shortenNumber(followingCount)}{' '} - Following - - - {shortenNumber(followersCount)}{' '} - Followers - - {!!createdAt && ( - - Joined:{' '} - - - - + info && ( + <> +

+ + +
+
+ {bot && ( + <> + + Automated + + )} -

-

- {followedBy ? Following you : }{' '} - {relationshipUIState !== 'loading' && relationship && ( - - )} -

-
- + })(); + }} + > + {following ? ( + <> + Following + Unfollow… + + ) : requested ? ( + <> + Requested + Withdraw… + + ) : locked ? ( + <> + Follow + + ) : ( + 'Follow' + )} + + )} +

+
+ + ) )} );