Skip to content

Studio: Snapshot counter not updating in settings when a site is deleted - #344

Merged
kozer merged 6 commits into
trunkfrom
fix/snapshots_counter
Jul 11, 2024
Merged

Studio: Snapshot counter not updating in settings when a site is deleted#344
kozer merged 6 commits into
trunkfrom
fix/snapshots_counter

Conversation

@kozer

@kozer kozer commented Jul 8, 2024

Copy link
Copy Markdown
Contributor

Fixes https://github.com/Automattic/dotcom-forge/issues/8132

Proposed Changes

This diff fixes a bug when the snapshot counter in user settings is not updated when the user deletes a site from settings tab.

NOTES:

  1. The problem was created due to circular dependencies between the different hooks and useSiteDetails.
  2. The issue is now fixed, by centralizing all snapshot logic in one place, and use it in useSiteDetails, where necessary
  3. It can simplified further, and moved into different hooks to offload the main use-snapshots provider. However, as we have moved to another project, I leave it for a different ticket.

Testing Instructions

  1. Create a site
  2. Add a snapshot
  3. Open user settings and ensure the counter has been increased
  4. Navigate to settings
  5. Press "Delete site" button at the bottom of the page
  6. Ensure that after visiting settings, the counter has been decreased.

Pre-merge Checklist

  • Have you checked for TypeScript, React or other console errors?
@kozer
kozer requested a review from a team July 8, 2024 19:20
@kozer kozer self-assigned this Jul 8, 2024
@kozer kozer changed the title Fix/snapshots counter Jul 8, 2024

@sejas sejas left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I've tested it by creating, updating and deleting some snapshots, and checking the quota. Everything worked as expected.
I've added some optimizations and suggestions removing duplicated code.
Screenshot 2024-07-11 at 10 41 08

Screenshot 2024-07-11 at 10 41 04
Comment thread src/ipc-handlers.ts Outdated
Comment thread src/hooks/use-snapshots.tsx Outdated
Comment thread src/hooks/use-snapshots.tsx
Comment thread src/hooks/use-snapshots.tsx
Comment thread src/hooks/use-archive-site.ts Outdated
@kozer
kozer merged commit d89adf3 into trunk Jul 11, 2024
@kozer
kozer deleted the fix/snapshots_counter branch July 11, 2024 11:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

2 participants