[PR #1195] [MERGED] fix: limits syncing issue #1462

Closed
opened 2026-02-26 19:33:22 +03:00 by kerem · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/documenso/documenso/pull/1195
Author: @emmpaz
Created: 6/24/2024
Status: Merged
Merged: 7/31/2024
Merged by: @Mythie

Base: mainHead: fix/doc-1192-limits-syncing-issue


📝 Commits (8)

  • fc7e11c fix: limit displayed is now consistent after deleting/creating
  • a7ed768 Merge branch 'documenso:main' into fix/doc-1192-limits-syncing-issue
  • 2bd3606 fix: updating aysnc behavior to align with current behavior
  • aa0a739 Update packages/ee/server-only/limits/provider/client.tsx
  • fa442c6 Merge branch 'documenso:main' into fix/doc-1192-limits-syncing-issue
  • 1119af8 Merge branch 'main' into fix/doc-1192-limits-syncing-issue
  • d956329 chore: minor updates
  • 250832a fix: remove unnecessary spread

📊 Changes

4 files changed (+25 additions, -12 deletions)

View changed files

📝 apps/web/src/app/(dashboard)/documents/delete-document-dialog.tsx (+3 -0)
📝 apps/web/src/app/(dashboard)/documents/upload-document.tsx (+3 -1)
📝 packages/ee/server-only/limits/provider/client.tsx (+18 -9)
📝 packages/ee/server-only/limits/provider/server.tsx (+1 -2)

📄 Description


name: Pull Request
about: Submit changes to the project for review and inclusion

Description

Expose refreshLimit() to be able to keep the limit in sync when deleting/creating a document.

Fixes #1192

Changes Made

Adding the refreshLimits() as a context value. We can only keep it as a optional parameter, because requring it means to put it in the initial props which means it will become part of the limits state, where a function cannot be within a state.

Inside useLimits() I create a type and runtime safe function that makes sure refreshLimits() is a function within the context.

  • Change 1
    Inside delete-document-dialog.tsx, I simply add void refreshLimits() after we refresh the page.

  • Change 2
    Inside upload-document.tsx, we can do the same as above. After successfully uploading a document, we can refresh the limit.

Testing Performed

I have uploading a document and keeping it as a draft by redirecting back the '/documents' page and can confirm the limit updates.

I have deleted a document from my list and can confirm the limit updates accordingly.

Checklist

  • I have tested these changes locally and they work as expected.
  • I have added/updated tests that prove the effectiveness of these changes.
  • I have updated the documentation to reflect these changes, if applicable.
  • I have followed the project's coding style guidelines.
  • I have addressed the code review feedback from the previous submission, if applicable.

Additional Notes

As I am exposing this function to the context and new components consume this context, I had to make sure that there was not any un-necessary re-renders.

As router.refresh() only refreshes the server data, the client component is cached so there is no re-render for the client that consumes this data.

Summary by CodeRabbit

  • New Features

    • Added functionality to refresh usage limits after deleting a document.
    • Added functionality to refresh usage limits after uploading a document.
  • Improvements

    • Enhanced limits management by incorporating a refreshLimits function in context, ensuring up-to-date limit information.

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/documenso/documenso/pull/1195 **Author:** [@emmpaz](https://github.com/emmpaz) **Created:** 6/24/2024 **Status:** ✅ Merged **Merged:** 7/31/2024 **Merged by:** [@Mythie](https://github.com/Mythie) **Base:** `main` ← **Head:** `fix/doc-1192-limits-syncing-issue` --- ### 📝 Commits (8) - [`fc7e11c`](https://github.com/documenso/documenso/commit/fc7e11cd954e32ab7055c21927d3d8a5525a6ef8) fix: limit displayed is now consistent after deleting/creating - [`a7ed768`](https://github.com/documenso/documenso/commit/a7ed768e7a04156aa34b21ca774f26c273fefeb6) Merge branch 'documenso:main' into fix/doc-1192-limits-syncing-issue - [`2bd3606`](https://github.com/documenso/documenso/commit/2bd360653f0a832ff4ce90b666ef4d683f4d1f12) fix: updating aysnc behavior to align with current behavior - [`aa0a739`](https://github.com/documenso/documenso/commit/aa0a739e23e4261f3549ea1adeb07131df1cdb2e) Update packages/ee/server-only/limits/provider/client.tsx - [`fa442c6`](https://github.com/documenso/documenso/commit/fa442c6f849eab9c34f27308052a5404c1f07fbf) Merge branch 'documenso:main' into fix/doc-1192-limits-syncing-issue - [`1119af8`](https://github.com/documenso/documenso/commit/1119af8dac29a5d06c32d6bfd4f5a97a404ca5f6) Merge branch 'main' into fix/doc-1192-limits-syncing-issue - [`d956329`](https://github.com/documenso/documenso/commit/d9563296e76aad3efbdc6eb3be9c53c05d5f4226) chore: minor updates - [`250832a`](https://github.com/documenso/documenso/commit/250832a061bb608f5d7ad107bbc9c484485488a8) fix: remove unnecessary spread ### 📊 Changes **4 files changed** (+25 additions, -12 deletions) <details> <summary>View changed files</summary> 📝 `apps/web/src/app/(dashboard)/documents/delete-document-dialog.tsx` (+3 -0) 📝 `apps/web/src/app/(dashboard)/documents/upload-document.tsx` (+3 -1) 📝 `packages/ee/server-only/limits/provider/client.tsx` (+18 -9) 📝 `packages/ee/server-only/limits/provider/server.tsx` (+1 -2) </details> ### 📄 Description --- name: Pull Request about: Submit changes to the project for review and inclusion --- ## Description Expose ```refreshLimit()``` to be able to keep the limit in sync when deleting/creating a document. ## Related Issue Fixes #1192 ## Changes Made Adding the ```refreshLimits()``` as a context value. We can only keep it as a optional parameter, because requring it means to put it in the initial props which means it will become part of the limits state, where a function cannot be within a state. Inside ```useLimits()``` I create a type and runtime safe function that makes sure ```refreshLimits()``` is a function within the context. - Change 1 Inside ```delete-document-dialog.tsx```, I simply add ```void refreshLimits()``` after we refresh the page. - Change 2 Inside ```upload-document.tsx```, we can do the same as above. After successfully uploading a document, we can refresh the limit. ## Testing Performed I have uploading a document and keeping it as a draft by redirecting back the '/documents' page and can confirm the limit updates. I have deleted a document from my list and can confirm the limit updates accordingly. ## Checklist <!--- Please check the boxes that apply to this pull request. --> <!--- You can add or remove items as needed. --> - [x] I have tested these changes locally and they work as expected. - [ ] I have added/updated tests that prove the effectiveness of these changes. - [x] I have updated the documentation to reflect these changes, if applicable. - [x] I have followed the project's coding style guidelines. - [ ] I have addressed the code review feedback from the previous submission, if applicable. ## Additional Notes As I am exposing this function to the context and new components consume this context, I had to make sure that there was not any un-necessary re-renders. As ```router.refresh()``` only refreshes the server data, the client component is cached so there is no re-render for the client that consumes this data. <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit - **New Features** - Added functionality to refresh usage limits after deleting a document. - Added functionality to refresh usage limits after uploading a document. - **Improvements** - Enhanced limits management by incorporating a `refreshLimits` function in context, ensuring up-to-date limit information. <!-- end of auto-generated comment: release notes by coderabbit.ai --> --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
kerem 2026-02-26 19:33:22 +03:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/documenso#1462
No description provided.