diff --git a/lib/actions/alert-actions.js b/lib/actions/alert-actions.js
--- a/lib/actions/alert-actions.js
+++ b/lib/actions/alert-actions.js
@@ -1,5 +1,5 @@
// @flow
-const recordNotifPermissionAlertActionType = 'RECORD_NOTIF_PERMISSION_ALERT';
+const recordAlertActionType = 'RECORD_ALERT';
-export { recordNotifPermissionAlertActionType };
+export { recordAlertActionType };
diff --git a/lib/reducers/alert-reducer.js b/lib/reducers/alert-reducer.js
--- a/lib/reducers/alert-reducer.js
+++ b/lib/reducers/alert-reducer.js
@@ -1,23 +1,24 @@
// @flow
-import { recordNotifPermissionAlertActionType } from '../actions/alert-actions.js';
-import { alertTypes, type AlertStore } from '../types/alert-types.js';
+import { recordAlertActionType } from '../actions/alert-actions.js';
+import type { AlertStore } from '../types/alert-types.js';
import type { BaseAction } from '../types/redux-types';
function reduceAlertStore(state: AlertStore, action: BaseAction): AlertStore {
- if (action.type === recordNotifPermissionAlertActionType) {
+ if (action.type === recordAlertActionType) {
return {
...state,
alertInfos: {
...state.alertInfos,
- [alertTypes.NOTIF_PERMISSION]: {
+ [(action.payload.alertType: string)]: {
totalAlerts:
- state.alertInfos[alertTypes.NOTIF_PERMISSION].totalAlerts + 1,
+ state.alertInfos[action.payload.alertType].totalAlerts + 1,
lastAlertTime: action.payload.time,
},
},
};
}
+
return state;
}
diff --git a/lib/types/alert-types.js b/lib/types/alert-types.js
--- a/lib/types/alert-types.js
+++ b/lib/types/alert-types.js
@@ -20,6 +20,11 @@
+alertInfos: AlertInfos,
};
+export type RecordAlertActionPayload = {
+ +alertType: AlertType,
+ +time: number,
+};
+
const defaultAlertInfo: AlertInfo = {
totalAlerts: 0,
lastAlertTime: 0,
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,7 +15,7 @@
QueueActivityUpdatesPayload,
SetThreadUnreadStatusPayload,
} from './activity-types.js';
-import type { AlertStore } from './alert-types.js';
+import type { AlertStore, RecordAlertActionPayload } from './alert-types.js';
import type {
AuxUserStore,
SetFarcasterFriendsFIDPayload,
@@ -1095,8 +1095,8 @@
+loadingInfo: LoadingInfo,
}
| {
- +type: 'RECORD_NOTIF_PERMISSION_ALERT',
- +payload: { +time: number },
+ +type: 'RECORD_ALERT',
+ +payload: RecordAlertActionPayload,
}
| {
+type: 'UPDATE_USER_AVATAR_STARTED',
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
@@ -6,7 +6,7 @@
import { LogBox, Platform } from 'react-native';
import { Notification as InAppNotification } from 'react-native-in-app-message';
-import { recordNotifPermissionAlertActionType } from 'lib/actions/alert-actions.js';
+import { recordAlertActionType } from 'lib/actions/alert-actions.js';
import type {
DeviceTokens,
SetDeviceTokenActionPayload,
@@ -29,7 +29,11 @@
} from 'lib/selectors/thread-selectors.js';
import { isLoggedIn } from 'lib/selectors/user-selectors.js';
import { mergePrefixIntoBody } from 'lib/shared/notif-utils.js';
-import { alertTypes, type AlertInfo } from 'lib/types/alert-types.js';
+import {
+ alertTypes,
+ type AlertInfo,
+ type RecordAlertActionPayload,
+} 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';
@@ -566,9 +570,15 @@
if (shouldSkipPushPermissionAlert(alertInfo)) {
return;
}
+
+ const payload: RecordAlertActionPayload = {
+ alertType: alertTypes.NOTIF_PERMISSION,
+ time: Date.now(),
+ };
+
this.props.dispatch({
- type: recordNotifPermissionAlertActionType,
- payload: { time: Date.now() },
+ type: recordAlertActionType,
+ payload,
});
Alert.alert(
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
@@ -2,7 +2,7 @@
import * as React from 'react';
-import { recordNotifPermissionAlertActionType } from 'lib/actions/alert-actions.js';
+import { recordAlertActionType } from 'lib/actions/alert-actions.js';
import {
useSetDeviceTokenFanout,
setDeviceTokenActionTypes,
@@ -10,7 +10,10 @@
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 {
+ alertTypes,
+ type RecordAlertActionPayload,
+} 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';
@@ -183,9 +186,15 @@
) {
// Ask existing users that are already logged in for permission
modalContext.pushModal();
+
+ const payload: RecordAlertActionPayload = {
+ alertType: alertTypes.NOTIF_PERMISSION,
+ time: Date.now(),
+ };
+
dispatch({
- type: recordNotifPermissionAlertActionType,
- payload: { time: Date.now() },
+ type: recordAlertActionType,
+ payload,
});
}
})();
@@ -207,9 +216,15 @@
!shouldSkipPushPermissionAlert(notifPermissionAlertInfo)
) {
modalContext.pushModal();
+
+ const payload: RecordAlertActionPayload = {
+ alertType: alertTypes.NOTIF_PERMISSION,
+ time: Date.now(),
+ };
+
dispatch({
- type: recordNotifPermissionAlertActionType,
- payload: { time: Date.now() },
+ type: recordAlertActionType,
+ payload,
});
}
}