refactor: fixed code refactor and added new slices and selector

This commit is contained in:
SundasNoreen
2023-06-05 19:55:46 +05:00
parent 78a40d47c1
commit cabf4e3f27
9 changed files with 108 additions and 77 deletions

View File

@@ -1,9 +1,23 @@
export const getNotificationStatus = () => state => state.notifications.notificationStatus;
export const getNotificationTabsCount = () => state => state.notifications.tabsCount;
export const getNotificationTabs = () => state => state.notifications.appsId;
export const getSelectedAppNotificationIds = (appName) => state => state.notifications.apps[appName] ?? [];
export const getNotificationTrayStatus = () => state => state.notifications.showNotificationTray;
export const getNotificationsByIds = (notificationIds) => state => Object.entries(state.notifications.notifications)
.filter(([key]) => notificationIds.includes(key)).map(([, value]) => value);
export const getSelectedAppName = () => state => state.notifications.appName;
export const getPaginationData = () => state => state.notifications.pagination;
import { createSelector } from '@reduxjs/toolkit';
export const selectNotificationStatus = () => state => state.notifications.notificationStatus;
export const selectNotificationTabsCount = () => state => state.notifications.tabsCount;
export const selectNotificationTabs = () => state => state.notifications.appsId;
export const selectSelectedAppNotificationIds = (appName) => state => state.notifications.apps[appName] ?? [];
export const selectShowNotificationTray = () => state => state.notifications.showNotificationTray;
export const selectNotifications = () => state => state.notifications.notification;
export const selectNotificationsByIds = createSelector(
state => state.notifications.notifications,
state => state.notifications.apps[state.notifications.appName] || [],
(notifications, notificationIds) => notificationIds.map(notificationId => notifications[notificationId]),
);
export const selectSelectedAppName = () => state => state.notifications.appName;
export const selectPaginationData = () => state => state.notifications.pagination;