Wait until config is loaded before using values

This commit is contained in:
N-Pex 2023-10-13 09:55:02 +02:00
parent b45a98eb57
commit da1424f97e

View file

@ -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) {