Cleanup storage code

This allows us to use either session or local storage, for issue #120.
This commit is contained in:
N-Pex 2021-05-10 11:13:22 +02:00
parent af04dd39f7
commit 0ac3cefb03
9 changed files with 144 additions and 89 deletions

View file

@ -37,7 +37,7 @@ export default {
methods: {
logout() {
//TODO - For guest accounts, show warning about not being able to rejoin.
this.$store.dispatch("auth/logout");
this.$store.dispatch("logout");
this.$nextTick(() => {
this.$navigation.push({path: "/login"}, -1);
})

View file

@ -60,6 +60,7 @@
<div class="ml-2">{{ data.item.name }}</div>
</template>
</v-select>
<v-switch v-model="sharedComputer" label="Using a shared computer" />
</v-col>
</v-row>
<v-row v-else>
@ -200,6 +201,14 @@ export default {
.substring(0, 1)
.toUpperCase();
},
sharedComputer: {
get: function () {
return !this.$store.state.useLocalStorage;
},
set: function (sharedComputer) {
this.$store.commit('setUseLocalStorage', !sharedComputer);
},
}
},
watch: {
roomId: {
@ -264,7 +273,7 @@ export default {
if (this.$matrix.ready) {
return Promise.resolve(this.$matrix.currentUser);
}
return this.$store.dispatch("auth/login", this.currentUser || this.guestUser);
return this.$store.dispatch("login", this.currentUser || this.guestUser);
},
getRoomInfo() {

View file

@ -120,7 +120,7 @@ export default {
user.normalize();
this.loading = true;
this.$store.dispatch("auth/login", user).then(
this.$store.dispatch("login", user).then(
() => {
if (this.$matrix.currentRoomId) {
this.$navigation.push({name: "Chat", params: { roomId: util.sanitizeRoomId(this.$matrix.currentRoomId) }}, -1);

View file

@ -146,7 +146,7 @@ export default {
methods: {
logout() {
//TODO - For guest accounts, show warning about not being able to rejoin.
this.$store.dispatch("auth/logout");
this.$store.dispatch("logout");
this.$nextTick(() => {
this.$navigation.push({path: "/login"}, -1);
})