HomePhabricator
Diffusion Comm 99b1b9cd5ba1

[web] Add setInitialReduxState action

Description

[web] Add setInitialReduxState action

Summary:
ENG-4752
Depends on D9124

Action for the previously introduced endpoint. It's defined inside web and doesn't have the STARTED, SUCCESS, FAILED actions because:

  • This is a web-specific endpoint that returns (and expects) web-specific data (e.g. urlInfo, web nav info)
  • To simulate the previous behaviour as much possible this action shouldn't interact much with other reducers and that's why it's inside of the web reducer
  • We don't really have use case for tracking progress and failure currently. The app can't function at all until this endpoint is called successfuly
  • Adding the STARTED etc. variants and useDispatchActionPromise would require moving it to lib and BaseAction. But it can't be moved to lib because it uses web-specific types

If ever decide to expand it to native, it shouldn't be much of a problem to rework it (the added code is quite small).

Test Plan:
Call:

const callGetInitialReduxState = useServerCall(getInitialReduxState);
const urlInfo = infoFromURL(decodeURI(window.location.href));
const payload = await callGetInitialReduxState(urlInfo);
dispatch({ type: setInitialReduxState, payload });

after the app loaded.

  • Check if the action contained the expected payload.
  • Check that diff after applying this action only contained lastUserInteractionCalendar, lastPruned, updatesCurrentAsOf etc. (the "static" data was the same)

Reviewers: kamil, inka, atul

Reviewed By: kamil

Subscribers: ashoat, tomek

Differential Revision: https://phab.comm.dev/D9140

Details

Provenance
Michal Gniadek <michal.gniadek@swmansion.com>Authored on Sep 5 2023, 6:23 AM
Reviewer
kamil
Differential Revision
D9140: [web] Add setInitialReduxState action
Parents
rCOMMe1f05c7d2e87: [keyserver] Implement `getInitialReduxStateResponder`
Branches
Unknown
Tags
Unknown

Event Timeline

Michal Gniadek <michal.gniadek@swmansion.com> committed rCOMM99b1b9cd5ba1: [web] Add setInitialReduxState action (authored by Michal Gniadek <michal.gniadek@swmansion.com>).Sep 20 2023, 2:26 AM