From 032a6a8355906000f918c9a88b34a2230d6c741d Mon Sep 17 00:00:00 2001 From: Cagatay Civici Date: Wed, 18 Oct 2023 00:59:30 +0300 Subject: [PATCH] Prevent unnecessary switch --- app.vue | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/app.vue b/app.vue index ad2d11159..a2f5c7296 100644 --- a/app.vue +++ b/app.vue @@ -22,11 +22,13 @@ export default { }, mounted() { this.themeChangeListener = (event) => { - this.$primevue.changeTheme(this.$appState.theme, event.theme, 'theme-link', () => { - this.$appState.theme = event.theme; - this.$appState.darkTheme = event.dark; - EventBus.emit('theme-change-complete', { theme: event.theme, dark: event.dark }); - }); + if (event.theme !== this.$appState.theme) { + this.$primevue.changeTheme(this.$appState.theme, event.theme, 'theme-link', () => { + this.$appState.theme = event.theme; + this.$appState.darkTheme = event.dark; + EventBus.emit('theme-change-complete', { theme: event.theme, dark: event.dark }); + }); + } }; EventBus.on('theme-change', this.themeChangeListener);