From 5f8c9427bfbe107db9498cee6d7593504b66391e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?marcin=20miko=C5=82ajczak?= Date: Tue, 18 Jun 2024 23:59:15 +0200 Subject: [PATCH] Remove some group-related stuff MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: marcin mikołajczak --- src/components/group-card.tsx | 4 -- src/components/status-action-bar.tsx | 8 ++- .../group/components/group-action-button.tsx | 5 -- .../group/components/group-header.tsx | 40 +++++++-------- .../group/components/group-options-button.tsx | 6 +-- src/features/group/group-timeline.tsx | 4 +- .../ui/components/group-media-panel.tsx | 4 +- src/locales/en.json | 2 - src/locales/pl.json | 2 +- src/normalizers/group.ts | 1 - src/pages/group-page.tsx | 49 +------------------ src/schemas/group-relationship.ts | 7 +-- src/schemas/group.ts | 3 +- 13 files changed, 31 insertions(+), 104 deletions(-) diff --git a/src/components/group-card.tsx b/src/components/group-card.tsx index 2e1527716..d8bc5735e 100644 --- a/src/components/group-card.tsx +++ b/src/components/group-card.tsx @@ -36,10 +36,6 @@ const GroupCard: React.FC = ({ group }) => ( - - {group.relationship?.pending_requests && ( -
- )} diff --git a/src/components/status-action-bar.tsx b/src/components/status-action-bar.tsx index 28a304413..732b8cf7b 100644 --- a/src/components/status-action-bar.tsx +++ b/src/components/status-action-bar.tsx @@ -501,14 +501,12 @@ const StatusActionBar: React.FC = ({ } if (isGroupStatus && !!status.group) { - const group = status.group as Group; - const account = status.account; const isGroupOwner = groupRelationship?.role === GroupRoles.OWNER; const isGroupAdmin = groupRelationship?.role === GroupRoles.ADMIN; - const isStatusFromOwner = group.owner.id === account.id; + // const isStatusFromOwner = group.owner.id === account.id; - const canBanUser = match?.isExact && (isGroupOwner || isGroupAdmin) && !isStatusFromOwner && !ownAccount; - const canDeleteStatus = !ownAccount && (isGroupOwner || (isGroupAdmin && !isStatusFromOwner)); + const canBanUser = match?.isExact && (isGroupOwner || isGroupAdmin) && !ownAccount; + const canDeleteStatus = !ownAccount && (isGroupOwner || isGroupAdmin); if (canBanUser || canDeleteStatus) { menu.push(null); diff --git a/src/features/group/components/group-action-button.tsx b/src/features/group/components/group-action-button.tsx index 5d7a98525..63e46b03c 100644 --- a/src/features/group/components/group-action-button.tsx +++ b/src/features/group/components/group-action-button.tsx @@ -37,7 +37,6 @@ const GroupActionButton = ({ group }: IGroupActionButton) => { const isNonMember = !group.relationship?.member && !isRequested; const isOwner = group.relationship?.role === GroupRoles.OWNER; const isAdmin = group.relationship?.role === GroupRoles.ADMIN; - const isBlocked = group.relationship?.blocked_by; const onJoinGroup = () => joinGroup.mutate({}, { onSuccess(entity) { @@ -80,10 +79,6 @@ const GroupActionButton = ({ group }: IGroupActionButton) => { }, }); - if (isBlocked) { - return null; - } - if (isOwner || isAdmin) { return (
); diff --git a/src/features/group/components/group-options-button.tsx b/src/features/group/components/group-options-button.tsx index 0b4ec83c8..1e42992ad 100644 --- a/src/features/group/components/group-options-button.tsx +++ b/src/features/group/components/group-options-button.tsx @@ -33,8 +33,6 @@ const GroupOptionsButton = ({ group }: IGroupActionButton) => { const isMember = group.relationship?.role === GroupRoles.USER; const isAdmin = group.relationship?.role === GroupRoles.ADMIN; const isInGroup = !!group.relationship?.member; - const isBlocked = group.relationship?.blocked_by; - const isMuting = group.relationship?.muting; const handleShare = () => { navigator.share({ @@ -80,9 +78,9 @@ const GroupOptionsButton = ({ group }: IGroupActionButton) => { } return items; - }, [isMember, isAdmin, isInGroup, isMuting]); + }, [isMember, isAdmin, isInGroup]); - if (isBlocked || menu.length === 0) { + if (menu.length === 0) { return null; } diff --git a/src/features/group/group-timeline.tsx b/src/features/group/group-timeline.tsx index 935f2d4bb..03b0ba295 100644 --- a/src/features/group/group-timeline.tsx +++ b/src/features/group/group-timeline.tsx @@ -4,7 +4,7 @@ import { FormattedMessage, useIntl } from 'react-intl'; import { Link } from 'react-router-dom'; import { groupCompose, uploadCompose } from 'soapbox/actions/compose'; -import { expandGroupFeaturedTimeline, expandGroupTimeline } from 'soapbox/actions/timelines'; +import { expandGroupTimeline } from 'soapbox/actions/timelines'; import { useGroup, useGroupStream } from 'soapbox/api/hooks'; import { Avatar, HStack, Icon, Stack, Text } from 'soapbox/components/ui'; import ComposeForm from 'soapbox/features/compose/components/compose-form'; @@ -47,7 +47,7 @@ const GroupTimeline: React.FC = (props) => { useEffect(() => { dispatch(expandGroupTimeline(groupId)); - dispatch(expandGroupFeaturedTimeline(groupId)); + // dispatch(expandGroupFeaturedTimeline(groupId)); dispatch(groupCompose(composeId, groupId)); }, [groupId]); diff --git a/src/features/ui/components/group-media-panel.tsx b/src/features/ui/components/group-media-panel.tsx index 4dbc6f2be..0592b6c5e 100644 --- a/src/features/ui/components/group-media-panel.tsx +++ b/src/features/ui/components/group-media-panel.tsx @@ -40,7 +40,7 @@ const GroupMediaPanel: React.FC = ({ group }) => { useEffect(() => { setLoading(true); - if (group && !group.deleted_at && (isMember || !isPrivate)) { + if (group && (isMember || !isPrivate)) { dispatch(expandGroupMediaTimeline(group.id)) // @ts-ignore .then(() => setLoading(false)) @@ -72,7 +72,7 @@ const GroupMediaPanel: React.FC = ({ group }) => { } }; - if ((isPrivate && !isMember) || group?.deleted_at) { + if (isPrivate && !isMember) { return null; } diff --git a/src/locales/en.json b/src/locales/en.json index 153fc78f1..2aca31d78 100644 --- a/src/locales/en.json +++ b/src/locales/en.json @@ -808,10 +808,8 @@ "gdpr.title": "{siteTitle} uses cookies", "generic.saved": "Saved", "getting_started.open_source_notice": "{code_name} is open source software. You can contribute or report issues at {code_link} (v{code_version}).", - "group.banned.message": "You are banned from {group}", "group.cancel_request": "Cancel request", "group.delete.success": "Group successfully deleted", - "group.deleted.message": "This group has been deleted.", "group.demote.user.success": "@{name} is now a member", "group.group_mod_authorize.fail": "Failed to approve @{name}", "group.group_mod_block": "Ban from group", diff --git a/src/locales/pl.json b/src/locales/pl.json index 25f76844a..69fb22673 100644 --- a/src/locales/pl.json +++ b/src/locales/pl.json @@ -781,7 +781,7 @@ "group.join.success": "Pomyślnie dołączono do grupy!", "group.leave": "Opuść grupę", "group.leave.label": "Opuść", - "group.leave.success": "Opuść grupę", + "group.leave.success": "Opuszczono grupę", "group.manage": "Zarządzaj grupę", "group.member.admin.limit.summary": "Możesz teraz przypisać do {count, plural, one {# administratora}, other {# administratorów}} do grupy.", "group.member.admin.limit.title": "Przekroczono limit administratorów", diff --git a/src/normalizers/group.ts b/src/normalizers/group.ts index 038d652d9..e23de3382 100644 --- a/src/normalizers/group.ts +++ b/src/normalizers/group.ts @@ -21,7 +21,6 @@ const GroupRecord = ImmutableRecord({ avatar: '', avatar_static: '', created_at: '', - deleted_at: null, display_name: '', domain: '', emojis: [] as Emoji[], diff --git a/src/pages/group-page.tsx b/src/pages/group-page.tsx index 05d47dcd0..20cebc637 100644 --- a/src/pages/group-page.tsx +++ b/src/pages/group-page.tsx @@ -13,8 +13,6 @@ import { } from 'soapbox/features/ui/util/async-components'; import { useOwnAccount } from 'soapbox/hooks'; -import type { Group } from 'soapbox/schemas'; - const messages = defineMessages({ all: { id: 'group.tabs.all', defaultMessage: 'All' }, members: { id: 'group.tabs.members', defaultMessage: 'Members' }, @@ -28,24 +26,6 @@ interface IGroupPage { children: React.ReactNode; } -const DeletedBlankslate = () => ( - -
- -
- - - - -
-); - const PrivacyBlankslate = () => (
@@ -64,27 +44,6 @@ const PrivacyBlankslate = () => ( ); -const BlockedBlankslate = ({ group }: { group: Group }) => ( - -
- -
- - - , - }} - /> - -
-); - /** Page to display a group. */ const GroupPage: React.FC = ({ params, children }) => { const intl = useIntl(); @@ -97,9 +56,7 @@ const GroupPage: React.FC = ({ params, children }) => { const { accounts: pending } = useGroupMembershipRequests(id); const isMember = !!group?.relationship?.member; - const isBlocked = group?.relationship?.blocked_by; const isPrivate = group?.locked; - const isDeleted = !!group?.deleted_at; const tabItems = useMemo(() => { const items = []; @@ -127,12 +84,8 @@ const GroupPage: React.FC = ({ params, children }) => { }, [pending.length, id]); const renderChildren = () => { - if (isDeleted) { - return ; - } else if (!isMember && isPrivate) { + if (!isMember && isPrivate) { return ; - } else if (isBlocked) { - return ; } else { return children; } diff --git a/src/schemas/group-relationship.ts b/src/schemas/group-relationship.ts index 93e2a5e14..2a6a8fa70 100644 --- a/src/schemas/group-relationship.ts +++ b/src/schemas/group-relationship.ts @@ -3,14 +3,11 @@ import z from 'zod'; import { GroupRoles } from './group-member'; const groupRelationshipSchema = z.object({ - blocked_by: z.boolean().catch(false), id: z.string(), member: z.boolean().catch(false), - muting: z.boolean().nullable().catch(false), - notifying: z.boolean().nullable().catch(null), - pending_requests: z.boolean().catch(false), - requested: z.boolean().catch(false), role: z.nativeEnum(GroupRoles).catch(GroupRoles.USER), + requested: z.boolean().catch(false), + owner: z.boolean().catch(false), }); type GroupRelationship = z.infer; diff --git a/src/schemas/group.ts b/src/schemas/group.ts index 239d8eb35..6cca9480e 100644 --- a/src/schemas/group.ts +++ b/src/schemas/group.ts @@ -15,7 +15,6 @@ const groupSchema = z.object({ avatar: z.string().catch(avatarMissing), avatar_static: z.string().catch(''), created_at: z.string().datetime().catch(new Date().toUTCString()), - deleted_at: z.string().datetime().or(z.null()).catch(null), display_name: z.string().catch(''), domain: z.string().catch(''), emojis: filteredArray(customEmojiSchema), @@ -25,7 +24,7 @@ const groupSchema = z.object({ locked: z.boolean().catch(false), membership_required: z.boolean().catch(false), members_count: z.number().catch(0), - owner: z.object({ id: z.string() }), + owner: z.object({ id: z.string() }).nullable().catch(null), note: z.string().transform(note => note === '

' ? '' : note).catch(''), relationship: groupRelationshipSchema.nullable().catch(null), // Dummy field to be overwritten later source: z.object({