Remove some group-related stuff

Signed-off-by: marcin mikołajczak <git@mkljczk.pl>
This commit is contained in:
marcin mikołajczak 2024-06-18 23:59:15 +02:00
parent dd5b1359c1
commit 5f8c9427bf
13 changed files with 31 additions and 104 deletions

View file

@ -36,10 +36,6 @@ const GroupCard: React.FC<IGroupCard> = ({ group }) => (
<Stack alignItems='center' justifyContent='end' grow className='basis-1/2 py-4' space={0.5}>
<HStack alignItems='center' space={1.5}>
<Text size='lg' weight='bold' dangerouslySetInnerHTML={{ __html: group.display_name_html }} />
{group.relationship?.pending_requests && (
<div className='h-2 w-2 rounded-full bg-secondary-500' />
)}
</HStack>
<HStack className='text-gray-700 dark:text-gray-600' space={2} wrap>

View file

@ -501,14 +501,12 @@ const StatusActionBar: React.FC<IStatusActionBar> = ({
}
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);

View file

@ -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 (
<Button

View file

@ -52,8 +52,6 @@ const GroupHeader: React.FC<IGroupHeader> = ({ group }) => {
);
}
const isDeleted = !!group.deleted_at;
const onAvatarClick = () => {
const avatar = normalizeAttachment({
type: 'image',
@ -142,29 +140,25 @@ const GroupHeader: React.FC<IGroupHeader> = ({ group }) => {
data-testid='group-name'
/>
{!isDeleted && (
<>
<Stack data-testid='group-meta' space={1} alignItems='center'>
<HStack className='text-gray-700 dark:text-gray-600' space={2} wrap>
<GroupRelationship group={group} />
<GroupPrivacy group={group} />
<GroupMemberCount group={group} />
</HStack>
<Stack data-testid='group-meta' space={1} alignItems='center'>
<HStack className='text-gray-700 dark:text-gray-600' space={2} wrap>
<GroupRelationship group={group} />
<GroupPrivacy group={group} />4
<GroupMemberCount group={group} />
</HStack>
<Text
theme='muted'
align='center'
dangerouslySetInnerHTML={{ __html: group.note_emojified }}
className='[&_a]:text-primary-600 [&_a]:hover:underline [&_a]:dark:text-accent-blue'
/>
</Stack>
<Text
theme='muted'
align='center'
dangerouslySetInnerHTML={{ __html: group.note_emojified }}
className='[&_a]:text-primary-600 [&_a]:hover:underline [&_a]:dark:text-accent-blue'
/>
</Stack>
<HStack alignItems='center' space={2} data-testid='group-actions'>
<GroupOptionsButton group={group} />
<GroupActionButton group={group} />
</HStack>
</>
)}
<HStack alignItems='center' space={2} data-testid='group-actions'>
<GroupOptionsButton group={group} />
<GroupActionButton group={group} />
</HStack>
</Stack>
</div>
);

View file

@ -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;
}

View file

@ -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<IGroupTimeline> = (props) => {
useEffect(() => {
dispatch(expandGroupTimeline(groupId));
dispatch(expandGroupFeaturedTimeline(groupId));
// dispatch(expandGroupFeaturedTimeline(groupId));
dispatch(groupCompose(composeId, groupId));
}, [groupId]);

View file

@ -40,7 +40,7 @@ const GroupMediaPanel: React.FC<IGroupMediaPanel> = ({ 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<IGroupMediaPanel> = ({ group }) => {
}
};
if ((isPrivate && !isMember) || group?.deleted_at) {
if (isPrivate && !isMember) {
return null;
}

View file

@ -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",

View file

@ -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",

View file

@ -21,7 +21,6 @@ const GroupRecord = ImmutableRecord({
avatar: '',
avatar_static: '',
created_at: '',
deleted_at: null,
display_name: '',
domain: '',
emojis: [] as Emoji[],

View file

@ -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 = () => (
<Stack space={4} className='py-10' alignItems='center'>
<div className='rounded-full bg-danger-200 p-3 dark:bg-danger-400/20'>
<Icon
src={require('@tabler/icons/outline/trash.svg')}
className='h-6 w-6 text-danger-600 dark:text-danger-400'
/>
</div>
<Text theme='muted'>
<FormattedMessage
id='group.deleted.message'
defaultMessage='This group has been deleted.'
/>
</Text>
</Stack>
);
const PrivacyBlankslate = () => (
<Stack space={4} className='py-10' alignItems='center'>
<div className='rounded-full bg-gray-200 p-3 dark:bg-gray-800'>
@ -64,27 +44,6 @@ const PrivacyBlankslate = () => (
</Stack>
);
const BlockedBlankslate = ({ group }: { group: Group }) => (
<Stack space={4} className='py-10' alignItems='center'>
<div className='rounded-full bg-danger-200 p-3 dark:bg-danger-400/20'>
<Icon
src={require('@tabler/icons/outline/ban.svg')}
className='h-6 w-6 text-danger-600 dark:text-danger-400'
/>
</div>
<Text theme='muted'>
<FormattedMessage
id='group.banned.message'
defaultMessage='You are banned from {group}'
values={{
group: <Text theme='inherit' tag='span' dangerouslySetInnerHTML={{ __html: group.display_name_html }} />,
}}
/>
</Text>
</Stack>
);
/** Page to display a group. */
const GroupPage: React.FC<IGroupPage> = ({ params, children }) => {
const intl = useIntl();
@ -97,9 +56,7 @@ const GroupPage: React.FC<IGroupPage> = ({ 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<IGroupPage> = ({ params, children }) => {
}, [pending.length, id]);
const renderChildren = () => {
if (isDeleted) {
return <DeletedBlankslate />;
} else if (!isMember && isPrivate) {
if (!isMember && isPrivate) {
return <PrivacyBlankslate />;
} else if (isBlocked) {
return <BlockedBlankslate group={group} />;
} else {
return children;
}

View file

@ -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<typeof groupRelationshipSchema>;

View file

@ -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 === '<p></p>' ? '' : note).catch(''),
relationship: groupRelationshipSchema.nullable().catch(null), // Dummy field to be overwritten later
source: z.object({