Set up URL routing after creating matrixchat in case onload / hashchange gets called before

This commit is contained in:
David Baker 2015-07-31 15:50:47 +01:00
parent 9f98c4e9f7
commit 69ac0bd368
1 changed files with 7 additions and 7 deletions

View File

@ -49,15 +49,8 @@ function onHashChange(ev) {
routeUrl(window.location); routeUrl(window.location);
} }
window.addEventListener('hashchange', onHashChange);
var loaded = false; var loaded = false;
window.onload = function() {
routeUrl(window.location);
loaded = true;
}
// This will be called whenever the SDK changes screens, // This will be called whenever the SDK changes screens,
// so a web page can update the URL bar appropriately. // so a web page can update the URL bar appropriately.
var onNewScreen = function(screen) { var onNewScreen = function(screen) {
@ -81,3 +74,10 @@ window.matrixChat = React.render(
<MatrixReactSdk.MatrixChat onNewScreen={onNewScreen} registrationUrl={makeRegistrationUrl()} />, <MatrixReactSdk.MatrixChat onNewScreen={onNewScreen} registrationUrl={makeRegistrationUrl()} />,
document.getElementById('matrixchat') document.getElementById('matrixchat')
); );
window.addEventListener('hashchange', onHashChange);
window.onload = function() {
routeUrl(window.location);
loaded = true;
}