Skip to content

Commit

Permalink
Merge pull request #69 from ogs-at-usi/fix/persistent_theme
Browse files Browse the repository at this point in the history
Persistent themes
  • Loading branch information
micheledallerive authored Dec 12, 2022
2 parents f34af3d + d26cf16 commit a8ba796
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 2 deletions.
5 changes: 3 additions & 2 deletions client/src/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,9 @@ export default {
this.$vuetify.theme.themes.light = themes[theme];
},
},
created() {
this.setTheme('blue');
async created() {
await this.$store.restored;
this.setTheme(this.$store.getters.theme || 'blue');
},
};
</script>
Expand Down
1 change: 1 addition & 0 deletions client/src/components/AppSettings.vue
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ export default {
methods: {
setTheme(theme) {
this.$vuetify.theme.themes.light = themesObject[theme];
this.$store.commit('setTheme', { theme });
},
},
};
Expand Down
6 changes: 6 additions & 0 deletions client/src/store/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ const vuexLocal = new VuexPersistence({
// Only save the state of the module 'auth'
isLoggedIn: state.isLoggedIn,
user: state.user,
theme: state.theme,
}),
asyncStorage: true,
});
Expand All @@ -22,13 +23,15 @@ export default new Vuex.Store({
user: null,
socket: null,
activeChat: null,
theme: null,
},
getters: {
isLoggedIn: (state) => state.isLoggedIn,
user: (state) => state.user,
socket: (state) => state.socket,
activeChat: (state) => state.activeChat,
isMobile: () => window.innerWidth < 600,
theme: (state) => state.theme,
},
mutations: {
login(state, { user }) {
Expand All @@ -48,6 +51,9 @@ export default new Vuex.Store({
setActiveChat(state, { chat }) {
state.activeChat = chat;
},
setTheme(state, { theme }) {
state.theme = theme;
},
},
actions: {
login({ commit }, { username, password }) {
Expand Down

0 comments on commit a8ba796

Please sign in to comment.