Improve navigation
This commit is contained in:
parent
d5945d675e
commit
6a22d99c17
12 changed files with 198 additions and 72 deletions
|
|
@ -125,7 +125,6 @@ export default {
|
|||
initClient() {
|
||||
this.reloadRooms();
|
||||
this.matrixClientReady = true;
|
||||
this.currentRoom = null;
|
||||
this.currentRoom = this.getRoom(this.currentRoomId);
|
||||
this.matrixClient.emit('Matrix.initialized', this.matrixClient);
|
||||
},
|
||||
|
|
@ -250,15 +249,10 @@ export default {
|
|||
this.rooms.forEach(room => {
|
||||
Vue.set(room, "avatar", room.getAvatarUrl(this.matrixClient.getHomeserverUrl(), 80, 80, "scale", true));
|
||||
});
|
||||
},
|
||||
|
||||
setCurrentRoom(room) {
|
||||
// If we don't know about this room yet (e.g. we just joined)
|
||||
// add it to our list.
|
||||
if (!this.getRoom(room.roomId)) {
|
||||
this.rooms.push(room);
|
||||
if (this.currentRoom == null && this.currentRoomId) {
|
||||
// Try to set it!
|
||||
this.currentRoom = this.getRoom(this.currentRoomId);
|
||||
}
|
||||
this.setCurrentRoomId(room.roomId);
|
||||
},
|
||||
|
||||
setCurrentRoomId(roomId) {
|
||||
|
|
@ -278,7 +272,7 @@ export default {
|
|||
if (!room && this.matrixClient) {
|
||||
room = this.matrixClient.getRoom(roomId);
|
||||
}
|
||||
return room;
|
||||
return room || null;
|
||||
},
|
||||
|
||||
on(event, handler) {
|
||||
|
|
|
|||
|
|
@ -3,12 +3,6 @@ export default {
|
|||
var routes = [];
|
||||
var zeroIndex = undefined;
|
||||
|
||||
// window.addEventListener('popstate', () => {
|
||||
// if (routes.length > 1) {
|
||||
// routes.splice(routes.length - 1);
|
||||
// }
|
||||
// });
|
||||
|
||||
router.beforeResolve((to, ignoredfrom, next) => {
|
||||
if (!zeroIndex) {
|
||||
routes = [to];
|
||||
|
|
@ -32,21 +26,27 @@ export default {
|
|||
})
|
||||
|
||||
const navigationService = {
|
||||
push(route, asRoot) {
|
||||
asRoot = asRoot || false;
|
||||
//var resolved = router.resolve(route);
|
||||
//resolved.route.meta = route.meta || {};
|
||||
if (asRoot) {
|
||||
const i = routes.length - 1; // window.history.length - zeroIndex;
|
||||
/***
|
||||
* @param mode Mode of operation. -1 = push as root, 0 = replace, 1 = normal push
|
||||
*/
|
||||
push(route, mode) {
|
||||
if (mode === undefined) {
|
||||
mode = 1;
|
||||
}
|
||||
if (mode == -1) {
|
||||
const i = routes.length - 1;
|
||||
routes = [route];
|
||||
//resolved.route.meta.index = 0;
|
||||
if (i > 0) {
|
||||
router.go(-i);
|
||||
} else {
|
||||
router.replace(route).catch((ignoredErr) => {});
|
||||
}
|
||||
} else if (mode == 0) {
|
||||
// Replace
|
||||
routes.pop()
|
||||
routes.push(route);
|
||||
router.replace(route).catch((ignoredErr) => {});
|
||||
} else {
|
||||
//resolved.route.meta.index = routes.length;
|
||||
routes.push(route);
|
||||
router.push(route).catch((ignoredErr) => {});
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue