Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 6 commits into from
Jul 11, 2024

Conversation

kozer
Copy link
Contributor

@kozer kozer commented Jul 8, 2024

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 added the [Type] Bug Something isn't working label Jul 8, 2024
@kozer kozer changed the title Fix/snapshots counter Studio: Snapshot counter not updating in settings when a site is deleted Jul 8, 2024
Copy link
Member

@sejas sejas left a comment

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

src/ipc-handlers.ts Outdated Show resolved Hide resolved
src/hooks/use-snapshots.tsx Outdated Show resolved Hide resolved
src/hooks/use-snapshots.tsx Show resolved Hide resolved
src/hooks/use-snapshots.tsx Outdated Show resolved Hide resolved
src/hooks/use-archive-site.ts Outdated Show resolved Hide resolved
@kozer kozer merged commit d89adf3 into trunk Jul 11, 2024
10 checks passed
@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
[Type] Bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants