fix(zoom): suppress toast during browser initialization
- commit
- d2baffaee440ec7562962bf159ae102eb2c12beb
- author
- bnema · · 2025-11-29 10:02 UTC
- parent
- 227825f
- signature
- GPG Unverified
2B82207D370127A0The key is unknown
1 file · +6 -2
M internal/app/control/zoom.go +6 -2
| @@ -17,6 +17,7 @@ type ZoomController struct { | |||
| 17 | 17 | programmaticTimer *time.Timer | |
| 18 | 18 | browserService *services.BrowserService | |
| 19 | 19 | webView *webkit.WebView | |
| 20 | + | initializing bool // true until first load completes, suppresses toasts | |
| 20 | 21 | } | |
| 21 | 22 | ||
| 22 | 23 | // WebViewInterface defines the interface for WebView zoom operations | |
| @@ -35,6 +36,7 @@ func NewZoomController(browserService *services.BrowserService, webView *webkit. | |||
| 35 | 36 | currentURL: "dumb://homepage", | |
| 36 | 37 | browserService: browserService, | |
| 37 | 38 | webView: webView, | |
| 39 | + | initializing: true, | |
| 38 | 40 | } | |
| 39 | 41 | } | |
| 40 | 42 | ||
| @@ -56,6 +58,8 @@ func (z *ZoomController) handleLoadCommitted(url string) { | |||
| 56 | 58 | if url == "" { | |
| 57 | 59 | return | |
| 58 | 60 | } | |
| 61 | + | // First load complete, allow toasts from now on | |
| 62 | + | z.initializing = false | |
| 59 | 63 | currentDomain := services.ZoomKeyForLog(url) | |
| 60 | 64 | z.loadZoomLevelAsync(url, currentDomain, false) | |
| 61 | 65 | } | |
| @@ -77,8 +81,8 @@ func (z *ZoomController) handleZoomChange(level float64) { | |||
| 77 | 81 | log.Printf("[zoom] saved %.2f for %s", level, key) | |
| 78 | 82 | }(url, level) | |
| 79 | 83 | ||
| 80 | - | // Only show toast for user-initiated zoom changes, not programmatic ones | |
| 81 | - | if !z.programmaticChange { | |
| 84 | + | // Only show toast for user-initiated zoom changes, not during init or programmatic changes | |
| 85 | + | if !z.programmaticChange && !z.initializing { | |
| 82 | 86 | z.showZoomToast(level) | |
| 83 | 87 | } | |
| 84 | 88 | } | |
| @@ -17,6 +17,7 @@ type ZoomController struct { | |||||
| 17 | programmaticTimer *time.Timer | 17 | programmaticTimer *time.Timer | ||
| 18 | browserService *services.BrowserService | 18 | browserService *services.BrowserService | ||
| 19 | webView *webkit.WebView | 19 | webView *webkit.WebView | ||
| 20 | + | initializing bool // true until first load completes, suppresses toasts | |||
| 20 | } | 21 | } | ||
| 21 | 22 | ||||
| 22 | // WebViewInterface defines the interface for WebView zoom operations | 23 | // WebViewInterface defines the interface for WebView zoom operations | ||
| @@ -35,6 +36,7 @@ func NewZoomController(browserService *services.BrowserService, webView *webkit. | |||||
| 35 | currentURL: "dumb://homepage", | 36 | currentURL: "dumb://homepage", | ||
| 36 | browserService: browserService, | 37 | browserService: browserService, | ||
| 37 | webView: webView, | 38 | webView: webView, | ||
| 39 | + | initializing: true, | |||
| 38 | } | 40 | } | ||
| 39 | } | 41 | } | ||
| 40 | 42 | ||||
| @@ -56,6 +58,8 @@ func (z *ZoomController) handleLoadCommitted(url string) { | |||||
| 56 | if url == "" { | 58 | if url == "" { | ||
| 57 | return | 59 | return | ||
| 58 | } | 60 | } | ||
| 61 | + | // First load complete, allow toasts from now on | |||
| 62 | + | z.initializing = false | |||
| 59 | currentDomain := services.ZoomKeyForLog(url) | 63 | currentDomain := services.ZoomKeyForLog(url) | ||
| 60 | z.loadZoomLevelAsync(url, currentDomain, false) | 64 | z.loadZoomLevelAsync(url, currentDomain, false) | ||
| 61 | } | 65 | } | ||
| @@ -77,8 +81,8 @@ func (z *ZoomController) handleZoomChange(level float64) { | |||||
| 77 | log.Printf("[zoom] saved %.2f for %s", level, key) | 81 | log.Printf("[zoom] saved %.2f for %s", level, key) | ||
| 78 | }(url, level) | 82 | }(url, level) | ||
| 79 | 83 | ||||
| 80 | - | // Only show toast for user-initiated zoom changes, not programmatic ones | 84 | + | // Only show toast for user-initiated zoom changes, not during init or programmatic changes |
| 81 | - | if !z.programmaticChange { | 85 | + | if !z.programmaticChange && !z.initializing { |
| 82 | z.showZoomToast(level) | 86 | z.showZoomToast(level) | ||
| 83 | } | 87 | } | ||
| 84 | } | 88 | } | ||