Page MenuHomePhabricator

D12536.diff
No OneTemporary

D12536.diff

diff --git a/lib/reducers/tunnelbroker-device-token-reducer.js b/lib/reducers/tunnelbroker-device-token-reducer.js
--- a/lib/reducers/tunnelbroker-device-token-reducer.js
+++ b/lib/reducers/tunnelbroker-device-token-reducer.js
@@ -1,13 +1,21 @@
// @flow
+import { setDeviceTokenActionTypes } from '../actions/device-actions.js';
import type { BaseAction } from '../types/redux-types.js';
import type { TunnelbrokerDeviceToken } from '../types/tunnelbroker-device-token-types.js';
-/* eslint-disable no-unused-vars */
function reduceTunnelbrokerDeviceToken(
state: TunnelbrokerDeviceToken,
action: BaseAction,
): TunnelbrokerDeviceToken {
+ if (action.type === setDeviceTokenActionTypes.started) {
+ if (!action.payload) {
+ return state;
+ }
+ const { deviceToken } = action.payload;
+ return { ...state, localToken: deviceToken };
+ }
+
return state;
}
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
@@ -829,7 +829,9 @@
}
| {
+type: 'SET_DEVICE_TOKEN_STARTED',
- +payload?: void,
+ +payload: ?{
+ +deviceToken: ?string,
+ },
+loadingInfo: LoadingInfo,
}
| {
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
@@ -528,13 +528,18 @@
deviceTokensMap[keyserverID] = deviceToken;
}
}
- this.setDeviceToken(deviceTokensMap);
+ this.setDeviceToken(deviceTokensMap, { deviceToken });
};
- setDeviceToken(deviceTokens: DeviceTokens) {
+ setDeviceToken(
+ deviceTokens: DeviceTokens,
+ payload: ?{ deviceToken: ?string },
+ ) {
void this.props.dispatchActionPromise(
setDeviceTokenActionTypes,
this.props.setDeviceToken(deviceTokens),
+ undefined,
+ payload,
);
}
@@ -542,6 +547,8 @@
void this.props.dispatchActionPromise(
setDeviceTokenActionTypes,
this.props.setDeviceTokenFanout(null),
+ undefined,
+ { deviceToken: null },
);
};
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
@@ -60,6 +60,8 @@
void dispatchActionPromise(
setDeviceTokenActionTypes,
callSetDeviceToken(token),
+ undefined,
+ { deviceToken: token },
);
}),
[callSetDeviceToken, dispatchActionPromise],
@@ -146,9 +148,12 @@
applicationServerKey: publicKey,
});
+ const token = JSON.stringify(subscription);
void dispatchActionPromise(
setDeviceTokenActionTypes,
- callSetDeviceToken(JSON.stringify(subscription)),
+ callSetDeviceToken(token),
+ undefined,
+ { deviceToken: token },
);
}, [callSetDeviceToken, dispatchActionPromise, publicKey, staffCanSee]);
}

File Metadata

Mime Type
text/plain
Expires
Wed, Nov 27, 12:09 AM (20 h, 45 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2587008
Default Alt Text
D12536.diff (2 KB)

Event Timeline