Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F3695134
D11600.id39013.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
6 KB
Referenced Files
None
Subscribers
None
D11600.id39013.diff
View Options
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(<PushNotifModal />);
+
+ 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(<PushNotifModal />);
+
+ const payload: RecordAlertActionPayload = {
+ alertType: alertTypes.NOTIF_PERMISSION,
+ time: Date.now(),
+ };
+
dispatch({
- type: recordNotifPermissionAlertActionType,
- payload: { time: Date.now() },
+ type: recordAlertActionType,
+ payload,
});
}
}
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Wed, Jan 8, 10:39 AM (2 h, 12 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2816534
Default Alt Text
D11600.id39013.diff (6 KB)
Attached To
Mode
D11600: [lib/native/web] refactor recordNotifPermissionAlertActionType to recordAlertActionType
Attached
Detach File
Event Timeline
Log In to Comment