Skip to content
This repository has been archived by the owner on Mar 13, 2024. It is now read-only.

MM-13348: Fix TOS reappears on next page refresh #2178

Merged
merged 4 commits into from
Dec 13, 2018
Merged

MM-13348: Fix TOS reappears on next page refresh #2178

merged 4 commits into from
Dec 13, 2018

Conversation

chetanyakan
Copy link
Contributor

Summary

loadMe method expects clientConfig to be loaded in advance. The value from clientConfig is used to load terms of service status and custom emoji conditionally.

Ticket Link

https://mattermost.atlassian.net/browse/MM-13348

Checklist

  • Ran make check-style to check for style errors (required for all pull requests)
  • Ran make test to ensure unit and component tests passed
  • Touches critical sections of the codebase (custom terms of service)

// if any new promise needs to be added please be mindful of the order as it is used in root.jsx for redirection
return async (dispatch) => {
// need to await for clientConfig first as it is required for loadMe
const clientConfig = await dispatch(getClientConfig());
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@chetanyakan, is it safe to dispatch getLicenseConfig asynchronously?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@lieut-data I am not sure. Could you elaborate on why it would not be safe?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will slow down the initiation of the app as we are waiting for getClientConfig response. Does it not work if we pass the key value from config to the react component it requires for conditional updates?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One alternative is to get terms of service and custom emoji always regardless of client config value in mattermost-redux.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@lieut-data @sudheerDev Would it make more sense to make this change instead?

Also, I am not sure about the working of custom emoji. So, could you help me understand if changing that would be required.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@sudheerDev This API call in loadMe of mattermost-redux is called only when config.EnableCustomTermsOfService === 'true'.

But since the config is not loaded, the condition will always evaluate to false and the user's terms-of-service status is not fetched on page refresh. This is why user needs to re-accept terms of service on every page refresh.

So, either we need config before API call for loadMe or we don't use config inside loadMe.

Copy link
Contributor

@sudheerDev sudheerDev Dec 11, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Got it!. Thanks. Make sense to exclude them from loadMe and call those two api calls here after these promises are resolved IMO.

@lieut-data The config call does not take a long time to return around 200ms on pre-release. I am not sure if i am reading too much into this.

Copy link
Contributor Author

@chetanyakan chetanyakan Dec 11, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@lieut-data @sudheerDev
It makes sense to mention the above mentioned behavior was changed in this PR.

Here, getClientConfig was called before loadMe and getLicenseConfig.
And here, after refactoring, getClientConfig, loadMe and getLicenseConfig are called parallelly.

I couldn't figure out whether this intentional or changed unintentionally while refactoring.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suspect the parallelization was done intentionally. I really like @sudheerDev's idea of conditionally doing the TOS fetch here instead of necessarily within loadMe, but I wouldn't be surprised if that opens up other issues, so it might be easier to defer.

We're investigating ways to fix this login/startup pipeline, but for now I'd propose that we at least continue to parallelize getClientConfig and getLicenseConfig, await on Promise.all, and then await on UserActions.loadMe(), finally returning all the promises together. That should at least preserve the parallelization of loading config and license.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. We shouldn't fetch TOS details here in the web app compared to redux as it would also be needed for the mobile app.
  2. Updated to parallelize getClientConfig and getLicenseConfig.

@lieut-data lieut-data added the 2: Dev Review Requires review by a core commiter label Dec 11, 2018
@jasonblais jasonblais added this to the v5.6.0 milestone Dec 11, 2018
@jasonblais jasonblais added the CherryPick/Approved Meant for the quality or patch release tracked in the milestone label Dec 11, 2018
Copy link
Contributor

@sudheerDev sudheerDev left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

}

return Promise.all(promises);
return [...resolvedPromises, loadMeResponse];
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If there is no MMUSERID cookie, loadMeResponse will be undefined, whereas previously it wasn't returned at all. Since we're creating a new array on line 26 anyway, I'd just drop the const on resolvedPromises and push as before.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@lieut-data Good catch. Updated.

Copy link
Member

@lieut-data lieut-data left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perfect! And right, no need to drop const since we’re not reassigning. Always trips me up :)

@jwilander jwilander added 4: Reviews Complete All reviewers have approved the pull request Do Not Merge Should not be merged until this label is removed and removed 2: Dev Review Requires review by a core commiter 4: Reviews Complete All reviewers have approved the pull request CherryPick/Approved Meant for the quality or patch release tracked in the milestone Do Not Merge Should not be merged until this label is removed labels Dec 13, 2018
@jwilander jwilander removed this from the v5.6.0 milestone Dec 13, 2018
@jwilander jwilander merged commit 40051c8 into mattermost:master Dec 13, 2018
@amyblais amyblais added this to the v5.7.0 milestone Dec 13, 2018
@jasonblais jasonblais modified the milestones: v5.7.0, v5.8.0 Dec 14, 2018
@lindy65 lindy65 removed the 4: Reviews Complete All reviewers have approved the pull request label Jan 10, 2019
@JtheBAB JtheBAB mentioned this pull request Jan 15, 2019
9 tasks
@amyblais amyblais added Changelog/Not Needed Does not require a changelog entry Docs/Not Needed Does not require documentation labels Jan 23, 2019
@lindalumitchell lindalumitchell added the Tests/Done Release tests have been written label Feb 11, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Changelog/Not Needed Does not require a changelog entry Docs/Not Needed Does not require documentation Tests/Done Release tests have been written
Projects
None yet
8 participants