Merge branch 'notification-types' into 'develop'

Display only known notification types

See merge request soapbox-pub/soapbox!1857
This commit is contained in:
Alex Gleason 2022-11-01 22:13:53 +00:00
commit 34ac55b7f8
3 changed files with 9 additions and 10 deletions

View file

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

View file

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