Do Not Disturb (DND)
Relevant source files
The following files were used as context for generating this wiki page:
The Do Not Disturb (DND) system in Messenger Unleashed is a notification management framework designed to suppress native desktop alerts and manage user availability. It operates by intercepting Electron's notification events and checking state variables stored in the application's persistent configuration. The system extends beyond simple manual toggling to include Quiet Hours, a scheduling engine that automates the DND state based on time-of-day constraints.
Sources: src/main/index.ts:1017-1025, CLAUDE.md:54-58, README.md:12-13
Architecture and Data Flow
The DND system is distributed across the Main process and the Preload script. The Preload script overrides the standard browser window.Notification constructor, redirecting notification requests to the Main process via Inter-Process Communication (IPC). The Main process then evaluates the doNotDisturb boolean from the electron-store before deciding whether to instantiate a native Notification object.
The following diagram illustrates the lifecycle of a notification when DND is active:
Quiet Hours Scheduling
Quiet Hours provides automated management of the DND state. It uses a background monitor that executes once per minute to compare the current system time against user-defined start and end boundaries.
Logic and State Management
The scheduling logic supports overnight ranges (e.g., 10:00 PM to 7:00 AM) by checking if the current time is greater than the start time OR less than the end time. When the current time enters the range, the system sets doNotDisturb to true and flags quietHoursApplied to ensure the state can be reverted once the time window closes.
Components and Configuration
The DND system relies on several configuration keys managed via electron-store. These settings are accessible through the "Unleashed" application menu or the "Power Tools" tab in the settings modal.
Key Configuration Elements
| Setting | Type | Default | Description |
|---|---|---|---|
doNotDisturb | boolean | false | Global toggle to suppress all native notifications. |
quietHoursEnabled | boolean | false | Enables the automated scheduling monitor. |
quietHoursStart | string | 22:00 | Start time for notification suppression (24h format). |
quietHoursEnd | string | 07:00 | End time for notification suppression (24h format). |
quietHoursApplied | boolean | false | Internal flag indicating DND was enabled by the scheduler. |
Sources: src/main/index.ts:1017-1025, src/preload/settings-modal.ts:474-486, src/main/index.ts:654-660
Key Functions
toggleDoNotDisturb(): Reverses the current global DND state and clears scheduler flags. Sources: src/main/index.ts:599-604applyQuietHours(): The core logic handler that evaluates time ranges and updates the store. Sources: src/main/index.ts:654-686parseTimeInput(value): Normalizes user input strings (e.g., "10 PM", "22:00") into total minutes from midnight. Sources: src/main/index.ts:606-631isWithinQuietHours(...): Utility function performing the mathematical comparison of time ranges. Sources: src/main/utils.ts:98-115
Integration with UI
The DND state is reflected in several parts of the application:
- Application Menu: A checkbox under
Unleashed > Power Tools > Do Not Disturbshows the current status. - Tray Icon: On macOS, unread badges are managed alongside DND logic, though the unread count is preserved internally even if alerts are suppressed.
- Settings Modal: The "Power Tools" section provides a dedicated interface for enabling Quiet Hours and editing the schedule via
openInputDialog.
Sources: src/main/index.ts:1017-1050, src/preload/settings-modal.ts:474-486, src/main/index.ts:748-751
Conclusion
The Do Not Disturb system provides a robust mechanism for managing user focus within the Messenger Unleashed environment. By combining manual overrides, scheduled Quiet Hours, and a secure IPC-based notification bridge, it ensures that desktop interruptions are strictly controlled according to user preferences while maintaining persistent state across application restarts.