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

Add a logged in class to EmbeddedPage and react to MatrixClient changes #3066

Merged
merged 1 commit into from
Jun 5, 2019

Conversation

turt2live
Copy link
Member

See element-hq/element-web#9957

The two hacks introduced here are for different reasons, mostly related to the welcome page. If you land directly on the welcome page, the app's lifecycle is highly unlikely to have a bootstrapped client. This results in the loggedIn class being false. When the client is later set up (loaded from session, new guest account registered, etc) the context fails to update for the EmbeddedPage, and we need to give it a kick to re-render. It's arguable if we should even keep using the context here.

See element-hq/element-web#9957

The two hacks introduced here are for different reasons, mostly related to the welcome page. If you land directly on the welcome page, the app's lifecycle is highly unlikely to have a bootstrapped client. This results in the loggedIn class being false. When the client is later set up (loaded from session, new guest account registered, etc) the context fails to update for the EmbeddedPage, and we need to give it a kick to re-render. It's arguable if we should even keep using the context here.
@turt2live turt2live requested a review from a team June 4, 2019 22:12
@turt2live turt2live added the X-Release-Blocker This affects the current release cycle and must be solved for a release to happen label Jun 5, 2019
@jryans jryans requested review from jryans and removed request for a team June 5, 2019 08:37
Copy link
Collaborator

@jryans jryans left a comment

Choose a reason for hiding this comment

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

Thanks, seems fine! 😁

render() {
const client = this.context.matrixClient;
// HACK: Workaround for the context's MatrixClient not updating.
const client = this.context.matrixClient || MatrixClientPeg.get();
Copy link
Collaborator

Choose a reason for hiding this comment

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

Yeah, if it's easier, feel free to not use the context here.

Copy link
Member Author

Choose a reason for hiding this comment

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

I think I'll leave it for compatibility concerns, and next time I swing by the component I'll take an axe to it.

const isGuest = client ? client.isGuest() : true;
const className = this.props.className;
const classes = classnames({
[className]: true,
[`${className}_guest`]: isGuest,
[`${className}_loggedIn`]: !!client,
Copy link
Collaborator

Choose a reason for hiding this comment

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

This is fine, but it does make me wonder if we should have a very high level class about logged in set on some top level component in the app? Then the welcome page and anything else can use CSS based on that one class, if it wants to, rather than sprinkling logged in classes to specific components like this. Anyway, up to you.

Copy link
Member Author

Choose a reason for hiding this comment

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

I'm fairly uncomfortable with the amount of indirection already here (it's not obviously clear that these classes are available). Putting them higher feels like a recipe for subtle and nasty bugs.

@turt2live turt2live merged commit 38a4031 into develop Jun 5, 2019
@turt2live turt2live deleted the travis/no-button-guest branch June 5, 2019 13:23
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
X-Release-Blocker This affects the current release cycle and must be solved for a release to happen
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants