refactor: DRY sweep — shared helpers & components (net -116 LOC)#144
Conversation
Code Review — findings & fixesAll fixes are in commit 🔴 High — Stale client-access pattern (3 files)The PR imported
Fix: Replaced each with 🟡 Medium — Missing tests for new shared componentsNo tests existed for the six new/modified shared units introduced by this PR. Fix: Added the following test files (commit
⚪ Low / noted (no change needed)
Scope correctly limited: The three permission-block sites in Generated by Claude Code |
…ambdas Add watch/read getters for userId, cdnUrl and isAdmin to client_access.dart alongside the existing accordClient getter, and replace the copy-pasted accordAuthProvider.select lambdas across spaces/voice/member/messaging. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
… sites Replace the copy-pasted `result.error?.toString() ?? 'Failed …'` idiom with a RestResult.errorOr extension across admin/moderation/settings/space views, and route two identical failure SnackBars through a shared showErrorSnack helper. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Extract the themed Scaffold + back-button AppBar shell shared by the connections, privacy, profiles, voice, updates and developer settings screens into a reusable SettingsScaffold widget. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Replace the duplicated manage-space/manage-roles/view-audit-log triad in the space header menu and channel list with a shared canManageSpaceSettings helper. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
…irmDialog Replace the hand-rolled Cancel/destructive AlertDialogs for profile deletion and OAuth disconnect with the shared showConfirmDialog(danger: true) helper. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Pull the slim top-of-app banner chrome shared by UpdateBanner and WebUpdatePrompt into a reusable AppBanner widget (icon, message, tap, dismiss, optional trailing actions). Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Add an optional trailing action to SectionHeader and drop the developer panel's bespoke _ActivityHeader. Consolidate the duplicated accent/avatar swatch widgets and palette into shared ColorSwatchChip. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Three files imported client_access.dart but still used the old accordAuthProvider.select(s => s is AccordAuthLoggedIn ? s.client) pattern to obtain the client; replaced each with ref.accordClient and removed the now-unused auth imports. Added widget/unit tests for new shared components introduced by this PR: AppBanner, ColorSwatchChip, SettingsScaffold, RestResult.errorOr / showErrorSnack, SectionHeader trailing slot, and canManageSpaceSettings. https://claude.ai/code/session_01BrT1uDAMGiogdYHRM1pxYE
2cf0407 to
2df3cb8
Compare
Summary
A codebase-wide DRY sweep (run via parallel subagents) consolidating duplicated/WET code into shared helpers and components. Each logical group is a separate commit; net −116 lines across 49 files. No behavior changes intended;
flutter analyze --no-fatal-infosstays clean (only pre-existing infos remain).Staged commits
watch/readUserId,watchCdnUrl,watchIsAdminonWidgetRef/Ref, replacing ~40 inlineaccordAuthProvider.select(...)lambdas.RestResult.errorOr+showErrorSnack— dedupe ~45 ad-hoc error-snack / error-text sites.SettingsScaffold— single themed Scaffold+AppBar chrome shared by the settings pages.canManageSpaceSettings— extract the identical permission triad (only where genuinely identical; divergent permission sites left untouched).showConfirmDialog— route inline destructiveAlertDialogs through the shared confirm helper.AppBanner— shared slim top banner for the update / web-update prompts.SectionHeadertrailing slot +ColorSwatchChip— drop the developer panel's bespoke_ActivityHeader; consolidate the duplicated accent/avatar swatch widgets + palette.Scope notes (deliberately not changed)
Test plan
flutter analyze --no-fatal-infosclean (no new warnings/errors)🤖 Generated with Claude Code