Merge branch 'group-fixes' into 'develop'

Multiple Group improvements

See merge request soapbox-pub/soapbox!2523
This commit is contained in:
Chewbacca 2023-05-23 13:39:57 +00:00
commit 092dee0592
5 changed files with 18 additions and 5 deletions

View file

@ -85,7 +85,7 @@ const Ad: React.FC<IAd> = ({ ad }) => {
</Text>
<Icon
className='h-5 w-5 stroke-accent-500'
className='h-4 w-4 stroke-accent-500'
src={require('@tabler/icons/timeline.svg')}
/>
</HStack>

View file

@ -13,7 +13,7 @@ import LayoutButtons, { GroupLayout } from './components/discover/layout-buttons
import type { Group } from 'soapbox/schemas';
const messages = defineMessages({
label: { id: 'groups.popular.label', defaultMessage: 'Suggested Groups' },
label: { id: 'groups.suggested.label', defaultMessage: 'Suggested Groups' },
});
const GridList: Components['List'] = React.forwardRef((props, ref) => {

View file

@ -856,6 +856,7 @@
"groups.pending.label": "Pending Requests",
"groups.popular.label": "Suggested Groups",
"groups.search.placeholder": "Search My Groups",
"groups.suggested.label": "Suggested Groups",
"groups.tags.title": "Browse Topics",
"hashtag.column_header.tag_mode.all": "and {additional}",
"hashtag.column_header.tag_mode.any": "or {additional}",

View file

@ -25,8 +25,19 @@ export const NotificationRecord = ImmutableRecord({
total_count: null as number | null, // grouped notifications
});
const normalizeType = (notification: ImmutableMap<string, any>) => {
if (notification.get('type') === 'group_mention') {
return notification.set('type', 'mention');
}
return notification;
};
export const normalizeNotification = (notification: Record<string, any>) => {
return NotificationRecord(
ImmutableMap(fromJS(notification)),
ImmutableMap(fromJS(notification))
.withMutations((notification: ImmutableMap<string, any>) => {
normalizeType(notification);
}),
);
};

View file

@ -88,12 +88,12 @@ const isValid = (notification: APIEntity) => {
}
// https://gitlab.com/soapbox-pub/soapbox/-/issues/424
if (!notification.account.id) {
if (!notification.account.get('id')) {
return false;
}
// Mastodon can return status notifications with a null status
if (['mention', 'reblog', 'favourite', 'poll', 'status'].includes(notification.type) && !notification.status.id) {
if (['mention', 'reblog', 'favourite', 'poll', 'status'].includes(notification.type) && !notification.status.get('id')) {
return false;
}
@ -131,6 +131,7 @@ const importNotification = (state: State, notification: APIEntity) => {
export const processRawNotifications = (notifications: APIEntity[]) => (
ImmutableOrderedMap(
notifications
.map(normalizeNotification)
.filter(isValid)
.map(n => [n.id, fixNotification(n)]),
));