mirror of
https://github.com/glitch-soc/mastodon.git
synced 2024-11-30 03:50:13 -05:00
f587ff643f
Co-authored-by: Eugen Rochko <eugen@zeonfederated.com> Co-authored-by: Claire <claire.github-309c@sitedethib.com>
35 lines
1.0 KiB
TypeScript
35 lines
1.0 KiB
TypeScript
import { createSelector } from '@reduxjs/toolkit';
|
|
|
|
import { compareId } from 'mastodon/compare_id';
|
|
import type { RootState } from 'mastodon/store';
|
|
|
|
export const selectUnreadNotificationGroupsCount = createSelector(
|
|
[
|
|
(s: RootState) => s.notificationGroups.lastReadId,
|
|
(s: RootState) => s.notificationGroups.pendingGroups,
|
|
(s: RootState) => s.notificationGroups.groups,
|
|
],
|
|
(notificationMarker, pendingGroups, groups) => {
|
|
return (
|
|
groups.filter(
|
|
(group) =>
|
|
group.type !== 'gap' &&
|
|
group.page_max_id &&
|
|
compareId(group.page_max_id, notificationMarker) > 0,
|
|
).length +
|
|
pendingGroups.filter(
|
|
(group) =>
|
|
group.type !== 'gap' &&
|
|
group.page_max_id &&
|
|
compareId(group.page_max_id, notificationMarker) > 0,
|
|
).length
|
|
);
|
|
},
|
|
);
|
|
|
|
export const selectPendingNotificationGroupsCount = createSelector(
|
|
[(s: RootState) => s.notificationGroups.pendingGroups],
|
|
(pendingGroups) =>
|
|
pendingGroups.filter((group) => group.type !== 'gap').length,
|
|
);
|