Merge branch 'notification-types' into 'develop'
Display only known notification types See merge request soapbox-pub/soapbox!1857
This commit is contained in:
commit
34ac55b7f8
3 changed files with 15 additions and 10 deletions
|
@ -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 {
|
||||
|
|
|
@ -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' ? (
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Reference in a new issue