Skip to content

refactor(providers): split remaining services out of app_providers.dart, close #4506#4556

Merged
NotThatKindOfDrLiz merged 2 commits into
mainfrom
refactor/4506-batch-9c-social-foundation
May 21, 2026
Merged

refactor(providers): split remaining services out of app_providers.dart, close #4506#4556
NotThatKindOfDrLiz merged 2 commits into
mainfrom
refactor/4506-batch-9c-social-foundation

Conversation

@realmeylisdev
Copy link
Copy Markdown
Contributor

@realmeylisdev realmeylisdev commented May 19, 2026

Summary

Final sub-batch (9c of 3) of #4506's split wave. Refs #4339 Wave 2.

Moves the 15-entity social/foundation/collaborator cluster to `lib/providers/social_providers.dart`. After this batch, `app_providers.dart` is essentially a barrel of re-exports plus a single helper function.

What moved

3 legacy `Provider(...)` collaborator providers:

  • `collaboratorResponseServiceProvider`
  • `collaboratorInviteStateStoreProvider`
  • `collaboratorConfirmationRepositoryProvider`

Action/DM orchestration:

Analytics + view publishing:

  • `analyticsService` (Kind 22236 view-event publisher)

Hashtags:

  • `hashtagCacheService` (persistent hashtag selection state)
  • `hashtagService` (in-memory analyzer over video events)

Per-user content:

  • `draftStorageService`
  • `clipLibraryService`

Identity lifecycle:

  • `userDataCleanupService` (sign-out / identity-change cleanup orchestrator)

Social / NIP-51:

  • `socialService` (Kind 30000 follow sets)

Content management:

  • `contentReportingService` (NIP-56)
  • `contentDeletionService` (NIP-09)

Diagnostics:

  • `bugReportService` (NIP-17 encrypted reports + Blossom uploads)

Migration pattern (mirrors 9a/9b)

```dart
// app_providers.dart
export 'social_providers.dart'; // keeps 20+ external consumers' imports unchanged
```

social_providers.dart now imports the owning sibling provider files directly (auth_providers, relay_providers, repository_providers, upload_media_providers, video_providers), so the new file does not depend on the app_providers.dart barrel.

Scope cleanup

  • `dart fix --apply` removed 33 newly-unused imports from `app_providers.dart` and 7 from `social_providers.dart` (5 unnecessary + 2 fully unused).
  • Deleted `app_providers.g.dart` entirely — no `@riverpod` annotations remain in `app_providers.dart`, so the codegen file has nothing to produce. Dropped the `part 'app_providers.g.dart';` directive.
  • Three section divider comments removed (FOUNDATIONAL SERVICES, DEPENDENT SERVICES, "(Removed duplicate legacy provider for StreamUploadService)") since their content all moved out.

Codegen moved: 15 `*Provider` chunks (~675 LoC) relocated from `app_providers.g.dart` into `social_providers.g.dart`.

What's left in `app_providers.dart`

After this batch, the file is 40 lines:

  • Header (ABOUTME)
  • 7 imports (just the helper's deps — `flutter_riverpod`, `videos_repository`, `moderation_providers`, `feature_flag_providers`, `blocklist_content_filter`)
  • 11 `export` statements (the re-export barrel)
  • `createBlockedAuthorFilter` helper function (14 lines)

The helper still has 3 callers across `moderation_providers.dart`, `repository_providers.dart`, and `video_providers.dart`. Moving it (alongside the rest of the back-import cleanup) is tracked under #4554.

Cumulative reduction across the full wave

State `app_providers.dart` LoC Reduction
Original (audit baseline) 2,918
After 9a (#4550) 978 66%
After 9b (#4555) 455 84%
After 9c (this PR) 40 98.6%

Each domain file:

File LoC Under 800 cap?
`auth_providers.dart` (existing)
`moderation_providers.dart` (existing)
`upload_media_providers.dart` 154
`video_providers.dart` (existing)
`repository_providers.dart` 551
`social_providers.dart` 410

Acceptance criteria for #4506

  • `app_providers.dart` is under 400 lines (now 40, re-export barrel + helper).
  • Each domain provider file is under 800 lines.
  • No provider in a domain file depends on Flutter widgets directly.
  • Each extraction PR independently shippable and reverts cleanly (9a → 9b → 9c).
  • Riverpod codegen still passes; `dart run build_runner build --delete-conflicting-outputs` produces no diff after the split.

Closes #4506.

Test plan

  • `dart run build_runner build --delete-conflicting-outputs` — clean
  • `flutter analyze lib test integration_test` — No issues found
  • `flutter test test/screens/feed/pooled_video_feed_item_repo_swap_test.dart test/widgets/video_feed_item/feed_videos_repo_swap_test.dart test/providers/dm_repository_provider_test.dart test/providers/curated_list_repository_bridge_test.dart` — 10 passed (incl. fix: cannot like first two videos in home feed #3503 repo-swap key-identity tests + the curated-list bridge test from feat(feed): remove new feed from home dropdown #4542)
  • `dart format` applied

Reviewer

Per established pattern, only @NotThatKindOfDrLiz will be added when CI turns green.

@realmeylisdev
Copy link
Copy Markdown
Contributor Author

Wave summary — app_providers.dart decomposition

Batch PR app_providers.dart LoC Cumulative reduction
Original (audit baseline) 2,918
9a (upload & media) #4550 978 66%
9b (repositories) #4555 455 84%
9c (this PR — social + foundation) #4556 40 98.6%

Each split file is under the 800-LoC cap per #4506's acceptance criteria. After 9c lands, app_providers.dart is a re-export barrel plus the lone createBlockedAuthorFilter helper — whose move alongside the remaining back-import cleanup is tracked under #4554.

@github-actions

This comment has been minimized.

realmeylisdev and others added 2 commits May 20, 2026 11:01
…rt, close #4506

Final sub-batch (9c of 3) of #4506's split wave. Refs #4339 Wave 2.

Moves the 15-entity social/foundation/collaborator cluster to
lib/providers/social_providers.dart:

- 3 legacy Provider<X> collaborator providers (response service, invite
  state store, confirmation repository)
- pendingActionService, outgoingDmRetryService (offline-action and DM
  retry orchestration)
- analyticsService (Kind 22236 view publisher)
- hashtagCacheService, hashtagService (in-memory + persistent hashtag indexes)
- draftStorageService, clipLibraryService (per-user content drafts/clips)
- userDataCleanupService (sign-out / identity-change cleanup orchestrator)
- socialService (NIP-51 Kind 30000 follow sets)
- contentReportingService (NIP-56)
- contentDeletionService (NIP-09)
- bugReportService (NIP-17 encrypted bug reports + Blossom uploads)

Migration pattern (mirrors 9a/9b):

  // app_providers.dart
  export 'social_providers.dart';  // keeps consumers' imports unchanged

After this batch, app_providers.dart is essentially a barrel of re-exports
plus the lone createBlockedAuthorFilter helper (which still has 3 callers
across moderation, repository, and video providers — moving it is tracked
under #4554 along with the rest of the back-import cleanup).

Scope cleanup:

- dart fix --apply removed 33 newly-unused imports from app_providers.dart.
- Deleted app_providers.g.dart entirely — no @riverpod annotations remain
  in app_providers.dart, so the generated file has nothing to produce.
  Dropped the `part 'app_providers.g.dart';` directive.
- Three section dividers removed (FOUNDATIONAL SERVICES, DEPENDENT
  SERVICES, "(Removed duplicate legacy provider for StreamUploadService)")
  since their content all moved out.

Cumulative reduction:
- app_providers.dart: 2,918 -> 40 LoC (98.6% reduction).
- Domain files now own ~all provider declarations. Each provider file is
  under 800 LoC (#4506 acceptance criterion).

Closes #4506.

Test plan:
- dart run build_runner build --delete-conflicting-outputs (clean)
- flutter analyze lib test integration_test (No issues found)
- flutter test test/screens/feed/pooled_video_feed_item_repo_swap_test.dart
  test/widgets/video_feed_item/feed_videos_repo_swap_test.dart
  test/providers/dm_repository_provider_test.dart
  test/providers/curated_list_repository_bridge_test.dart (10 passed)
@NotThatKindOfDrLiz NotThatKindOfDrLiz force-pushed the refactor/4506-batch-9c-social-foundation branch from 7b9c084 to 26c20b6 Compare May 20, 2026 15:07
@NotThatKindOfDrLiz
Copy link
Copy Markdown
Member

Took over this PR and cleaned up the new provider split before merge.

What changed:

  • removed the new social_providers.dart -> app_providers.dart back-import
  • switched social_providers.dart to direct sibling imports from auth_providers.dart, relay_providers.dart, repository_providers.dart, upload_media_providers.dart, and video_providers.dart
  • updated the PR description so it matches the final import graph

Local verification on the updated branch:

  • dart run build_runner build --delete-conflicting-outputs
  • flutter analyze lib test integration_test
  • flutter test test/screens/feed/pooled_video_feed_item_repo_swap_test.dart test/widgets/video_feed_item/feed_videos_repo_swap_test.dart test/providers/dm_repository_provider_test.dart test/providers/curated_list_repository_bridge_test.dart

This keeps the split behaviorally identical while avoiding new provider-barrel debt in the file introduced by this PR.

@github-actions
Copy link
Copy Markdown

Mobile PR Preview

Preview refreshed for 26c20b6

Last refresh: 26c20b6 at 2026-05-20 18:30:47 UTC (preview run)

Property Value
Preview URL https://b06d1892.openvine-app.pages.dev
Pages project openvine-app
Preview branch pr-4556
PR branch refactor/4506-batch-9c-social-foundation
Commit 26c20b6

Copy link
Copy Markdown
Member

@NotThatKindOfDrLiz NotThatKindOfDrLiz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Final pass complete. The provider split is clean, the follow-up import cleanup is in place, there are no unresolved review threads, and all required checks are green.

@NotThatKindOfDrLiz
Copy link
Copy Markdown
Member

Final pass on May 21, 2026:

  • verified the branch head is still 26c20b6 with the social-provider back-import cleanup in place
  • confirmed there are no unresolved review threads on the PR
  • confirmed all required checks are green, including Analyze, Tests, Generated Files, Format, preview build, semantic PR, mergeability, linked issue, and CLA
  • spot-checked the final diff to make sure app_providers.dart is now just the compatibility barrel plus createBlockedAuthorFilter, while the moved providers and generated part-of rename live in social_providers.dart and social_providers.g.dart

No further code changes were needed after the takeover commit. This looks ready to merge.

@NotThatKindOfDrLiz NotThatKindOfDrLiz merged commit 2a0d43c into main May 21, 2026
11 checks passed
@NotThatKindOfDrLiz NotThatKindOfDrLiz deleted the refactor/4506-batch-9c-social-foundation branch May 21, 2026 22:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

refactor(providers): split app_providers.dart by feature domain

2 participants