Page MenuHomePhabricator

D7029.diff
No OneTemporary

D7029.diff

diff --git a/keyserver/src/responders/website-responders.js b/keyserver/src/responders/website-responders.js
--- a/keyserver/src/responders/website-responders.js
+++ b/keyserver/src/responders/website-responders.js
@@ -29,6 +29,7 @@
import { currentDateInTimeZone } from 'lib/utils/date-utils.js';
import { ServerError } from 'lib/utils/errors.js';
import { promiseAll } from 'lib/utils/promises.js';
+import { defaultNotifPermissionAlertInfo } from 'lib/utils/push-alerts.js';
import getTitle from 'web/title/getTitle.js';
import { navInfoFromURL } from 'web/url-utils.js';
@@ -390,6 +391,7 @@
urlPrefix: '',
windowDimensions: { width: 0, height: 0 },
baseHref,
+ notifPermissionAlertInfo: defaultNotifPermissionAlertInfo,
connection: {
...defaultConnectionInfo(viewer.platform ?? 'web', viewer.timeZone),
actualizedCalendarQuery: calendarQuery,
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
@@ -12,6 +12,7 @@
import reduceNextLocalID from './local-id-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 { reduceThreadInfos } from './thread-reducer.js';
@@ -97,6 +98,10 @@
updatesCurrentAsOf,
urlPrefix: reduceURLPrefix(state.urlPrefix, action),
calendarFilters: reduceCalendarFilters(state.calendarFilters, action),
+ notifPermissionAlertInfo: reduceNotifPermissionAlertInfo(
+ state.notifPermissionAlertInfo,
+ action,
+ ),
connection,
lifecycleState: reduceLifecycleState(state.lifecycleState, action),
enabledApps: reduceEnabledApps(state.enabledApps, action),
diff --git a/lib/reducers/notif-permission-alert-info-reducer.js b/lib/reducers/notif-permission-alert-info-reducer.js
new file mode 100644
--- /dev/null
+++ b/lib/reducers/notif-permission-alert-info-reducer.js
@@ -0,0 +1,22 @@
+// @flow
+
+import type { BaseAction } from '../types/redux-types';
+import {
+ type NotifPermissionAlertInfo,
+ recordNotifPermissionAlertActionType,
+} from '../utils/push-alerts.js';
+
+function reduceNotifPermissionAlertInfo(
+ state: NotifPermissionAlertInfo,
+ action: BaseAction,
+): NotifPermissionAlertInfo {
+ 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
@@ -84,6 +84,7 @@
import type { ClientUpdatesResultWithUserInfos } from './update-types.js';
import type { CurrentUserInfo, UserStore } from './user-types.js';
import type { Shape } from '../types/core.js';
+import type { NotifPermissionAlertInfo } from '../utils/push-alerts.js';
export type BaseAppState<NavInfo: BaseNavInfo> = {
navInfo: NavInfo,
@@ -97,6 +98,7 @@
loadingStatuses: { [key: string]: { [idx: number]: LoadingStatus } },
calendarFilters: $ReadOnlyArray<CalendarFilter>,
urlPrefix: string,
+ notifPermissionAlertInfo: NotifPermissionAlertInfo,
connection: ConnectionInfo,
watchedThreadIDs: $ReadOnlyArray<string>,
lifecycleState: LifecycleState,
@@ -911,6 +913,10 @@
+error: true,
+payload: Error,
+loadingInfo: LoadingInfo,
+ }
+ | {
+ +type: 'RECORD_NOTIF_PERMISSION_ALERT',
+ +payload: { +time: number },
};
export type ActionPayload = ?(Object | Array<*> | $ReadOnlyArray<*> | string);
diff --git a/native/push/alerts.js b/lib/utils/push-alerts.js
rename from native/push/alerts.js
rename to lib/utils/push-alerts.js
--- a/native/push/alerts.js
+++ b/lib/utils/push-alerts.js
@@ -10,4 +10,9 @@
lastAlertTime: 0,
};
-export { defaultNotifPermissionAlertInfo };
+const recordNotifPermissionAlertActionType = 'RECORD_NOTIF_PERMISSION_ALERT';
+
+export {
+ defaultNotifPermissionAlertInfo,
+ recordNotifPermissionAlertActionType,
+};
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
@@ -26,8 +26,11 @@
useDispatchActionPromise,
type DispatchActionPromise,
} from 'lib/utils/action-utils.js';
+import {
+ type NotifPermissionAlertInfo,
+ recordNotifPermissionAlertActionType,
+} from 'lib/utils/push-alerts.js';
-import { type NotifPermissionAlertInfo } from './alerts.js';
import {
androidNotificationChannelID,
handleAndroidMessage,
@@ -59,7 +62,6 @@
import { activeMessageListSelector } from '../navigation/nav-selectors.js';
import { NavContext } from '../navigation/navigation-context.js';
import type { RootNavigationProp } from '../navigation/root-navigator.react.js';
-import { recordNotifPermissionAlertActionType } from '../redux/action-types.js';
import { useSelector } from '../redux/redux-utils.js';
import { RootContext, type RootContextType } from '../root-context.js';
import type { EventSubscription } from '../types/react-native.js';
diff --git a/native/redux/action-types.js b/native/redux/action-types.js
--- a/native/redux/action-types.js
+++ b/native/redux/action-types.js
@@ -13,8 +13,6 @@
import type { GlobalThemeInfo } from '../types/themes.js';
export const resetUserStateActionType = 'RESET_USER_STATE';
-export const recordNotifPermissionAlertActionType =
- 'RECORD_NOTIF_PERMISSION_ALERT';
export const updateDimensionsActiveType = 'UPDATE_DIMENSIONS';
export const updateConnectivityActiveType = 'UPDATE_CONNECTIVITY';
export const updateThemeInfoActionType = 'UPDATE_THEME_INFO';
@@ -39,10 +37,6 @@
+type: 'SET_CUSTOM_SERVER',
+payload: string,
}
- | {
- +type: 'RECORD_NOTIF_PERMISSION_ALERT',
- +payload: { +time: number },
- }
| { +type: 'RESET_USER_STATE' }
| {
+type: 'UPDATE_DIMENSIONS',
diff --git a/native/redux/persist.js b/native/redux/persist.js
--- a/native/redux/persist.js
+++ b/native/redux/persist.js
@@ -28,12 +28,12 @@
translateClientDBMessageInfoToRawMessageInfo,
translateRawMessageInfoToClientDBMessageInfo,
} from 'lib/utils/message-ops-utils.js';
+import { defaultNotifPermissionAlertInfo } from 'lib/utils/push-alerts.js';
import { convertThreadStoreOperationsToClientDBOperations } from 'lib/utils/thread-ops-utils.js';
import { migrateThreadStoreForEditThreadPermissions } from './edit-thread-permission-migration.js';
import type { AppState } from './state-types.js';
import { commCoreModule } from '../native-modules.js';
-import { defaultNotifPermissionAlertInfo } from '../push/alerts.js';
import { defaultDeviceCameraInfo } from '../types/camera.js';
import { defaultGlobalThemeInfo } from '../types/themes.js';
import { isTaskCancelledError } from '../utils/error-handling.js';
diff --git a/native/redux/redux-setup.js b/native/redux/redux-setup.js
--- a/native/redux/redux-setup.js
+++ b/native/redux/redux-setup.js
@@ -30,11 +30,11 @@
import { reduxLoggerMiddleware } from 'lib/utils/action-logger.js';
import { setNewSessionActionType } from 'lib/utils/action-utils.js';
import { convertMessageStoreOperationsToClientDBOperations } from 'lib/utils/message-ops-utils.js';
+import { defaultNotifPermissionAlertInfo } from 'lib/utils/push-alerts.js';
import { convertThreadStoreOperationsToClientDBOperations } from 'lib/utils/thread-ops-utils.js';
import {
resetUserStateActionType,
- recordNotifPermissionAlertActionType,
updateDimensionsActiveType,
updateConnectivityActiveType,
updateThemeInfoActionType,
@@ -54,7 +54,6 @@
import { defaultNavInfo } from '../navigation/default-state.js';
import { getGlobalNavContext } from '../navigation/icky-global.js';
import { activeMessageListSelector } from '../navigation/nav-selectors.js';
-import { defaultNotifPermissionAlertInfo } from '../push/alerts.js';
import reactotron from '../reactotron.js';
import { defaultDeviceCameraInfo } from '../types/camera.js';
import { defaultConnectivityInfo } from '../types/connectivity.js';
@@ -221,14 +220,6 @@
...state,
customServer: action.payload,
};
- } else if (action.type === recordNotifPermissionAlertActionType) {
- return {
- ...state,
- notifPermissionAlertInfo: {
- totalAlerts: state.notifPermissionAlertInfo.totalAlerts + 1,
- lastAlertTime: action.payload.time,
- },
- };
} else if (action.type === resetUserStateActionType) {
const cookie =
state.cookie && state.cookie.startsWith('anonymous=')
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
@@ -15,10 +15,10 @@
import type { ConnectionInfo } from 'lib/types/socket-types.js';
import type { ThreadStore } from 'lib/types/thread-types.js';
import type { CurrentUserInfo, UserStore } from 'lib/types/user-types.js';
+import type { NotifPermissionAlertInfo } from 'lib/utils/push-alerts.js';
import type { DimensionsInfo } from './dimensions-updater.react.js';
import type { NavInfo } from '../navigation/default-state.js';
-import type { NotifPermissionAlertInfo } from '../push/alerts.js';
import type { DeviceCameraInfo } from '../types/camera.js';
import type { ConnectivityInfo } from '../types/connectivity.js';
import type { GlobalThemeInfo } from '../types/themes.js';
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
@@ -35,6 +35,7 @@
import type { ThreadStore } from 'lib/types/thread-types.js';
import type { CurrentUserInfo, UserStore } from 'lib/types/user-types.js';
import { setNewSessionActionType } from 'lib/utils/action-utils.js';
+import type { NotifPermissionAlertInfo } from 'lib/utils/push-alerts.js';
import {
updateWindowActiveActionType,
@@ -79,6 +80,7 @@
cookie?: void,
deviceToken: ?string,
baseHref: string,
+ notifPermissionAlertInfo: NotifPermissionAlertInfo,
connection: ConnectionInfo,
watchedThreadIDs: $ReadOnlyArray<string>,
lifecycleState: LifecycleState,

File Metadata

Mime Type
text/plain
Expires
Mon, Dec 23, 4:06 PM (15 h, 21 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2695289
Default Alt Text
D7029.diff (10 KB)

Event Timeline