Skip to content

Support multiple message elements in Gmail dark theme#612

Merged
timche merged 1 commit into
mainfrom
claude/dark-theme-multiple-inboxes-1lkaz0
Jul 21, 2026
Merged

Support multiple message elements in Gmail dark theme#612
timche merged 1 commit into
mainfrom
claude/dark-theme-multiple-inboxes-1lkaz0

Conversation

@timche

@timche timche commented Jul 21, 2026

Copy link
Copy Markdown
Collaborator

Refactor the Gmail message dark theme handler to support multiple message elements simultaneously instead of tracking only a single element.

Summary

The dark theme message handler previously tracked a single message element and would revert its theme when a different element was encountered. This change updates it to maintain dark theme controllers for multiple message elements, enabling proper theming when multiple messages are visible in the DOM.

Key Changes

  • Changed from single themedElement and controller variables to a Map<HTMLElement, DarkThemeController> for tracking multiple elements
  • Updated selector from $() (single element) to $$() (multiple elements)
  • Implemented cleanup logic that reverts themes for removed elements and applies themes to new elements
  • Maintains a Set of current message elements to efficiently detect which controllers should be cleaned up

Implementation Details

  • The function now iterates through existing controllers and removes those whose elements are no longer in the DOM
  • For each current message element, it checks if a controller already exists before creating a new one, avoiding duplicate theme applications
  • The dark theme configuration remains unchanged; only the lifecycle management was refactored

https://claude.ai/code/session_01Q3HANa7VjTStHLgCT1USHa

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Q3HANa7VjTStHLgCT1USHa
@timche
timche merged commit dfe50e6 into main Jul 21, 2026
4 checks passed
@timche
timche deleted the claude/dark-theme-multiple-inboxes-1lkaz0 branch July 21, 2026 16:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants