2024-09-17 00:51:56 +10:00
|
|
|
import { createSelector } from '@reduxjs/toolkit';
|
|
|
|
|
2024-07-19 00:36:09 +10:00
|
|
|
import type { RootState } from 'mastodon/store';
|
|
|
|
|
|
|
|
/* eslint-disable @typescript-eslint/no-unsafe-call, @typescript-eslint/no-unsafe-member-access */
|
|
|
|
// state.settings is not yet typed, so we disable some ESLint checks for those selectors
|
2024-09-17 00:51:56 +10:00
|
|
|
export const selectSettingsNotificationsShows = createSelector(
|
|
|
|
[
|
|
|
|
(state) =>
|
|
|
|
state.settings.getIn(['notifications', 'shows']) as Immutable.Map<
|
|
|
|
string,
|
|
|
|
boolean
|
|
|
|
>,
|
|
|
|
],
|
|
|
|
(shows) => shows.toJS() as Record<string, boolean>,
|
|
|
|
);
|
2024-07-19 00:36:09 +10:00
|
|
|
|
2024-09-17 00:51:56 +10:00
|
|
|
export const selectSettingsNotificationsExcludedTypes = createSelector(
|
|
|
|
[selectSettingsNotificationsShows],
|
|
|
|
(shows) =>
|
|
|
|
Object.entries(shows)
|
|
|
|
.filter(([_type, enabled]) => !enabled)
|
|
|
|
.map(([type, _enabled]) => type),
|
|
|
|
);
|
2024-07-19 00:36:09 +10:00
|
|
|
|
|
|
|
export const selectSettingsNotificationsQuickFilterShow = (state: RootState) =>
|
|
|
|
state.settings.getIn(['notifications', 'quickFilter', 'show']) as boolean;
|
|
|
|
|
|
|
|
export const selectSettingsNotificationsQuickFilterActive = (
|
|
|
|
state: RootState,
|
|
|
|
) => state.settings.getIn(['notifications', 'quickFilter', 'active']) as string;
|
|
|
|
|
|
|
|
export const selectSettingsNotificationsQuickFilterAdvanced = (
|
|
|
|
state: RootState,
|
|
|
|
) =>
|
|
|
|
state.settings.getIn(['notifications', 'quickFilter', 'advanced']) as boolean;
|
|
|
|
|
|
|
|
export const selectSettingsNotificationsShowUnread = (state: RootState) =>
|
|
|
|
state.settings.getIn(['notifications', 'showUnread']) as boolean;
|
|
|
|
|
|
|
|
export const selectNeedsNotificationPermission = (state: RootState) =>
|
|
|
|
(state.settings.getIn(['notifications', 'alerts']).includes(true) &&
|
|
|
|
state.notifications.get('browserSupport') &&
|
|
|
|
state.notifications.get('browserPermission') === 'default' &&
|
|
|
|
!state.settings.getIn([
|
|
|
|
'notifications',
|
|
|
|
'dismissPermissionBanner',
|
|
|
|
])) as boolean;
|
|
|
|
|
2024-08-03 00:59:37 +10:00
|
|
|
export const selectSettingsNotificationsMinimizeFilteredBanner = (
|
|
|
|
state: RootState,
|
|
|
|
) =>
|
|
|
|
state.settings.getIn(['notifications', 'minimizeFilteredBanner']) as boolean;
|
|
|
|
|
2024-10-16 19:33:11 +11:00
|
|
|
export const selectSettingsNotificationsGroupFollows = (state: RootState) =>
|
|
|
|
state.settings.getIn(['notifications', 'group', 'follow']) as boolean;
|
|
|
|
|
2024-07-19 00:36:09 +10:00
|
|
|
/* eslint-enable @typescript-eslint/no-unsafe-call, @typescript-eslint/no-unsafe-member-access */
|