I added a copmonent re-rendering on device ID change and setting a device ID whenever the device ID is null.
On logout/account deletion/cookie invalidation the reducer sets device ID to null, causing SET_DEVICE_ID action to get dispatched.
For now the device ID set on the login/create account screen is also used after login/account creation as I didn't find any reasons not to.
Persistance has not yet been added
Details
Test using redux tools that the device ID is present and changes on logout, cookie invalidation and account deletion.
Diff Detail
- Repository
- rCOMM Comm
- Branch
- inka/redux_device_id
- Lint
No Lint Coverage - Unit
No Test Coverage
Event Timeline
it is not yet possible to delete an account on web
It is possible. You can do that by opening account settings (cog icon in bottom left corner), then open danger zone and there's an option to do so.
web/redux/device-id-updater.js | ||
---|---|---|
2–12 | In all the places we import React and use it instead of importing the effect. I think it might make sense to keep it consistent. | |
13 | It might be a little safer to handle also undefined. We can do that by converting deviceID to boolean |
It is possible. You can do that by opening account settings (cog icon in bottom left corner), then open danger zone and there's an option to do so.
Right, sorry, I missed that.
web/redux/device-id-updater.js | ||
---|---|---|
13–19 ↗ | (On Diff #15816) | If we end up adding more parameters into the dep list, or if dispatch changes, we could end up calling this twice in a row. It could be good to make sure we call this only when !deviceID becomes true. We could do this with two variables: const hasDeviceID = !!deviceID; const hadDeviceIDRef = React.useRef(hasDeviceID); React.useEffect(() => { if (hadDeviceIDRef.value && !hasDeviceID) { ... } hadDeviceIDRef.value = hasDeviceID; }, [hasDeviceID, dispatch]); |
web/redux/device-id-updater.js | ||
---|---|---|
12–15 ↗ | (On Diff #15905) | We still need it to run at the beginning, when the server returns the initial id=null, hence the null |