Display only know notification types

environments/review-notificati-vjyo1r/deployments/1238
Alex Gleason 2022-11-01 13:16:25 -05:00
rodzic 3430af668b
commit 7efb5729bd
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: 7211D1F99744FBB7
3 zmienionych plików z 15 dodań i 10 usunięć

Wyświetl plik

@ -1,5 +1,4 @@
import {
List as ImmutableList,
Map as ImmutableMap,
} from 'immutable';
import IntlMessageFormat from 'intl-messageformat';
@ -12,6 +11,7 @@ import { getFilters, regexFromFilters } from 'soapbox/selectors';
import { isLoggedIn } from 'soapbox/utils/auth';
import { getFeatures, parseVersion, PLEROMA } from 'soapbox/utils/features';
import { unescapeHTML } from 'soapbox/utils/html';
import { NOTIFICATION_TYPES } from 'soapbox/utils/notification';
import { joinPublicPath } from 'soapbox/utils/static';
import { fetchRelationships } from './accounts';
@ -168,11 +168,8 @@ const dequeueNotifications = () =>
dispatch(markReadNotifications());
};
// const excludeTypesFromSettings = (getState: () => RootState) => (getSettings(getState()).getIn(['notifications', 'shows']) as ImmutableMap<string, boolean>).filter(enabled => !enabled).keySeq().toJS();
const excludeTypesFromFilter = (filter: string) => {
const allTypes = ImmutableList(['follow', 'follow_request', 'favourite', 'reblog', 'mention', 'status', 'poll', 'move', 'pleroma:emoji_reaction']);
return allTypes.filterNot(item => item === filter).toJS();
return NOTIFICATION_TYPES.filter(item => item !== filter);
};
const noOp = () => new Promise(f => f(undefined));
@ -182,6 +179,7 @@ const expandNotifications = ({ maxId }: Record<string, any> = {}, done: () => an
if (!isLoggedIn(getState)) return dispatch(noOp);
const state = getState();
const features = getFeatures(state.instance);
const activeFilter = getSettings(state).getIn(['notifications', 'quickFilter', 'active']) as string;
const notifications = state.notifications;
const isLoadingMore = !!maxId;
@ -195,10 +193,11 @@ const expandNotifications = ({ maxId }: Record<string, any> = {}, done: () => an
max_id: maxId,
};
if (activeFilter !== 'all') {
const instance = state.instance;
const features = getFeatures(instance);
if (activeFilter === 'all') {
if (features.notificationsIncludeTypes) {
params.types = NOTIFICATION_TYPES;
}
} else {
if (features.notificationsIncludeTypes) {
params.types = [activeFilter];
} else {

Wyświetl plik

@ -268,7 +268,7 @@ const Notification: React.FC<INotificaton> = (props) => {
};
const renderContent = () => {
switch (type) {
switch (type as NotificationType) {
case 'follow':
case 'user_approved':
return account && typeof account === 'object' ? (

Wyświetl plik

@ -5,6 +5,7 @@ import {
} from 'immutable';
import { normalizeNotification } from 'soapbox/normalizers/notification';
import { validType } from 'soapbox/utils/notification';
import {
ACCOUNT_BLOCK_SUCCESS,
@ -67,6 +68,11 @@ const fixNotification = notification => {
const isValid = notification => {
try {
// Ensure the notification is a known type
if (!validType(notification.type)) {
return false;
}
// https://gitlab.com/soapbox-pub/soapbox/-/issues/424
if (!notification.account.id) {
return false;