From 25b2f167f2ec3b35f1f9ac391c3efe59a870e83f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?marcin=20miko=C5=82ajczak?= Date: Sat, 17 Dec 2022 00:41:22 +0100 Subject: [PATCH] Groups: Lint, use PlaceholderAccount for GroupMembers MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: marcin mikołajczak --- app/soapbox/features/birthdays/account.tsx | 43 +++++++------------ app/soapbox/features/group/group-members.tsx | 6 +++ .../components/placeholder-account.tsx | 19 ++++---- app/soapbox/normalizers/account.ts | 2 +- app/soapbox/pages/group-page.tsx | 2 +- 5 files changed, 33 insertions(+), 39 deletions(-) diff --git a/app/soapbox/features/birthdays/account.tsx b/app/soapbox/features/birthdays/account.tsx index 805538fd5..79a70fc42 100644 --- a/app/soapbox/features/birthdays/account.tsx +++ b/app/soapbox/features/birthdays/account.tsx @@ -1,10 +1,9 @@ import React, { useCallback } from 'react'; import { defineMessages, useIntl } from 'react-intl'; -import { Link } from 'react-router-dom'; -import Avatar from 'soapbox/components/avatar'; -import DisplayName from 'soapbox/components/display-name'; +import AccountComponent from 'soapbox/components/account'; import Icon from 'soapbox/components/icon'; +import { HStack } from 'soapbox/components/ui'; import { useAppSelector } from 'soapbox/hooks'; import { makeGetAccount } from 'soapbox/selectors'; @@ -22,12 +21,6 @@ const Account: React.FC = ({ accountId }) => { const account = useAppSelector((state) => getAccount(state, accountId)); - // useEffect(() => { - // if (accountId && !account) { - // fetchAccount(accountId); - // } - // }, [accountId]); - if (!account) return null; const birthday = account.birthday; @@ -36,26 +29,20 @@ const Account: React.FC = ({ accountId }) => { const formattedBirthday = intl.formatDate(birthday, { day: 'numeric', month: 'short', year: 'numeric' }); return ( -
-
- -
-
- - -
- -
- - {formattedBirthday} -
+ +
+
-
+
+ + {formattedBirthday} +
+ ); }; diff --git a/app/soapbox/features/group/group-members.tsx b/app/soapbox/features/group/group-members.tsx index 7df79b6bc..7e7f368a0 100644 --- a/app/soapbox/features/group/group-members.tsx +++ b/app/soapbox/features/group/group-members.tsx @@ -8,6 +8,8 @@ import { CardHeader, CardTitle } from 'soapbox/components/ui'; import AccountContainer from 'soapbox/containers/account-container'; import { useAppDispatch, useAppSelector } from 'soapbox/hooks'; +import PlaceholderAccount from '../placeholder/components/placeholder-account'; + import type { List } from 'soapbox/reducers/group-memberships'; type RouteParams = { id: string }; @@ -61,6 +63,10 @@ const GroupMembers: React.FC = (props) => { hasMore={!!memberships?.next} onLoadMore={handler} isLoading={memberships?.isLoading} + showLoading={memberships?.isLoading && !memberships?.items?.count()} + placeholderComponent={PlaceholderAccount} + placeholderCount={3} + itemClassName='pb-4 last:pb-0' > {memberships?.items?.map(accountId => )} diff --git a/app/soapbox/features/placeholder/components/placeholder-account.tsx b/app/soapbox/features/placeholder/components/placeholder-account.tsx index 113ed02f9..f3ba98109 100644 --- a/app/soapbox/features/placeholder/components/placeholder-account.tsx +++ b/app/soapbox/features/placeholder/components/placeholder-account.tsx @@ -1,21 +1,22 @@ import React from 'react'; +import { HStack } from 'soapbox/components/ui'; + import PlaceholderAvatar from './placeholder-avatar'; import PlaceholderDisplayName from './placeholder-display-name'; /** Fake account to display while data is loading. */ const PlaceholderAccount: React.FC = () => { return ( -
-
- -
- -
- -
+ +
+
-
+ +
+ +
+ ); }; diff --git a/app/soapbox/normalizers/account.ts b/app/soapbox/normalizers/account.ts index fb6a04255..3dace3d08 100644 --- a/app/soapbox/normalizers/account.ts +++ b/app/soapbox/normalizers/account.ts @@ -25,7 +25,7 @@ export const AccountRecord = ImmutableRecord({ acct: '', avatar: '', avatar_static: '', - birthday: '', + birthday: '2001-02-12', bot: false, chats_onboarded: true, created_at: '', diff --git a/app/soapbox/pages/group-page.tsx b/app/soapbox/pages/group-page.tsx index 656d25f5e..620147872 100644 --- a/app/soapbox/pages/group-page.tsx +++ b/app/soapbox/pages/group-page.tsx @@ -61,7 +61,7 @@ const GroupPage: React.FC = ({ params, children }) => { to: `/groups/${group?.id}/members`, name: '/groups/:id/members', }, - ] + ]; return ( <>