Don't set avatar and display name if they haven't changed.

Related to issue #40.
This commit is contained in:
N-Pex 2021-01-29 21:41:43 +01:00
parent 8555436bc7
commit bdd6977728
7 changed files with 94 additions and 33 deletions

View file

@ -25,6 +25,8 @@ export default {
matrixClient: null,
matrixClientReady: false,
rooms: [],
userDisplayName: null,
userAvatar: null,
currentRoom: null,
}
},
@ -149,6 +151,15 @@ export default {
this.reloadRooms();
this.matrixClientReady = true;
this.matrixClient.emit('Matrix.initialized', this.matrixClient);
this.matrixClient.getProfileInfo(this.currentUserId)
.then(info => {
console.log("Got user profile: " + JSON.stringify(info));
this.userDisplayName = info.displayname;
this.userAvatar = info.avatar_url;
})
.catch(err => {
console.log("Failed to get user profile: ", err);
})
},
async getMatrixClient(user) {
@ -266,6 +277,7 @@ export default {
},
onRoom(ignoredroom) {
console.log("Got room: " + ignoredroom);
this.reloadRooms();
},
@ -300,8 +312,9 @@ export default {
Vue.set(room, "avatar", room.getAvatarUrl(this.matrixClient.getHomeserverUrl(), 80, 80, "scale", true));
}
});
console.log("Reload rooms", updatedRooms);
Vue.set(this, "rooms", updatedRooms);
const currentRoom = this.getRoom(this.currentRoomId);
const currentRoom = this.getRoom(this.$store.state.currentRoomId);
if (this.currentRoom != currentRoom) {
this.currentRoom = currentRoom;
}

View file

@ -13,13 +13,13 @@ export default {
})
router.beforeEach((to, from, next) => {
if (this.nextRoutes) {
console.log("Nav: next routes set, going:", this.routes, this.nextRoutes);
this.routes = this.nextRoutes;
this.nextRoutes = null;
if (this.routes.length > 0) {
console.log("Redirecting to", this.routes.lastItem());
next(this.routes.lastItem());
if (nextRoutes) {
console.log("Nav: next routes set, going:", routes, nextRoutes);
routes = nextRoutes;
nextRoutes = null;
if (routes.length > 0) {
console.log("Redirecting to", routes[routes.length - 1]);
next(routes[routes.length - 1]);
return;
}
}
@ -35,22 +35,28 @@ export default {
mode = 1;
}
if (mode == -1) {
const i = routes.length - 1;
nextRoutes = [route];
if (i > 0) {
router.go(-i);
} else {
router.replace(route).catch((ignoredErr) => {});
}
} else if (mode == 0) {
// Replace
nextRoutes = [...routes];
nextRoutes.pop();
nextRoutes.push(route);
router.replace(route).catch((ignoredErr) => {});
} else {
nextRoutes = [...routes];
nextRoutes.push(route);
}
const index = nextRoutes.length - routes.length;
const targetIndex = nextRoutes.length - 1;
console.log("Nav - index " + index + " Target " + targetIndex);
if (index < 0) {
console.log("Nav - go " + index);
router.go(index);
} else if (index == 0) {
console.log("Nav - replace");
router.replace(route).catch((ignoredErr) => {});
} else {
console.log("Nav - push");
router.push(route).catch((ignoredErr) => {});
}
},
@ -63,8 +69,7 @@ export default {
},
pop() {
nextRoutes = [...routes];
nextRoutes.pop();
routes.pop();
router.go(-1);
}
}