-
Notifications
You must be signed in to change notification settings - Fork 101
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Theme loading without flickering #2233
Conversation
Signed-off-by: Timo K <toger5@hotmail.de>
Signed-off-by: Timo K <toger5@hotmail.de>
Signed-off-by: Timo K <toger5@hotmail.de>
Signed-off-by: Timo K <toger5@hotmail.de>
Signed-off-by: Timo K <toger5@hotmail.de>
Signed-off-by: Timo K <toger5@hotmail.de>
public/index.html
Outdated
@@ -13,7 +13,7 @@ | |||
</script> | |||
</head> | |||
|
|||
<body class="cpd-theme-dark"> | |||
<body class="nodisplay"> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could we rename this class to something like no-theme
so that it's more apparent that it's involved in the theme code?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what about invisible-loading-theme
(so its also clear that this class could be the reason why its not rendering anything.)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's also fine by me
Signed-off-by: Timo K <toger5@hotmail.de>
The theme did flicker because there is a default theme shown before any JS is loaded.
When the layoutEffect from the useTheme hook is reached the theme gets updated -> If its a different theme ("light", "dark") one can see a very short flicker.
This is particularly annoying in widget mode.
To work around this we only send the contentLoaded action once the theme is set.
This relies on the js sdk not sending this action automatically AND the react sdk needs to be configured with waitForIframe=false, so that it does not consider the widget to be ready once the IFrame is loaded.
Until the content_loadedaction is sent (which now is equivalent to: until EC is loaded), we will not show the widget. Instead the EW loading screen is shown.
This also saves us from the flickering: EW widget loading screen -> EC normal screen with header -> EC loading screen -> EC lobby.
This relies on:
Js-sdk PR that allows to disable sending the content loaded action right after the client is initialized but before the first react update (default behaviour of the js sdk):
matrix-org/matrix-js-sdk#4086
EW PR that sets waitForIframe=false and shows the widget loading screen until the receiving the content_loaded action:
matrix-org/matrix-react-sdk#12292
Signed-off-by: Timo K toger5@hotmail.de
The type failiours will be fixed once matrix-org/matrix-js-sdk#4086 is merged.