mirror of
				https://github.com/TeamPiped/Piped.git
				synced 2025-11-04 06:31:55 +00:00 
			
		
		
		
	fix stacked listeners
This commit is contained in:
		
							
								
								
									
										13
									
								
								src/main.js
									
									
									
									
									
								
							
							
						
						
									
										13
									
								
								src/main.js
									
									
									
									
									
								
							@@ -64,6 +64,7 @@ import "@unocss/reset/tailwind.css";
 | 
				
			|||||||
import "uno.css";
 | 
					import "uno.css";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
const timeAgo = new TimeAgo("en-US");
 | 
					const timeAgo = new TimeAgo("en-US");
 | 
				
			||||||
 | 
					const darkModePreference = window.matchMedia("(prefers-color-scheme: dark)");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
import("./registerServiceWorker");
 | 
					import("./registerServiceWorker");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -240,13 +241,11 @@ const mixin = {
 | 
				
			|||||||
    computed: {
 | 
					    computed: {
 | 
				
			||||||
        theme() {
 | 
					        theme() {
 | 
				
			||||||
            this.refreshTheme; // forces Vue to recompute the value when the var gets changed
 | 
					            this.refreshTheme; // forces Vue to recompute the value when the var gets changed
 | 
				
			||||||
            if (this.getPreferenceString("theme", "dark") == "auto") {
 | 
					            let themePref = this.getPreferenceString("theme", "dark");
 | 
				
			||||||
                const darkModePreference = window.matchMedia("(prefers-color-scheme: dark)");
 | 
					            if (themePref == "auto") {
 | 
				
			||||||
                // Forces the app to recompute the theme class
 | 
					 | 
				
			||||||
                darkModePreference.addEventListener("change", () => this.refreshTheme++);
 | 
					 | 
				
			||||||
                return darkModePreference.matches ? "dark" : "light";
 | 
					                return darkModePreference.matches ? "dark" : "light";
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
            return this.getPreferenceString("theme", "dark");
 | 
					            return themePref;
 | 
				
			||||||
        },
 | 
					        },
 | 
				
			||||||
        authenticated(_this) {
 | 
					        authenticated(_this) {
 | 
				
			||||||
            return _this.getAuthToken() !== undefined;
 | 
					            return _this.getAuthToken() !== undefined;
 | 
				
			||||||
@@ -279,6 +278,10 @@ const mixin = {
 | 
				
			|||||||
            refreshTheme: 0,
 | 
					            refreshTheme: 0,
 | 
				
			||||||
        };
 | 
					        };
 | 
				
			||||||
    },
 | 
					    },
 | 
				
			||||||
 | 
					    mounted() {
 | 
				
			||||||
 | 
					        // Forces the app to recompute the theme class
 | 
				
			||||||
 | 
					        darkModePreference.addEventListener("change", () => this.refreshTheme++);
 | 
				
			||||||
 | 
					    },
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
const i18n = createI18n({
 | 
					const i18n = createI18n({
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user