Skip to content

Commit

Permalink
Fix dark mode flash
Browse files Browse the repository at this point in the history
  • Loading branch information
karimi committed Sep 17, 2024
1 parent c479119 commit 57ea52e
Showing 1 changed file with 20 additions and 13 deletions.
33 changes: 20 additions & 13 deletions quasar_site/src/layouts/MainLayout.vue
Original file line number Diff line number Diff line change
Expand Up @@ -117,12 +117,15 @@ mounted() {
if (this.$route.query.plain) {
this.forScriptEditor = true;
}
let wasDark = localStorage.getItem('darkMode') || "false";
if (this.$route.query.dark == "true"){
wasDark = true;
let wasDark = localStorage.getItem('darkMode');
if (this.$route.query.dark){
if (this.$route.query.dark == "true"){
wasDark = "true";
}
else{
wasDark = "false";
}
}
console.log("wasDark", wasDark)
console.log("isActive", this.$q.dark.isActive.toString())
if (this.$q.dark.isActive.toString() != wasDark){
this.$q.dark.toggle()
}
Expand Down Expand Up @@ -178,7 +181,6 @@ methods: {
done(childNodes);
},
toggleDarkMode(){
console.log("toggling")
this.$q.dark.toggle();
localStorage.setItem('darkMode', this.$q.dark.isActive)
}
Expand Down Expand Up @@ -252,15 +254,20 @@ watch: {
else {
this.searchText = "";
}
let wasDark = false;
if (to.query.dark == "true"){
console.log("dark is setting")
wasDark = true;
let wasDark = localStorage.getItem('darkMode');
if (to.query.dark){
if (to.query.dark == "true"){
wasDark = "true";
}
else{
wasDark = "false";
}
}
if (this.$q.dark.isActive.toString() != wasDark){
console.log("toggling")
this.$q.dark.toggle()
}
console.log("toggling dark mode",wasDark,this.$q.dark.isActive.toString() )
this.$q.dark.toggle()
}
}
},
components: { SearchPage }
Expand Down

0 comments on commit 57ea52e

Please sign in to comment.