2023-08-09 00:53:06 +00:00
|
|
|
// Copyright 2023 Signal Messenger, LLC
|
|
|
|
// SPDX-License-Identifier: AGPL-3.0-only
|
|
|
|
|
|
|
|
import { createSelector } from 'reselect';
|
|
|
|
import type { StateType } from '../reducer';
|
|
|
|
import type { NavStateType } from '../ducks/nav';
|
2023-08-14 23:28:47 +00:00
|
|
|
import { getAllConversationsUnreadStats } from './conversations';
|
|
|
|
import { getStoriesNotificationCount } from './stories';
|
|
|
|
import type { UnreadStats } from '../../util/countUnreadStats';
|
2023-08-09 00:53:06 +00:00
|
|
|
|
|
|
|
function getNav(state: StateType): NavStateType {
|
|
|
|
return state.nav;
|
|
|
|
}
|
|
|
|
|
|
|
|
export const getSelectedNavTab = createSelector(getNav, nav => {
|
|
|
|
return nav.selectedNavTab;
|
|
|
|
});
|
2023-08-14 23:28:47 +00:00
|
|
|
|
|
|
|
export const getAppUnreadStats = createSelector(
|
|
|
|
getAllConversationsUnreadStats,
|
|
|
|
getStoriesNotificationCount,
|
|
|
|
(conversationsUnreadStats, storiesNotificationCount): UnreadStats => {
|
|
|
|
return {
|
|
|
|
// Note: Conversation unread stats includes the call history unread count.
|
|
|
|
unreadCount:
|
|
|
|
conversationsUnreadStats.unreadCount + storiesNotificationCount,
|
|
|
|
unreadMentionsCount: conversationsUnreadStats.unreadMentionsCount,
|
|
|
|
markedUnread: conversationsUnreadStats.markedUnread,
|
|
|
|
};
|
|
|
|
}
|
|
|
|
);
|