feat: enable hide clock functionality on mobile devices#175
Conversation
📝 WalkthroughWalkthroughThis PR makes targeted changes across clock visibility, shortcut styling, and theme handling: refactoring clock visibility to always use persisted state instead of media-query conditions, fixing a CSS class name typo in shortcuts SVG markup, removing inline style mutations for accent colors in dark theme application, and extending dark-mode CSS filters to additional UI elements. Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~22 minutes Possibly related PRs
Suggested labels
Suggested reviewers
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
Hi, I’ve implemented a fix for this issue. Please review it. Thanks! |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
scripts/clock.js (1)
70-70: Resize handler may cause redundant clock re-initializations.
handleClockVisibilityis called on every resize event. When the clock is visible (!isClockHidden), this callsinitializeClock()repeatedly during window resizing. SinceinitializeClock()clears and recreates intervals, this could cause flickering or unnecessary overhead during resize operations.Consider debouncing the resize handler or checking if the state actually changed before re-applying:
♻️ Proposed fix - debounce or guard the resize handler
+let lastClockHiddenState = null; + +function handleClockVisibility() { + const isClockHidden = localStorage.getItem("hideClockVisible") === "true"; + + // Skip if state hasn't changed (for resize events) + if (lastClockHiddenState === isClockHidden) return; + lastClockHiddenState = isClockHidden; + + hideClockCheckbox.checked = isClockHidden; // ... rest of functionAlternatively, consider if the resize listener is even necessary now that the logic is screen-size-independent.
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@scripts/clock.js` at line 70, handleClockVisibility is being invoked on every resize and ends up calling initializeClock repeatedly while the clock is visible (isClockHidden === false), which recreates intervals and causes flicker/overhead; modify the resize listener so it either debounces calls (e.g., wrap handleClockVisibility in a short debounce) or add a guard inside handleClockVisibility to compare the previous visibility state before calling initializeClock/clear intervals (use the existing isClockHidden or a cachedPrevVisibility variable) and only re-initialize when the visibility actually changes; update the window.addEventListener("resize", ...) hookup to use the debounced function or leave the guarded handler as the listener.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In `@scripts/clock.js`:
- Line 70: handleClockVisibility is being invoked on every resize and ends up
calling initializeClock repeatedly while the clock is visible (isClockHidden ===
false), which recreates intervals and causes flicker/overhead; modify the resize
listener so it either debounces calls (e.g., wrap handleClockVisibility in a
short debounce) or add a guard inside handleClockVisibility to compare the
previous visibility state before calling initializeClock/clear intervals (use
the existing isClockHidden or a cachedPrevVisibility variable) and only
re-initialize when the visibility actually changes; update the
window.addEventListener("resize", ...) hookup to use the debounced function or
leave the guarded handler as the listener.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 77a7d1c1-8a09-4fbe-a779-0b436246072e
📒 Files selected for processing (4)
scripts/clock.jsscripts/shortcuts.jsscripts/theme.jsstyle.css
💤 Files with no reviewable changes (1)
- scripts/theme.js
Feature: Hide Clock on Mobile
Problem
The "Hide Clock" option was not available or functional on mobile devices due to CSS restrictions and logic bypass.
Solution
Changes
Testing
Fixes #132
Screenshots: Not included, but the functionality has been tested on both desktop and mobile screen sizes.
Hide Clock Functionality on Mobile Devices
Overview
Enables the "Hide Clock" toggle option on mobile devices by removing previous CSS restrictions and refactoring the clock visibility logic to work consistently across all screen sizes. Settings persist using localStorage. Fixes #132.
Changes
Clock Visibility Refactoring (clock.js)
handleClockVisibility()to remove thematchMedia("(max-width: 500px)")conditional that previously blocked mobile devices from accessing the hide clock featurelocalStorage["hideClockVisible"]changeevent listener to be registered at the top level (outside conditional flow), ensuring consistent behavior across all screen sizesCSS Updates (style.css)
.toggleTextsCont .ttcont:has(#hideClock)on small screens@mediablock for small screensfilter: invert(1) hue-rotate(180deg)selectors to apply to additional UI icon/container elements (shortcut logo container, Google apps dot icons, bookmark/todo/search icons, AI/mic/t icons) in addition to existing#darkThemeand.favicontargetsBug Fixes
shorcutDarkColortoshortcutDarkColoracross YouTube, Gmail, Telegram, WhatsApp, Twitter, and Discord preset entries.black-theme .shorcutDarkColorto.black-theme .shortcutDarkColorTheme Logic Simplification (theme.js)
.accentColorinline fill style manipulation fromresetDarkTheme().accentColorinline fill style application fromapplySelectedTheme()during dark-mode theme applicationTesting
Verified toggle functionality and state persistence on both desktop and mobile screen sizes.