Page MenuHomePhabricator

D9816.id33316.diff
No OneTemporary

D9816.id33316.diff

diff --git a/lib/reducers/device-token-reducer.js b/lib/reducers/device-token-reducer.js
deleted file mode 100644
--- a/lib/reducers/device-token-reducer.js
+++ /dev/null
@@ -1,26 +0,0 @@
-// @flow
-
-import { setDeviceTokenActionTypes } from '../actions/device-actions.js';
-import type { BaseAction } from '../types/redux-types';
-import { incrementalStateSyncActionType } from '../types/socket-types.js';
-import { updateTypes } from '../types/update-types-enum.js';
-import { ashoatKeyserverID } from '../utils/validation-utils.js';
-
-function reduceDeviceToken(state: ?string, action: BaseAction): ?string {
- if (action.type === setDeviceTokenActionTypes.success) {
- return action.payload.deviceTokens[ashoatKeyserverID];
- }
- if (action.type === incrementalStateSyncActionType) {
- for (const update of action.payload.updatesResult.newUpdates) {
- if (
- update.type === updateTypes.BAD_DEVICE_TOKEN &&
- update.deviceToken === state
- ) {
- return null;
- }
- }
- }
- return state;
-}
-
-export { reduceDeviceToken };
diff --git a/lib/reducers/keyserver-reducer.js b/lib/reducers/keyserver-reducer.js
--- a/lib/reducers/keyserver-reducer.js
+++ b/lib/reducers/keyserver-reducer.js
@@ -1,9 +1,11 @@
// @flow
-import { reduceDeviceToken } from './device-token-reducer.js';
import { unsupervisedBackgroundActionType } from './lifecycle-state-reducer.js';
import { updateActivityActionTypes } from '../actions/activity-actions.js';
-import { updateLastCommunicatedPlatformDetailsActionType } from '../actions/device-actions.js';
+import {
+ updateLastCommunicatedPlatformDetailsActionType,
+ setDeviceTokenActionTypes,
+} from '../actions/device-actions.js';
import {
addKeyserverActionType,
removeKeyserverActionType,
@@ -17,7 +19,7 @@
resetUserStateActionType,
} from '../actions/user-actions.js';
import { queueActivityUpdatesActionType } from '../types/activity-types.js';
-import type { KeyserverStore } from '../types/keyserver-types';
+import type { KeyserverInfos, KeyserverStore } from '../types/keyserver-types';
import type { BaseAction } from '../types/redux-types.js';
import {
fullStateSyncActionType,
@@ -26,6 +28,7 @@
setLateResponseActionType,
updateDisconnectedBarActionType,
} from '../types/socket-types.js';
+import { updateTypes } from '../types/update-types-enum.js';
import { processUpdatesActionType } from '../types/update-types.js';
import { setNewSessionActionType } from '../utils/action-utils.js';
import { getConfig } from '../utils/config.js';
@@ -131,6 +134,16 @@
};
} else if (action.type === incrementalStateSyncActionType) {
const { keyserverID } = action.payload;
+ let deviceToken = state.keyserverInfos[keyserverID].deviceToken;
+ for (const update of action.payload.updatesResult.newUpdates) {
+ if (
+ update.type === updateTypes.BAD_DEVICE_TOKEN &&
+ update.deviceToken === state.keyserverInfos[keyserverID].deviceToken
+ ) {
+ deviceToken = null;
+ break;
+ }
+ }
state = {
...state,
keyserverInfos: {
@@ -138,6 +151,7 @@
[keyserverID]: {
...state.keyserverInfos[keyserverID],
updatesCurrentAsOf: action.payload.updatesResult.currentAsOf,
+ deviceToken,
},
},
};
@@ -334,22 +348,18 @@
},
},
};
- }
-
- const deviceToken = reduceDeviceToken(
- state.keyserverInfos[ashoatKeyserverID].deviceToken,
- action,
- );
- if (deviceToken !== state.keyserverInfos[ashoatKeyserverID].deviceToken) {
+ } else if (action.type === setDeviceTokenActionTypes.success) {
+ const { deviceTokens } = action.payload;
+ const keyserverInfos: { ...KeyserverInfos } = { ...state.keyserverInfos };
+ for (const keyserverID in deviceTokens) {
+ keyserverInfos[keyserverID] = {
+ ...keyserverInfos[keyserverID],
+ deviceToken: deviceTokens[keyserverID],
+ };
+ }
state = {
...state,
- keyserverInfos: {
- ...state.keyserverInfos,
- [ashoatKeyserverID]: {
- ...state.keyserverInfos[ashoatKeyserverID],
- deviceToken,
- },
- },
+ keyserverInfos,
};
}

File Metadata

Mime Type
text/plain
Expires
Wed, Nov 27, 4:31 AM (16 h, 7 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2588002
Default Alt Text
D9816.id33316.diff (4 KB)

Event Timeline