Page MenuHomePhorge

D12887.1768257954.diff
No OneTemporary

Size
5 KB
Referenced Files
None
Subscribers
None

D12887.1768257954.diff

diff --git a/lib/actions/device-actions.js b/lib/actions/device-actions.js
--- a/lib/actions/device-actions.js
+++ b/lib/actions/device-actions.js
@@ -11,6 +11,11 @@
} from '../types/device-types';
import { getConfig } from '../utils/config.js';
+export type SetDeviceTokenStartedPayload =
+ | { +type: 'nothing_to_set' }
+ | { +type: 'device_token', +deviceToken: ?string }
+ | { +type: 'clear_device_token' };
+
export type DeviceTokens = {
+[keyserverID: string]: ?string,
};
diff --git a/lib/handlers/tunnelbroker-device-token-handler.react.js b/lib/handlers/tunnelbroker-device-token-handler.react.js
--- a/lib/handlers/tunnelbroker-device-token-handler.react.js
+++ b/lib/handlers/tunnelbroker-device-token-handler.react.js
@@ -33,9 +33,10 @@
type: messageToTunnelbrokerTypes.SET_DEVICE_TOKEN,
deviceToken: tunnelbrokerDeviceToken.localToken,
};
- const promise = (async () => {
+ const deviceToken = tunnelbrokerDeviceToken.localToken;
+ const promise: Promise<{ deviceToken: string }> = (async () => {
await sendMessageToTunnelbroker(JSON.stringify(message));
- return { deviceToken: tunnelbrokerDeviceToken.localToken };
+ return { deviceToken };
})();
void dispatchActionPromise(setTBDeviceTokenActionTypes, promise);
}, [
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,6 +1,9 @@
// @flow
-import { setDeviceTokenActionTypes } from '../actions/device-actions.js';
+import {
+ setDeviceTokenActionTypes,
+ type SetDeviceTokenStartedPayload,
+} from '../actions/device-actions.js';
import { setTBDeviceTokenActionTypes } from '../actions/tunnelbroker-actions.js';
import type { BaseAction } from '../types/redux-types.js';
import type { TunnelbrokerDeviceToken } from '../types/tunnelbroker-device-token-types.js';
@@ -10,11 +13,14 @@
action: BaseAction,
): TunnelbrokerDeviceToken {
if (action.type === setDeviceTokenActionTypes.started) {
- if (!action.payload) {
+ const payload: SetDeviceTokenStartedPayload = action.payload;
+ if (payload.type === 'nothing_to_set') {
return state;
}
- const { deviceToken } = action.payload;
- return { ...state, localToken: deviceToken };
+ if (payload.type === 'clear_device_token') {
+ return { ...state, localToken: null };
+ }
+ return { ...state, localToken: payload.deviceToken };
} else if (action.type === setTBDeviceTokenActionTypes.success) {
const { deviceToken } = action.payload;
return { ...state, tunnelbrokerToken: deviceToken };
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
@@ -154,7 +154,10 @@
UserStore,
UserInfo,
} from './user-types.js';
-import type { SetDeviceTokenActionPayload } from '../actions/device-actions.js';
+import type {
+ SetDeviceTokenActionPayload,
+ SetDeviceTokenStartedPayload,
+} from '../actions/device-actions.js';
import type {
UpdateConnectionStatusPayload,
SetLateResponsePayload,
@@ -833,9 +836,7 @@
}
| {
+type: 'SET_DEVICE_TOKEN_STARTED',
- +payload: ?{
- +deviceToken: ?string,
- },
+ +payload: SetDeviceTokenStartedPayload,
+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
@@ -7,12 +7,11 @@
import { Notification as InAppNotification } from 'react-native-in-app-message';
import { recordAlertActionType } from 'lib/actions/alert-actions.js';
-import type {
- DeviceTokens,
- SetDeviceTokenActionPayload,
-} from 'lib/actions/device-actions.js';
import {
+ type DeviceTokens,
setDeviceTokenActionTypes,
+ type SetDeviceTokenStartedPayload,
+ type SetDeviceTokenActionPayload,
useSetDeviceToken,
useSetDeviceTokenFanout,
} from 'lib/actions/device-actions.js';
@@ -266,7 +265,7 @@
deviceTokensMap[keyserverID] = deviceToken;
}
}
- this.setDeviceToken(deviceTokensMap);
+ this.setDeviceToken(deviceTokensMap, { type: 'nothing_to_set' });
}
}
@@ -531,12 +530,12 @@
deviceTokensMap[keyserverID] = deviceToken;
}
}
- this.setDeviceToken(deviceTokensMap, { deviceToken });
+ this.setDeviceToken(deviceTokensMap, { type: 'device_token', deviceToken });
};
setDeviceToken(
deviceTokens: DeviceTokens,
- payload: ?{ deviceToken: ?string },
+ payload: SetDeviceTokenStartedPayload,
) {
void this.props.dispatchActionPromise(
setDeviceTokenActionTypes,
@@ -551,7 +550,7 @@
setDeviceTokenActionTypes,
this.props.setDeviceTokenFanout(null),
undefined,
- { deviceToken: null },
+ { type: 'clear_device_token' },
);
};
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
@@ -61,7 +61,7 @@
setDeviceTokenActionTypes,
callSetDeviceToken(token),
undefined,
- { deviceToken: token },
+ { type: 'device_token', deviceToken: token },
);
}),
[callSetDeviceToken, dispatchActionPromise],
@@ -153,7 +153,7 @@
setDeviceTokenActionTypes,
callSetDeviceToken(token),
undefined,
- { deviceToken: token },
+ { type: 'device_token', deviceToken: token },
);
}, [callSetDeviceToken, dispatchActionPromise, publicKey, staffCanSee]);
}

File Metadata

Mime Type
text/plain
Expires
Mon, Jan 12, 10:45 PM (17 h, 5 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
5925121
Default Alt Text
D12887.1768257954.diff (5 KB)

Event Timeline