mirror of
https://github.com/funamitech/mastodon
synced 2024-12-12 05:39:02 +09:00
[Glitch] Fix all streamed notification types being stored without filtering
Port a7b718c31a
to glitch-soc
Signed-off-by: Claire <claire.github-309c@sitedethib.com>
This commit is contained in:
parent
61b2139267
commit
8426c20d34
@ -15,6 +15,7 @@ import type { NotificationGap } from 'flavours/glitch/reducers/notification_grou
|
|||||||
import {
|
import {
|
||||||
selectSettingsNotificationsExcludedTypes,
|
selectSettingsNotificationsExcludedTypes,
|
||||||
selectSettingsNotificationsQuickFilterActive,
|
selectSettingsNotificationsQuickFilterActive,
|
||||||
|
selectSettingsNotificationsShows,
|
||||||
} from 'flavours/glitch/selectors/settings';
|
} from 'flavours/glitch/selectors/settings';
|
||||||
import type { AppDispatch } from 'flavours/glitch/store';
|
import type { AppDispatch } from 'flavours/glitch/store';
|
||||||
import {
|
import {
|
||||||
@ -104,7 +105,31 @@ export const fetchNotificationsGap = createDataLoadingThunk(
|
|||||||
|
|
||||||
export const processNewNotificationForGroups = createAppAsyncThunk(
|
export const processNewNotificationForGroups = createAppAsyncThunk(
|
||||||
'notificationGroups/processNew',
|
'notificationGroups/processNew',
|
||||||
(notification: ApiNotificationJSON, { dispatch }) => {
|
(notification: ApiNotificationJSON, { dispatch, getState }) => {
|
||||||
|
const state = getState();
|
||||||
|
const activeFilter = selectSettingsNotificationsQuickFilterActive(state);
|
||||||
|
const notificationShows = selectSettingsNotificationsShows(state);
|
||||||
|
|
||||||
|
const showInColumn =
|
||||||
|
activeFilter === 'all'
|
||||||
|
? notificationShows[notification.type]
|
||||||
|
: activeFilter === notification.type;
|
||||||
|
|
||||||
|
if (!showInColumn) return;
|
||||||
|
|
||||||
|
if (
|
||||||
|
(notification.type === 'mention' || notification.type === 'update') &&
|
||||||
|
notification.status.filtered
|
||||||
|
) {
|
||||||
|
const filters = notification.status.filtered.filter((result) =>
|
||||||
|
result.filter.context.includes('notifications'),
|
||||||
|
);
|
||||||
|
|
||||||
|
if (filters.some((result) => result.filter.filter_action === 'hide')) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
dispatchAssociatedRecords(dispatch, [notification]);
|
dispatchAssociatedRecords(dispatch, [notification]);
|
||||||
|
|
||||||
return notification;
|
return notification;
|
||||||
|
@ -104,7 +104,7 @@ export const connectTimelineStream = (timelineId, channelName, params = {}, opti
|
|||||||
const notificationJSON = JSON.parse(data.payload);
|
const notificationJSON = JSON.parse(data.payload);
|
||||||
dispatch(updateNotifications(notificationJSON, messages, locale));
|
dispatch(updateNotifications(notificationJSON, messages, locale));
|
||||||
// TODO: remove this once the groups feature replaces the previous one
|
// TODO: remove this once the groups feature replaces the previous one
|
||||||
if(getState().notificationGroups.groups.length > 0) {
|
if(getState().settings.getIn(['notifications', 'groupingBeta'], false)) {
|
||||||
dispatch(processNewNotificationForGroups(notificationJSON));
|
dispatch(processNewNotificationForGroups(notificationJSON));
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -58,6 +58,29 @@ export interface ApiPreviewCardJSON {
|
|||||||
authors: ApiPreviewCardAuthorJSON[];
|
authors: ApiPreviewCardAuthorJSON[];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export type FilterContext =
|
||||||
|
| 'home'
|
||||||
|
| 'notifications'
|
||||||
|
| 'public'
|
||||||
|
| 'thread'
|
||||||
|
| 'account';
|
||||||
|
|
||||||
|
export interface ApiFilterJSON {
|
||||||
|
id: string;
|
||||||
|
title: string;
|
||||||
|
context: FilterContext;
|
||||||
|
expires_at: string;
|
||||||
|
filter_action: 'warn' | 'hide';
|
||||||
|
keywords?: unknown[]; // TODO: FilterKeywordSerializer
|
||||||
|
statuses?: unknown[]; // TODO: FilterStatusSerializer
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface ApiFilterResultJSON {
|
||||||
|
filter: ApiFilterJSON;
|
||||||
|
keyword_matches: string[];
|
||||||
|
status_matches: string[];
|
||||||
|
}
|
||||||
|
|
||||||
export interface ApiStatusJSON {
|
export interface ApiStatusJSON {
|
||||||
id: string;
|
id: string;
|
||||||
created_at: string;
|
created_at: string;
|
||||||
@ -80,8 +103,7 @@ export interface ApiStatusJSON {
|
|||||||
bookmarked?: boolean;
|
bookmarked?: boolean;
|
||||||
pinned?: boolean;
|
pinned?: boolean;
|
||||||
|
|
||||||
// filtered: FilterResult[]
|
filtered?: ApiFilterResultJSON[];
|
||||||
filtered: unknown; // TODO
|
|
||||||
content?: string;
|
content?: string;
|
||||||
text?: string;
|
text?: string;
|
||||||
|
|
||||||
|
@ -387,12 +387,14 @@ export const notificationGroupsReducer = createReducer<NotificationGroupsState>(
|
|||||||
})
|
})
|
||||||
.addCase(processNewNotificationForGroups.fulfilled, (state, action) => {
|
.addCase(processNewNotificationForGroups.fulfilled, (state, action) => {
|
||||||
const notification = action.payload;
|
const notification = action.payload;
|
||||||
|
if (notification) {
|
||||||
processNewNotification(
|
processNewNotification(
|
||||||
usePendingItems ? state.pendingGroups : state.groups,
|
usePendingItems ? state.pendingGroups : state.groups,
|
||||||
notification,
|
notification,
|
||||||
);
|
);
|
||||||
updateLastReadId(state);
|
updateLastReadId(state);
|
||||||
trimNotifications(state);
|
trimNotifications(state);
|
||||||
|
}
|
||||||
})
|
})
|
||||||
.addCase(disconnectTimeline, (state, action) => {
|
.addCase(disconnectTimeline, (state, action) => {
|
||||||
if (action.payload.timeline === 'home') {
|
if (action.payload.timeline === 'home') {
|
||||||
|
Loading…
Reference in New Issue
Block a user