Add matrix service to $matrix and move room handling to that
This commit is contained in:
parent
2ca7dd3655
commit
c88931e00c
7 changed files with 239 additions and 213 deletions
21
src/App.vue
21
src/App.vue
|
|
@ -1,12 +1,12 @@
|
|||
<template>
|
||||
<v-app>
|
||||
<v-app-bar app dark>
|
||||
<v-app-bar app dark flat color="#008860">
|
||||
<v-app-bar-nav-icon @click.stop="openDrawer = !openDrawer">
|
||||
<v-icon>menu</v-icon>
|
||||
</v-app-bar-nav-icon>
|
||||
|
||||
<v-toolbar-title
|
||||
>Keanu{{ room ? " - " + room.name : "" }}</v-toolbar-title
|
||||
>Keanu{{ $matrix.currentRoom ? (" - " + $matrix.currentRoom.summary.info.title) : "" }}</v-toolbar-title
|
||||
>
|
||||
|
||||
<v-spacer></v-spacer>
|
||||
|
|
@ -39,8 +39,7 @@
|
|||
<v-navigation-drawer app v-model="openDrawer">
|
||||
<v-list nav dense>
|
||||
<RoomList
|
||||
v-if="$matrixClient != null"
|
||||
v-on:onCurrentRoomChanged="onCurrentRoomChanged"
|
||||
v-if="$matrix.ready"
|
||||
/>
|
||||
</v-list>
|
||||
</v-navigation-drawer>
|
||||
|
|
@ -54,7 +53,6 @@
|
|||
</template>
|
||||
|
||||
<script>
|
||||
import Vue from "vue";
|
||||
import RoomList from "./components/RoomList";
|
||||
|
||||
export default {
|
||||
|
|
@ -64,7 +62,6 @@ export default {
|
|||
},
|
||||
data: () => ({
|
||||
openDrawer: false,
|
||||
currentRoom: null,
|
||||
}),
|
||||
mounted() {
|
||||
this.$router.replace("/");
|
||||
|
|
@ -76,28 +73,22 @@ export default {
|
|||
logOut() {
|
||||
this.$store.dispatch("auth/logout");
|
||||
this.$router.replace("/login");
|
||||
this.$store.commit("setCurrentRoom", null);
|
||||
},
|
||||
onCurrentRoomChanged(room) {
|
||||
this.$store.commit("setCurrentRoom", room);
|
||||
},
|
||||
},
|
||||
computed: {
|
||||
currentUser() {
|
||||
return this.$store.state.auth.user;
|
||||
},
|
||||
room() {
|
||||
return this.$store.state.currentRoom;
|
||||
},
|
||||
},
|
||||
watch: {
|
||||
currentUser: {
|
||||
immediate: true,
|
||||
handler(ignorednewVal, ignoredoldVal) {
|
||||
if (this.loggedIn) {
|
||||
const self = this;
|
||||
this.$matrix.getMatrixClient(this.currentUser)
|
||||
.then((matrixClient) => {
|
||||
Vue.prototype.$matrixClient = matrixClient;
|
||||
.then(() => {
|
||||
self.$matrix.initClient();
|
||||
})
|
||||
.catch((error) => {
|
||||
console.log("Error creating client", error);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue