Fix notification and sound system issues with comprehensive improvements
- **Fixed duplicate sound events**: Prevent success/shutdown sounds from playing multiple times during timeline switches and app quit - **Added event coordination patterns**: Implemented flags and source tracking to prevent circular UI event chains - **Completed sound event coverage**: Added missing sound methods (play_favorite, play_follow, play_unfollow, play_direct_message, play_post) and wired them to user actions - **Enhanced notification system**: Fixed desktop notifications ignoring enable/disable settings by adding missing notifications section to default config - **Improved timeline-specific sounds**: Conversations now use direct_message sound instead of generic timeline_update sound - **Added duplicate code prevention guidelines**: Comprehensive CLAUDE.md section with patterns, checklist, and testing requirements to prevent future duplicate implementations - **Sound pack compatibility**: Full support for both default pack (private_message, post_sent) and Doom pack (direct_message, post) naming conventions with intelligent fallback All sound events now properly trigger on user actions: boost/favorite posts, follow/unfollow users, notifications, timeline updates, and lifecycle events. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
68
CLAUDE.md
68
CLAUDE.md
@ -7,6 +7,74 @@ Bifrost is a fully accessible fediverse client built with PySide6, designed spec
|
||||
- Check for any changes in git project before doing anything else. Make sure the latest changes have been pulled
|
||||
- See what has changed, use git commands and examine the code to make sure you are up to date with the latest code
|
||||
|
||||
## Duplicate Code Prevention Guidelines
|
||||
|
||||
### Critical Areas Requiring Attention
|
||||
1. **Sound/Audio Events**: Never add multiple paths that trigger the same sound event
|
||||
2. **UI Event Handlers**: Avoid circular event chains (A triggers B which triggers A)
|
||||
3. **Timeline Operations**: Coordinate refresh calls and state changes to prevent conflicts
|
||||
4. **Lifecycle Events**: Ensure shutdown, close, and quit events don't overlap
|
||||
|
||||
### Required Patterns for Event-Heavy Operations
|
||||
|
||||
#### Event Coordination Pattern
|
||||
```python
|
||||
def operation_method(self):
|
||||
if hasattr(self, '_operation_in_progress') and self._operation_in_progress:
|
||||
return
|
||||
self._operation_in_progress = True
|
||||
try:
|
||||
# perform operation
|
||||
self.sound_manager.play_success()
|
||||
finally:
|
||||
# Reset flag after brief delay to prevent rapid-fire calls
|
||||
QTimer.singleShot(100, lambda: setattr(self, '_operation_in_progress', False))
|
||||
```
|
||||
|
||||
#### Event Source Tracking Pattern
|
||||
```python
|
||||
def ui_triggered_method(self, index, from_source="unknown"):
|
||||
# Handle differently based on source: "tab_change", "keyboard", "menu"
|
||||
if from_source == "tab_change":
|
||||
# Skip certain UI updates to prevent circular calls
|
||||
pass
|
||||
```
|
||||
|
||||
#### Lifecycle Event Coordination Pattern
|
||||
```python
|
||||
def quit_application(self):
|
||||
self._shutdown_handled = True # Mark that shutdown is being handled
|
||||
self.sound_manager.play_shutdown()
|
||||
|
||||
def closeEvent(self, event):
|
||||
# Only handle if not already handled by explicit quit
|
||||
if not hasattr(self, '_shutdown_handled'):
|
||||
self.sound_manager.play_shutdown()
|
||||
```
|
||||
|
||||
### Development Review Checklist
|
||||
Before implementing any sound, notification, or UI event:
|
||||
1. **Is there already another code path that triggers this same feedback?**
|
||||
2. **Could this create an event loop (A calls B which calls A)?**
|
||||
3. **Can rapid user actions (keyboard shortcuts) trigger this multiple times?**
|
||||
4. **Does this operation need coordination with other similar operations?**
|
||||
5. **Are there multiple UI elements (menu + button + shortcut) that trigger this?**
|
||||
|
||||
### Common Patterns to Avoid
|
||||
- Multiple event handlers calling the same sound method
|
||||
- UI updates that trigger their own event handlers
|
||||
- Shutdown/close/quit events without coordination
|
||||
- Timeline refresh without checking if already refreshing
|
||||
- Direct sound calls in multiple places for the same user action
|
||||
|
||||
### Testing Requirements
|
||||
When adding event-driven features, always test:
|
||||
- Rapid keyboard shortcut usage
|
||||
- Multiple quick UI interactions
|
||||
- Combinations of keyboard shortcuts + UI clicks
|
||||
- Window closing during operations
|
||||
- Tab switching with keyboard vs mouse
|
||||
|
||||
## Documentation and Dependencies
|
||||
- **README Updates**: When adding new functionality or sound events, update README.md with detailed descriptions
|
||||
- **Requirements Management**: Check and update requirements.txt when new dependencies are added
|
||||
|
Reference in New Issue
Block a user