2007 task replace unsubscribe service with takeuntildestroyed - #808
Conversation
|
There seem to be more occurrences of subscriptions that could have For example: |
…-takeuntildestroyed
…rvice-with-takeuntildestroyed' into 2007-task-replace-unsubscribe-service-with-takeuntildestroyed # Conflicts: # src/app/core/_components/tables/base-table/base-table.component.ts # src/app/shared/report-builder/reports/base-report/base-report.component.ts
There was a problem hiding this comment.
Pull request overview
This PR removes the custom UnsubscribeService pattern and migrates Angular components to use DestroyRef + takeUntilDestroyed() for subscription cleanup, along with corresponding test updates.
Changes:
- Replaced manual subscription tracking/unsubscribe logic with
takeUntilDestroyed(inject(DestroyRef))across many components. - Refactored table base/components to rely on
DestroyRefinstead ofSubscriptioncollections. - Deleted
src/app/core/_services/unsubscribe.service.tsand removed it from unit tests/providers.
Reviewed changes
Copilot reviewed 95 out of 95 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| src/app/users/globalpermissionsgroups/edit-globalpermissionsgroups/edit-globalpermissionsgroups.component.ts | Replace UnsubscribeService with DestroyRef + takeUntilDestroyed. |
| src/app/users/globalpermissionsgroups/edit-globalpermissionsgroups/edit-globalpermissionsgroups.component.spec.ts | Remove UnsubscribeService test provider/mocks. |
| src/app/users/edit-users/edit-users.component.ts | Replace UnsubscribeService with DestroyRef + takeUntilDestroyed. |
| src/app/users/edit-users/edit-users.component.spec.ts | Remove UnsubscribeService test provider/mocks and related assertions. |
| src/app/users/edit-groups/edit-groups.component.ts | Replace UnsubscribeService with DestroyRef + takeUntilDestroyed. |
| src/app/users/edit-groups/edit-groups.component.spec.ts | Remove UnsubscribeService from providers. |
| src/app/tasks/new-preconfigured-tasks/new-preconfigured-tasks.component.ts | Replace UnsubscribeService with DestroyRef + takeUntilDestroyed. |
| src/app/tasks/import-supertasks/wrbulk/wrbulk.component.ts | Replace UnsubscribeService with DestroyRef + takeUntilDestroyed. |
| src/app/tasks/import-supertasks/wrbulk/wrbulk.component.spec.ts | Remove UnsubscribeService test provider/mocks. |
| src/app/tasks/import-supertasks/masks/masks.component.ts | Replace UnsubscribeService with DestroyRef + takeUntilDestroyed. |
| src/app/tasks/import-supertasks/masks/masks.component.spec.ts | Remove UnsubscribeService test provider/mocks. |
| src/app/tasks/edit-tasks/edit-tasks.component.ts | Remove unused routeSub unsubscribe logic. |
| src/app/tasks/edit-preconfigured-tasks/edit-preconfigured-tasks.component.ts | Replace UnsubscribeService with DestroyRef + takeUntilDestroyed. |
| src/app/shared/report-builder/reports/hashlist-report/hashlist-report.component.ts | Remove manual subscription cleanup; rely on updated base pattern. |
| src/app/shared/report-builder/reports/base-report/base-report.component.ts | Remove subscriptions tracking from report base component. |
| src/app/layout/header/header.component.ts | Replace manual subscription arrays/subjects with DestroyRef + takeUntilDestroyed. |
| src/app/home/home.component.ts | Replace manual subscription array cleanup with DestroyRef + takeUntilDestroyed. |
| src/app/hashlists/search-hash/search-hash.component.ts | Remove UnsubscribeService and component-level destroy cleanup. |
| src/app/hashlists/new-hashlist/new-hashlist.component.spec.ts | Remove UnsubscribeService from tests. |
| src/app/hashlists/import-cracked-hashes/import-cracked-hashes.component.ts | Replace UnsubscribeService + custom destroy subjects with DestroyRef + takeUntilDestroyed. |
| src/app/hashlists/import-cracked-hashes/import-cracked-hashes.component.spec.ts | Remove UnsubscribeService test provider/mocks and destroy tests. |
| src/app/hashlists/hashes/hashes.component.ts | Replace UnsubscribeService with DestroyRef + takeUntilDestroyed. |
| src/app/hashlists/edit-hashlist/edit-hashlist.component.ts | Replace UnsubscribeService with DestroyRef + takeUntilDestroyed. |
| src/app/hashlists/edit-hashlist/edit-hashlist.component.spec.ts | Remove UnsubscribeService from tests and related assertions. |
| src/app/files/new-files/new-files.component.ts | Replace UnsubscribeService + custom destroy subject with DestroyRef + takeUntilDestroyed. |
| src/app/files/new-files/new-files.component.spec.ts | Remove UnsubscribeService from tests and destroy test. |
| src/app/core/_services/unsubscribe.service.ts | Delete UnsubscribeService. |
| src/app/core/_components/tables/vouchers-table/vouchers-table.component.ts | Use takeUntilDestroyed(this.destroyRef) instead of pushing subscriptions. |
| src/app/core/_components/tables/users-table/users-table.component.ts | Use takeUntilDestroyed(this.destroyRef) instead of pushing subscriptions. |
| src/app/core/_components/tables/tasks-table/tasks-table.component.ts | Use takeUntilDestroyed(this.destroyRef) instead of pushing subscriptions. |
| src/app/core/_components/tables/tasks-table/tasks-table.component.spec.ts | Update datasource stub to Subject for filterError$. |
| src/app/core/_components/tables/tasks-chunks-table/tasks-chunks-table.component.ts | Use takeUntilDestroyed(this.destroyRef) for action subscriptions. |
| src/app/core/_components/tables/tasks-agents-table/tasks-agents-table.component.ts | Use takeUntilDestroyed(this.destroyRef) for dialog/actions. |
| src/app/core/_components/tables/supertasks-table/supertasks-table.component.ts | Use takeUntilDestroyed(this.destroyRef) for dialog/actions. |
| src/app/core/_components/tables/supertasks-pretasks-table/supertasks-pretasks-table.component.ts | Use takeUntilDestroyed(this.destroyRef) for dialog/actions. |
| src/app/core/_components/tables/super-hashlists-table/super-hashlists-table.component.ts | Use takeUntilDestroyed(this.destroyRef) for dialog/actions. |
| src/app/core/_components/tables/super-hashlist-hashlist-table/super-hashlist-hashlist-table.component.ts | Use takeUntilDestroyed(this.destroyRef) for dialog/actions. |
| src/app/core/_components/tables/search-hash-table/search-hash-table.component.ts | Remove manual unsubscribe loop for base subscriptions. |
| src/app/core/_components/tables/pretasks-table/pretasks-table.component.spec.ts | Update datasource stub to Subject for filterError$. |
| src/app/core/_components/tables/preprocessors-table/preprocessors-table.component.ts | Use takeUntilDestroyed(this.destroyRef) for dialog/actions. |
| src/app/core/_components/tables/permissions-table/permissions-table.component.ts | Use takeUntilDestroyed(this.destroyRef) for dialog/actions. |
| src/app/core/_components/tables/notifications-table/notifications-table.component.ts | Use takeUntilDestroyed(this.destroyRef) for dialog/actions. |
| src/app/core/_components/tables/logs-table/logs-table.component.ts | Remove manual unsubscribe loop for base subscriptions. |
| src/app/core/_components/tables/ht-table/ht-table.component.ts | Replace Subscription aggregator with DestroyRef + takeUntilDestroyed. |
| src/app/core/_components/tables/health-checks-table/health-checks-table.component.ts | Use takeUntilDestroyed(this.destroyRef) for dialog/actions. |
| src/app/core/_components/tables/health-check-agents-table/health-check-agents-table.component.ts | Remove manual unsubscribe loop for base subscriptions. |
| src/app/core/_components/tables/hashtypes-table/hashtypes-table.component.ts | Use takeUntilDestroyed(this.destroyRef) for dialog/actions. |
| src/app/core/_components/tables/hashlists-table/hashlists-table.component.ts | Use takeUntilDestroyed(this.destroyRef) for dialog/actions. |
| src/app/core/_components/tables/hashlists-table/hashlists-table.component.spec.ts | Update datasource stub to Subject for filterError$. |
| src/app/core/_components/tables/hashlist-supertask-builder-table/hashlist-supertask-builder-table.component.ts | Replace stored subscription with takeUntilDestroyed for datasource connect. |
| src/app/core/_components/tables/hashlist-pretask-builder-table/hashlist-pretask-builder-table.component.ts | Replace stored subscription with takeUntilDestroyed for datasource connect. |
| src/app/core/_components/tables/hashes-table/hashes-table.component.ts | Remove manual unsubscribe loop for base subscriptions. |
| src/app/core/_components/tables/files-table/files-table.component.ts | Use takeUntilDestroyed(this.destroyRef) for dialog/actions. |
| src/app/core/_components/tables/files-attack-table/files-attack-table.component.ts | Remove manual unsubscribe loop for base subscriptions. |
| src/app/core/_components/tables/cracks-table/cracks-table.component.ts | Use takeUntilDestroyed(this.destroyRef) for dialog/actions. |
| src/app/core/_components/tables/crackers-table/crackers-table.component.ts | Use takeUntilDestroyed(this.destroyRef) for dialog/actions. |
| src/app/core/_components/tables/chunks-table/chunks-table.component.ts | Use takeUntilDestroyed(this.destroyRef) for action subscriptions. |
| src/app/core/_components/tables/chunks-table/chunks-table.component.spec.ts | Update datasource stub to Subject for filterError$. |
| src/app/core/_components/tables/base-table/base-table.component.ts | Introduce DestroyRef + takeUntilDestroyed in base subscription wiring. |
| src/app/core/_components/tables/api-tokens-table/api-tokens-table.component.ts | Use takeUntilDestroyed(this.destroyRef) for dialog subscriptions. |
| src/app/core/_components/tables/agents-table/agents-table.component.ts | Use takeUntilDestroyed(this.destroyRef) for dialog/actions. |
| src/app/core/_components/tables/agents-status-table/agents-status-table.component.ts | Use takeUntilDestroyed(this.destroyRef) for dialog/actions. |
| src/app/core/_components/tables/agent-error-table/agent-error-table.component.ts | Use takeUntilDestroyed(this.destroyRef) for dialog/actions. |
| src/app/core/_components/tables/agent-binaries-table/agent-binaries-table.component.ts | Use takeUntilDestroyed(this.destroyRef) for dialog/actions. |
| src/app/core/_components/tables/access-permission-groups-users-table/access-permission-groups-users-table.component.ts | Remove manual unsubscribe loop for base subscriptions. |
| src/app/core/_components/tables/access-permission-groups-user-table/access-permission-groups-user-table.component.ts | Use takeUntilDestroyed(this.destroyRef) for update requests. |
| src/app/core/_components/tables/access-groups-users-table/access-groups-users-table.component.ts | Use takeUntilDestroyed(this.destroyRef) for dialog/actions. |
| src/app/core/_components/tables/access-groups-table/access-groups-table.component.ts | Use takeUntilDestroyed(this.destroyRef) for dialog/actions. |
| src/app/core/_components/tables/access-groups-table/access-groups-table.component.spec.ts | Remove ngOnDestroy subscription-unsubscribe test (pattern removed). |
| src/app/core/_components/tables/access-groups-agents-table/access-groups-agents-table.component.ts | Use takeUntilDestroyed(this.destroyRef) for dialog/actions. |
| src/app/core/_components/menus/action-menu/action-menu.component.ts | Replace manual subscription array with DestroyRef + takeUntilDestroyed. |
| src/app/core/_components/forms/simple-forms/formconfig.component.ts | Replace manual subscription storage with DestroyRef + takeUntilDestroyed. |
| src/app/core/_components/forms/simple-forms/formconfig.component.spec.ts | Remove UnsubscribeService provider and related destroy test. |
| src/app/core/_components/forms/custom-forms/task/new-supertasks/new-supertasks.component.ts | Replace UnsubscribeService with DestroyRef + takeUntilDestroyed. |
| src/app/core/_components/forms/custom-forms/superhashlist/new-superhashlist/new-superhashlist.component.ts | Replace UnsubscribeService with DestroyRef + takeUntilDestroyed. |
| src/app/config/server-actions/server-actions.component.ts | Replace UnsubscribeService with DestroyRef + takeUntilDestroyed. |
| src/app/config/health-checks/view-health-check/view-health-checks.component.ts | Replace UnsubscribeService with DestroyRef + takeUntilDestroyed. |
| src/app/config/health-checks/new-health-check/new-health-checks.component.ts | Replace UnsubscribeService with DestroyRef + takeUntilDestroyed. |
| src/app/config/engine/preprocessors/new_edit-preprocessor/new_edit-preprocessor.component.ts | Replace component-managed subscriptions with DestroyRef + takeUntilDestroyed. |
| src/app/auth/forgot-password/forgot-password.component.ts | Replace UnsubscribeService with DestroyRef + takeUntilDestroyed. |
| src/app/auth/forgot-password/forgot-password.component.spec.ts | Remove UnsubscribeService provider/mocks and related assertions. |
| src/app/auth/auth.component.ts | Replace UnsubscribeService with DestroyRef + takeUntilDestroyed. |
| src/app/auth/auth.component.spec.ts | Remove UnsubscribeService provider/mocks and related assertions. |
| src/app/agents/new-agent/new-agent.component.ts | Replace manual subscription tracking with DestroyRef + takeUntilDestroyed. |
| src/app/agents/new-agent/new-agent.component.spec.ts | Remove destroy/unsubscribe test for removed subscription field. |
| src/app/agents/edit-agent/edit-agent.component.ts | Replace UnsubscribeService with DestroyRef + takeUntilDestroyed. |
| src/app/agents/edit-agent/edit-agent.component.spec.ts | Remove destroy/unsubscribe test for removed service. |
| src/app/account/settings/acc-settings/acc-settings.component.ts | Replace manual subscription array with DestroyRef + takeUntilDestroyed. |
| src/app/account/notifications/notification/new-notification.component.ts | Replace manual subscription array with DestroyRef + takeUntilDestroyed. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
I included other components that had this existing pattern of tracking subscriptions and unsubscribing during Now there is mainly only datasource classes left, that track their internal subscriptions for unsubscribing during a disconnect. Introducing the |
remove subscription service