From 5854b4cc57ce0e1af72c8469e97d0d3559b7d536 Mon Sep 17 00:00:00 2001 From: AskaEth Date: Sat, 25 Jul 2026 21:22:34 +0800 Subject: [PATCH] fix: add debounce to theme toggle to prevent flash-back --- static/js/utils/theme.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/static/js/utils/theme.js b/static/js/utils/theme.js index 5be5c7c..b2cc9d1 100644 --- a/static/js/utils/theme.js +++ b/static/js/utils/theme.js @@ -1,5 +1,6 @@ const Theme = { _current: 'dark', + _toggling: false, init() { this._current = localStorage.getItem('turbosu-theme') || 'dark'; @@ -7,8 +8,11 @@ const Theme = { }, toggle() { + if (this._toggling) return; + this._toggling = true; this._current = this._current === 'dark' ? 'light' : 'dark'; this.apply(); + setTimeout(() => { this._toggling = false; }, 200); }, apply() {