Use types
param in /api/v1/notifications
Signed-off-by: marcin mikołajczak <git@mkljczk.pl>
This commit is contained in:
parent
30ec3dbd9f
commit
a9aae8fbe8
2 changed files with 25 additions and 7 deletions
|
@ -9,7 +9,7 @@ import { defineMessages } from 'react-intl';
|
|||
import api, { getLinks } from 'soapbox/api';
|
||||
import { getFilters, regexFromFilters } from 'soapbox/selectors';
|
||||
import { isLoggedIn } from 'soapbox/utils/auth';
|
||||
import { parseVersion, PLEROMA } from 'soapbox/utils/features';
|
||||
import { getFeatures, parseVersion, PLEROMA } from 'soapbox/utils/features';
|
||||
import { unescapeHTML } from 'soapbox/utils/html';
|
||||
import { joinPublicPath } from 'soapbox/utils/static';
|
||||
|
||||
|
@ -167,7 +167,7 @@ const dequeueNotifications = () =>
|
|||
dispatch(markReadNotifications());
|
||||
};
|
||||
|
||||
const excludeTypesFromSettings = (getState: () => RootState) => (getSettings(getState()).getIn(['notifications', 'shows']) as ImmutableMap<string, boolean>).filter(enabled => !enabled).keySeq().toJS();
|
||||
// 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']);
|
||||
|
@ -180,8 +180,9 @@ const expandNotifications = ({ maxId }: Record<string, any> = {}, done: () => an
|
|||
(dispatch: AppDispatch, getState: () => RootState) => {
|
||||
if (!isLoggedIn(getState)) return dispatch(noOp);
|
||||
|
||||
const activeFilter = getSettings(getState()).getIn(['notifications', 'quickFilter', 'active']) as string;
|
||||
const notifications = getState().notifications;
|
||||
const state = getState();
|
||||
const activeFilter = getSettings(state).getIn(['notifications', 'quickFilter', 'active']) as string;
|
||||
const notifications = state.notifications;
|
||||
const isLoadingMore = !!maxId;
|
||||
|
||||
if (notifications.get('isLoading')) {
|
||||
|
@ -191,11 +192,19 @@ const expandNotifications = ({ maxId }: Record<string, any> = {}, done: () => an
|
|||
|
||||
const params: Record<string, any> = {
|
||||
max_id: maxId,
|
||||
exclude_types: activeFilter === 'all'
|
||||
? excludeTypesFromSettings(getState)
|
||||
: excludeTypesFromFilter(activeFilter),
|
||||
};
|
||||
|
||||
if (activeFilter !== 'all') {
|
||||
const instance = state.instance;
|
||||
const features = getFeatures(instance);
|
||||
|
||||
if (features.notificationsIncludeTypes) {
|
||||
params.types = [activeFilter];
|
||||
} else {
|
||||
params.exclude_types = excludeTypesFromFilter(activeFilter);
|
||||
}
|
||||
}
|
||||
|
||||
if (!maxId && notifications.get('items').size > 0) {
|
||||
params.since_id = notifications.getIn(['items', 0, 'id']);
|
||||
}
|
||||
|
|
|
@ -401,6 +401,15 @@ const getInstanceFeatures = (instance: Instance) => {
|
|||
v.software === PLEROMA && gte(v.version, '2.4.50'),
|
||||
]),
|
||||
|
||||
/**
|
||||
* Allows specifying notification types to include, rather than to exclude.
|
||||
* @see GET /api/v1/notifications
|
||||
*/
|
||||
notificationsIncludeTypes: any([
|
||||
v.software === MASTODON && gte(v.compatVersion, '3.5.0'),
|
||||
v.software === PLEROMA && gte(v.version, '2.4.50'),
|
||||
]),
|
||||
|
||||
/**
|
||||
* Supports pagination in threads.
|
||||
* @see GET /api/v1/statuses/:id/context/ancestors
|
||||
|
|
Loading…
Reference in a new issue