mirror of
https://github.com/aljazceru/notedeck.git
synced 2025-12-17 08:44:20 +01:00
This commit addresses all identified issues in channel management: 1. **Fix timeline cleanup on channel removal** (channels.rs:97-123) - remove_channel() now properly unsubscribes from timeline - Prevents memory leaks from orphaned timeline subscriptions - Ensures proper cleanup when deleting channels 2. **Add bounds checking on deserialization** (storage/channels.rs:138-158) - Validates selected index after loading channels from disk - Prevents out-of-bounds panics if saved state is corrupted - Handles edge case of empty channel lists gracefully 3. **Implement channel deletion UI** (channel_sidebar.rs:19-25, 273-287) - Added DeleteChannel action to sidebar - Right-click context menu shows "Delete Channel" option - Only allows deletion if more than one channel exists - Properly cleans up timeline and saves state after deletion 4. **Implement channel editing UI** (channel_dialog.rs:5-44, channel_sidebar.rs:19-25) - Added EditChannel action and editing_index field to dialog - open_for_edit() method pre-fills dialog with existing data - Dialog title changes to "Edit Channel" in edit mode - Button changes from "Create" to "Save" when editing - Context menu shows "Edit Channel" option 5. **Add channel editing logic** (channels.rs:99-132, app.rs:476-524) - edit_channel() method updates channel data - Unsubscribes from old timeline if hashtags changed - Re-subscribes to new timeline with updated hashtags - Properly updates router with new timeline kind 6. **Auto-select newly created channels** (channels.rs:93-97) - add_channel() now automatically selects the new channel - Improves UX by immediately showing the channel user just created - Eliminates confusion about which channel is active 7. **Optimize storage saves** (app.rs:1290-1296) - Removed automatic save on every channel selection - Channel selection state will be saved on app close instead - Prevents excessive disk I/O from rapid channel switching - Saves only on create, edit, and delete operations All changes tested and build succeeds without errors.