Expose room id in navigation

So rooms can be bookmarked, issue #26.
This commit is contained in:
N-Pex 2021-01-12 11:26:01 +01:00
parent 50ae081ea8
commit 6608f0c8ce
7 changed files with 24 additions and 12 deletions

View file

@ -3,6 +3,7 @@ import VueRouter from 'vue-router'
//import Home from '../components/Home.vue'
import Chat from '../components/Chat.vue'
import Login from '../components/Login.vue'
import util from '../plugins/utils'
Vue.use(VueRouter)
@ -13,7 +14,7 @@ const routes = [
component: Chat
},
{
path: '/room/',
path: '/room/:roomId',
name: 'Chat',
component: Chat
},
@ -46,10 +47,11 @@ router.beforeEach((to, from, next) => {
var authRequired = !publicPages.includes(to.path) && !to.path.startsWith('/join');
const loggedIn = localStorage.getItem('user');
if (to.path.startsWith('/room/')) {
if (to.hash && to.hash.startsWith('#')) {
if (to.name == 'Chat') {
const roomId = util.sanitizeRoomId(to.params.roomId);
router.app.$matrix.setCurrentRoomId(roomId);
if (roomId && roomId.startsWith('#')) {
//Invite to public room
router.app.$matrix.setCurrentRoomId(to.hash);
authRequired = false;
}
}