Refactor: Extract rail tiles and space actions into separate files#108
Conversation
accord_home_message_row.dart (1200 lines) and accord_home_rail.dart (1124 lines) were the only first-party source files over 1000 lines. Break them up along class boundaries into new part files of the same accord_home.dart library, with no code changes: - accord_home_mute_button.dart: _MuteButton + _NotifAction (channel header notification toggle, unrelated to message rows) - accord_home_reactions.dart: _ReactButton, _ReactionPill, _ReactorsDialog - accord_home_space_actions.dart: _serverActionEntries, _copyServerLink, _leaveSpace, _leaveAndDeleteSpace - accord_home_rail_tiles.dart: _DraggableSpace, _FolderTile, _SpaceIcon, _DirectMessagesButton, _AddServerButton, _HiddenServersButton https://claude.ai/code/session_01G5zyWf2nQTv7wJpVkhEvAx
- accord_home_rail_tiles.dart: TextEditingController in _promptName was never disposed; chain .whenComplete(controller.dispose) so it's freed when the dialog closes regardless of cancel vs. save. - accord_home_space_actions.dart: _leaveSpace docstring claimed "leave-and-delete lives in Privacy & Data" — inaccurate since _leaveAndDeleteSpace is also surfaced directly from the rail menu. Removed the false claim. - test/features/settings/accord_settings_test.dart: add SpaceFolder round-trip, copyWith, and fromJson-defaults tests, plus AccordSettings.spaceOrder / spaceFolders persistence tests. The SpaceFolder model drives the extracted accord_home_rail_tiles.dart and accord_home_space_actions.dart part files and previously had no test coverage. https://claude.ai/code/session_01GWsozNipjSqDPcW5goaAb7
Code Review — PR #108Overall this is a clean, well-executed refactor. All extracted code uses 🔴 High —
|
The reaction & mute work landed both in accord_home_message_row.dart and in the dedicated part files (accord_home_mute_button.dart / accord_home_reactions.dart) that refactor #108 had already extracted, producing duplicate_definition compile errors. Remove the stale copies from accord_home_message_row.dart and port the two bug fixes into the canonical part files: - mute-state read: parse channel_id out of the listMutes objects instead of stringifying the whole map (was always falsey, so muted state never showed). - custom-emoji reactions: resolve the image URL from the space emoji catalog (image_url with space segment + real extension) rather than the bare AccordCDN.emoji(id) path, which 404'd. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
…111) * feat(messaging): emoji reactions with custom-emoji image resolution Adds reaction pills, a reaction picker, and a reactors dialog to message rows, and resolves custom-emoji reaction images from the space's emoji catalog (falling back to the bare CDN path) so animated/custom emoji render correctly. Also fixes channel-mute detection to read channel_id from the structured mutes list. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com> * fix(messaging): resolve duplicate _MuteButton/_ReactionPill definitions The reaction & mute work landed both in accord_home_message_row.dart and in the dedicated part files (accord_home_mute_button.dart / accord_home_reactions.dart) that refactor #108 had already extracted, producing duplicate_definition compile errors. Remove the stale copies from accord_home_message_row.dart and port the two bug fixes into the canonical part files: - mute-state read: parse channel_id out of the listMutes objects instead of stringifying the whole map (was always falsey, so muted state never showed). - custom-emoji reactions: resolve the image URL from the space emoji catalog (image_url with space segment + real extension) rather than the bare AccordCDN.emoji(id) path, which 404'd. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com> * fix(messaging): remove duplicate reaction/mute widget definitions and add tests The PR added _ReactButton, _ReactionPill, _ReactorsDialog, _MuteButton, and _NotifAction to accord_home_message_row.dart, but identical/older definitions of the first three already existed in accord_home_reactions.dart (same `part of` library → compile-time duplicate class error). - Move all reaction/notification widgets to accord_home_reactions.dart (their natural home); remove duplicates from accord_home_message_row.dart. - Update _ReactionPill in accord_home_reactions.dart to use the new `imageUrl` parameter (was `cdnUrl`) matching the improved PR design. - Extract _ReactorTile to eliminate the double accordAvatarUrl() call per user. - Fix wrong docstring on _MuteButton (previously read "Opens the full emoji picker to add a reaction to the message"). - Remove redundant `final emojiUrl = imageUrl;` alias in _ReactionPill.build(). - Wrap long _reactionEmojiUrl line to stay within 80 cols. - Add test/features/messaging/emoji_utils_test.dart covering parseEmojiToken, resolveEmojiGlyph, and the mute-list channel_id extraction logic. https://claude.ai/code/session_01MVhELbGUNvFDcBX2MkRs8r * fix(messaging): remove _MuteButton/_NotifAction dupes from reactions part The mute-button widgets were accidentally appended to accord_home_reactions.dart, duplicating the definitions already in accord_home_mute_button.dart and failing analyze with duplicate_definition. Keep only the canonical copies. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.7 <noreply@anthropic.com>
Summary
Refactored the
accord_home_rail.dartfile by extracting large helper classes and functions into dedicated, focused modules. This improves code organization, maintainability, and follows the single-responsibility principle without changing any functionality.Changes
accord_home_rail_tiles.dart(new): Extracted_DraggableSpace,_DraggableSpaceState,_FolderTile, and_SpaceIconwidget classes that handle the visual representation and interaction of space tiles and folders in the rail.accord_home_space_actions.dart(new): Extracted space action functions (_serverActionEntries,_copyServerLink,_leaveSpace,_leaveAndDeleteSpace) that handle muting, inviting, settings, and leaving spaces. These are shared between the standalone-space menu and folder-member menu.accord_home_reactions.dart(new): Extracted reaction-related widgets (_ReactButton,_ReactionPill,_ReactorsDialog) fromaccord_home_message_row.dartfor cleaner separation of concerns.accord_home_mute_button.dart(new): Extracted the_MuteButtonwidget and_NotifActionenum fromaccord_home_message_row.dartto isolate channel notification management.accord_home.dart: Updated to include newpartdirectives for the extracted files, maintaining the part-file pattern used throughout the codebase.accord_home_rail.dart: Removed ~750 lines of extracted code; file now focuses on the main_SpaceRailwidget and rail layout logic.accord_home_message_row.dart: Removed ~400 lines of extracted reaction and mute button code; file now focuses on message rendering and actions.Implementation Details
part of 'accord_home.dart'to maintain access to the same import scope and private members.https://claude.ai/code/session_01G5zyWf2nQTv7wJpVkhEvAx