Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F3400822
D11568.id38881.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
10 KB
Referenced Files
None
Subscribers
None
D11568.id38881.diff
View Options
diff --git a/lib/reducers/alert-reducer.js b/lib/reducers/alert-reducer.js
new file mode 100644
--- /dev/null
+++ b/lib/reducers/alert-reducer.js
@@ -0,0 +1,24 @@
+// @flow
+
+import { alertTypes, type AlertStore } from '../types/alert-types.js';
+import type { BaseAction } from '../types/redux-types';
+import { recordNotifPermissionAlertActionType } from '../utils/push-alerts.js';
+
+function reduceAlertStore(state: AlertStore, action: BaseAction): AlertStore {
+ if (action.type === recordNotifPermissionAlertActionType) {
+ return {
+ ...state,
+ alertInfos: {
+ ...state.alertInfos,
+ [alertTypes.NOTIF_PERMISSION]: {
+ totalAlerts:
+ state.alertInfos[alertTypes.NOTIF_PERMISSION].totalAlerts + 1,
+ lastAlertTime: action.payload.time,
+ },
+ },
+ };
+ }
+ return state;
+}
+
+export { reduceAlertStore };
diff --git a/lib/reducers/master-reducer.js b/lib/reducers/master-reducer.js
--- a/lib/reducers/master-reducer.js
+++ b/lib/reducers/master-reducer.js
@@ -1,5 +1,6 @@
// @flow
+import { reduceAlertStore } from './alert-reducer.js';
import { reduceAuxUserStore } from './aux-user-reducer.js';
import reduceCalendarFilters from './calendar-filters-reducer.js';
import { reduceCommunityStore } from './community-reducer.js';
@@ -16,7 +17,6 @@
import { reduceLoadingStatuses } from './loading-reducer.js';
import { reduceMessageStore } from './message-reducer.js';
import reduceBaseNavInfo from './nav-reducer.js';
-import { reduceNotifPermissionAlertInfo } from './notif-permission-alert-info-reducer.js';
import policiesReducer from './policies-reducer.js';
import reduceReportStore from './report-store-reducer.js';
import reduceServicesAccessToken from './services-access-token-reducer.js';
@@ -197,10 +197,7 @@
action,
threadStore,
),
- notifPermissionAlertInfo: reduceNotifPermissionAlertInfo(
- state.notifPermissionAlertInfo,
- action,
- ),
+ alertStore: reduceAlertStore(state.alertStore, action),
lifecycleState: reduceLifecycleState(state.lifecycleState, action),
enabledApps: reduceEnabledApps(state.enabledApps, action),
reportStore,
diff --git a/lib/reducers/notif-permission-alert-info-reducer.js b/lib/reducers/notif-permission-alert-info-reducer.js
deleted file mode 100644
--- a/lib/reducers/notif-permission-alert-info-reducer.js
+++ /dev/null
@@ -1,20 +0,0 @@
-// @flow
-
-import type { AlertInfo } from '../types/alert-types.js';
-import type { BaseAction } from '../types/redux-types';
-import { recordNotifPermissionAlertActionType } from '../utils/push-alerts.js';
-
-function reduceNotifPermissionAlertInfo(
- state: AlertInfo,
- action: BaseAction,
-): AlertInfo {
- if (action.type === recordNotifPermissionAlertActionType) {
- return {
- totalAlerts: state.totalAlerts + 1,
- lastAlertTime: action.payload.time,
- };
- }
- return state;
-}
-
-export { reduceNotifPermissionAlertInfo };
diff --git a/lib/types/redux-types.js b/lib/types/redux-types.js
--- a/lib/types/redux-types.js
+++ b/lib/types/redux-types.js
@@ -15,6 +15,7 @@
QueueActivityUpdatesPayload,
SetThreadUnreadStatusPayload,
} from './activity-types.js';
+import type { AlertStore } from './alert-types.js';
import type {
AuxUserStore,
SetFarcasterFriendsFIDPayload,
@@ -138,7 +139,6 @@
SetLateResponsePayload,
UpdateKeyserverReachabilityPayload,
} from '../keyserver-conn/keyserver-conn-types.js';
-import type { AlertInfo } from '../types/alert-types.js';
export type BaseAppState<NavInfo: BaseNavInfo = BaseNavInfo> = {
+navInfo: NavInfo,
@@ -150,7 +150,7 @@
+messageStore: MessageStore,
+loadingStatuses: { [key: string]: { [idx: number]: LoadingStatus } },
+calendarFilters: $ReadOnlyArray<CalendarFilter>,
- +notifPermissionAlertInfo: AlertInfo,
+ +alertStore: AlertStore,
+watchedThreadIDs: $ReadOnlyArray<string>,
+lifecycleState: LifecycleState,
+enabledApps: EnabledApps,
diff --git a/lib/utils/reducers-utils.test.js b/lib/utils/reducers-utils.test.js
--- a/lib/utils/reducers-utils.test.js
+++ b/lib/utils/reducers-utils.test.js
@@ -2,7 +2,7 @@
import { authoritativeKeyserverID } from './authoritative-keyserver.js';
import { resetUserSpecificState } from './reducers-utils.js';
-import { defaultAlertInfo } from '../types/alert-types.js';
+import { defaultAlertInfo, alertTypes } from '../types/alert-types.js';
import { defaultWebEnabledApps } from '../types/enabled-apps.js';
import { defaultCalendarFilters } from '../types/filter-types.js';
import { defaultKeyserverInfo } from '../types/keyserver-types.js';
@@ -46,7 +46,11 @@
loadingStatuses: {},
calendarFilters: defaultCalendarFilters,
dataLoaded: false,
- notifPermissionAlertInfo: defaultAlertInfo,
+ alertStore: {
+ alertInfos: {
+ [alertTypes.NOTIF_PERMISSION]: defaultAlertInfo,
+ },
+ },
watchedThreadIDs: [],
lifecycleState: 'active',
enabledApps: defaultWebEnabledApps,
diff --git a/native/push/push-handler.react.js b/native/push/push-handler.react.js
--- a/native/push/push-handler.react.js
+++ b/native/push/push-handler.react.js
@@ -28,7 +28,7 @@
} from 'lib/selectors/thread-selectors.js';
import { isLoggedIn } from 'lib/selectors/user-selectors.js';
import { mergePrefixIntoBody } from 'lib/shared/notif-utils.js';
-import type { AlertInfo } from 'lib/types/alert-types.js';
+import { alertTypes, type AlertInfo } from 'lib/types/alert-types.js';
import type { RawMessageInfo } from 'lib/types/message-types.js';
import type { ThreadInfo } from 'lib/types/minimally-encoded-thread-permissions-types.js';
import type { Dispatch } from 'lib/types/redux-types.js';
@@ -779,7 +779,7 @@
const deviceTokens = useSelector(deviceTokensSelector);
const threadInfos = useSelector(threadInfoSelector);
const notifPermissionAlertInfo = useSelector(
- state => state.notifPermissionAlertInfo,
+ state => state.alertStore.alertInfos[alertTypes.NOTIF_PERMISSION],
);
const allUpdatesCurrentAsOf = useSelector(allUpdatesCurrentAsOfSelector);
const activeTheme = useSelector(state => state.globalThemeInfo.activeTheme);
diff --git a/native/redux/default-state.js b/native/redux/default-state.js
--- a/native/redux/default-state.js
+++ b/native/redux/default-state.js
@@ -3,7 +3,7 @@
import { Platform } from 'react-native';
import Orientation from 'react-native-orientation-locker';
-import { defaultAlertInfo } from 'lib/types/alert-types.js';
+import { defaultAlertInfo, alertTypes } from 'lib/types/alert-types.js';
import { defaultEnabledApps } from 'lib/types/enabled-apps.js';
import { defaultCalendarFilters } from 'lib/types/filter-types.js';
import { defaultKeyserverInfo } from 'lib/types/keyserver-types.js';
@@ -43,7 +43,11 @@
calendarFilters: defaultCalendarFilters,
dataLoaded: false,
customServer: natNodeServer,
- notifPermissionAlertInfo: defaultAlertInfo,
+ alertStore: {
+ alertInfos: {
+ [alertTypes.NOTIF_PERMISSION]: defaultAlertInfo,
+ },
+ },
watchedThreadIDs: [],
lifecycleState: 'active',
enabledApps: defaultEnabledApps,
diff --git a/native/redux/state-types.js b/native/redux/state-types.js
--- a/native/redux/state-types.js
+++ b/native/redux/state-types.js
@@ -3,7 +3,7 @@
import type { Orientations } from 'react-native-orientation-locker';
import type { PersistState } from 'redux-persist/es/types.js';
-import type { AlertInfo } from 'lib/types/alert-types.js';
+import type { AlertStore } from 'lib/types/alert-types.js';
import type { AuxUserStore } from 'lib/types/aux-user-types.js';
import type { CommunityStore } from 'lib/types/community-types.js';
import type { DBOpsStore } from 'lib/types/db-ops-types';
@@ -58,7 +58,7 @@
+calendarFilters: $ReadOnlyArray<CalendarFilter>,
+dataLoaded: boolean,
+customServer: ?string,
- +notifPermissionAlertInfo: AlertInfo,
+ +alertStore: AlertStore,
+watchedThreadIDs: $ReadOnlyArray<string>,
+lifecycleState: LifecycleState,
+enabledApps: EnabledApps,
diff --git a/web/push-notif/push-notifs-handler.js b/web/push-notif/push-notifs-handler.js
--- a/web/push-notif/push-notifs-handler.js
+++ b/web/push-notif/push-notifs-handler.js
@@ -9,6 +9,7 @@
import { useModalContext } from 'lib/components/modal-provider.react.js';
import { isLoggedIn } from 'lib/selectors/user-selectors.js';
import { hasMinCodeVersion } from 'lib/shared/version-utils.js';
+import { alertTypes } from 'lib/types/alert-types.js';
import { isDesktopPlatform } from 'lib/types/device-types.js';
import { getConfig } from 'lib/utils/config.js';
import { convertNonPendingIDToNewSchema } from 'lib/utils/migration-utils.js';
@@ -156,7 +157,7 @@
const createPushSubscription = useCreatePushSubscription();
const notifPermissionAlertInfo = useSelector(
- state => state.notifPermissionAlertInfo,
+ state => state.alertStore.alertInfos[alertTypes.NOTIF_PERMISSION],
);
const modalContext = useModalContext();
diff --git a/web/redux/default-state.js b/web/redux/default-state.js
--- a/web/redux/default-state.js
+++ b/web/redux/default-state.js
@@ -1,6 +1,6 @@
// @flow
-import { defaultAlertInfo } from 'lib/types/alert-types.js';
+import { defaultAlertInfo, alertTypes } from 'lib/types/alert-types.js';
import { defaultWebEnabledApps } from 'lib/types/enabled-apps.js';
import { defaultCalendarFilters } from 'lib/types/filter-types.js';
import { defaultKeyserverInfo } from 'lib/types/keyserver-types.js';
@@ -44,7 +44,11 @@
loadingStatuses: {},
calendarFilters: defaultCalendarFilters,
dataLoaded: false,
- notifPermissionAlertInfo: defaultAlertInfo,
+ alertStore: {
+ alertInfos: {
+ [alertTypes.NOTIF_PERMISSION]: defaultAlertInfo,
+ },
+ },
watchedThreadIDs: [],
lifecycleState: 'active',
enabledApps: defaultWebEnabledApps,
diff --git a/web/redux/redux-setup.js b/web/redux/redux-setup.js
--- a/web/redux/redux-setup.js
+++ b/web/redux/redux-setup.js
@@ -30,7 +30,7 @@
identityInvalidSessionDowngrade,
invalidSessionRecovery,
} from 'lib/shared/session-utils.js';
-import type { AlertInfo } from 'lib/types/alert-types.js';
+import type { AlertStore } from 'lib/types/alert-types.js';
import type { AuxUserStore } from 'lib/types/aux-user-types.js';
import type { CommunityStore } from 'lib/types/community-types.js';
import type { MessageID, DBOpsStore } from 'lib/types/db-ops-types.js';
@@ -102,7 +102,7 @@
+calendarFilters: $ReadOnlyArray<CalendarFilter>,
+communityPickerStore: CommunityPickerStore,
+windowDimensions: WindowDimensions,
- +notifPermissionAlertInfo: AlertInfo,
+ +alertStore: AlertStore,
+watchedThreadIDs: $ReadOnlyArray<string>,
+lifecycleState: LifecycleState,
+enabledApps: EnabledApps,
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Tue, Dec 3, 9:04 AM (20 h, 45 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2611111
Default Alt Text
D11568.id38881.diff (10 KB)
Attached To
Mode
D11568: [lib/native/web] refactor notif permission alert info reducer
Attached
Detach File
Event Timeline
Log In to Comment