From da1424f97e209846cdcda1f1577ccd0768bae922 Mon Sep 17 00:00:00 2001 From: N-Pex Date: Fri, 13 Oct 2023 09:55:02 +0200 Subject: [PATCH] Wait until config is loaded before using values --- src/router/index.js | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/src/router/index.js b/src/router/index.js index 0ccdae6..0e4a0a8 100644 --- a/src/router/index.js +++ b/src/router/index.js @@ -129,12 +129,16 @@ router.beforeEach((to, from, next) => { let roomId = util.sanitizeUserId(to.params.userId); if (roomId && !roomId.startsWith("@")) { // Not a full username. Assume local name on this server. - const user = new User(router.app.$config.defaultServer, roomId, ""); - user.normalize(); - roomId = "@" + roomId + ":" + User.serverDomain(user.home_server); + return router.app.$config.promise.then((config) => { + const user = new User(config.defaultServer, roomId, ""); + user.normalize(); + roomId = "@" + roomId + ":" + User.serverDomain(user.home_server); + router.app.$matrix.setCurrentRoomId(roomId); + }).catch(err => console.error(err)).finally(() => next()); + } else { + router.app.$matrix.setCurrentRoomId(roomId); + authRequired = false; } - router.app.$matrix.setCurrentRoomId(roomId); - authRequired = false; } } else if (to.name == 'Invite') { if (to.params.roomId) {