Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F3375255
D4886.id15816.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
2 KB
Referenced Files
None
Subscribers
None
D4886.id15816.diff
View Options
diff --git a/web/app.react.js b/web/app.react.js
--- a/web/app.react.js
+++ b/web/app.react.js
@@ -31,6 +31,7 @@
import LoadingIndicator from './loading-indicator.react';
import { MenuProvider } from './menu-provider.react';
import { ModalProvider, useModalContext } from './modals/modal-provider.react';
+import DeviceIDUpdater from './redux/device-id-updater';
import DisconnectedBar from './redux/disconnected-bar';
import DisconnectedBarVisibilityHandler from './redux/disconnected-bar-visibility-handler';
import FocusHandler from './redux/focus-handler.react';
@@ -142,6 +143,7 @@
<MenuProvider>
<FocusHandler />
<VisibilityHandler />
+ <DeviceIDUpdater />
{content}
{this.props.modals}
</MenuProvider>
diff --git a/web/redux/device-id-reducer.js b/web/redux/device-id-reducer.js
--- a/web/redux/device-id-reducer.js
+++ b/web/redux/device-id-reducer.js
@@ -1,5 +1,11 @@
// @flow
+import {
+ deleteAccountActionTypes,
+ logOutActionTypes,
+} from 'lib/actions/user-actions.js';
+import { setNewSessionActionType } from 'lib/utils/action-utils.js';
+
import type { Action } from '../redux/redux-setup';
import { deviceIDFormatRegex } from '../utils/device-id';
import { setDeviceIDActionType } from './action-types';
@@ -10,6 +16,13 @@
return action.payload;
}
return null;
+ } else if (
+ action.type === logOutActionTypes.success ||
+ action.type === deleteAccountActionTypes.success ||
+ (action.type === setNewSessionActionType &&
+ action.payload.sessionChange.cookieInvalidated)
+ ) {
+ return null;
}
return state;
}
diff --git a/web/redux/device-id-updater.js b/web/redux/device-id-updater.js
new file mode 100644
--- /dev/null
+++ b/web/redux/device-id-updater.js
@@ -0,0 +1,25 @@
+// @flow
+import * as React from 'react';
+import { useDispatch, useSelector } from 'react-redux';
+
+import { generateDeviceID, deviceIDTypes } from '../utils/device-id';
+import { setDeviceIDActionType } from './action-types';
+
+function DeviceIDUpdater(): null {
+ const dispatch = useDispatch();
+ const deviceID = useSelector(state => state.deviceID);
+
+ React.useEffect(() => {
+ if (!deviceID) {
+ const newDeviceID = generateDeviceID(deviceIDTypes.WEB);
+ dispatch({
+ type: setDeviceIDActionType,
+ payload: newDeviceID,
+ });
+ }
+ }, [deviceID, dispatch]);
+
+ return null;
+}
+
+export default DeviceIDUpdater;
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Wed, Nov 27, 7:18 PM (20 h, 45 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2591427
Default Alt Text
D4886.id15816.diff (2 KB)
Attached To
Mode
D4886: [web] Add dispatching SET_DEVICE_ID action
Attached
Detach File
Event Timeline
Log In to Comment