[GH-ISSUE #1192] Update limit/doc-table when deleting documents or when drafting documents. #340

Closed
opened 2026-02-26 18:46:36 +03:00 by kerem · 1 comment
Owner

Originally created by @emmpaz on GitHub (Jun 21, 2024).
Original GitHub issue: https://github.com/documenso/documenso/issues/1192

Describe the improvement you are suggesting in detail

Currently when a user creates a document and does not complete it (draft), the limit does not update until a full page refresh. Similarly, when a user deletes a document.

Screenshot 2024-06-21 at 1 05 55 PM

Useful information

const refreshLimits = async () => {
    const newLimits = await getLimits({ teamId });

    setLimits((oldLimits) => {
      if (equals(oldLimits, newLimits)) {
        return oldLimits;
      }

      return newLimits;
    });
  };

This method refreshes the limit to see if it was updated.
It's current use case is only in 2 useEffect() to be called when the Limits provider component mounts.

This inaccuracy happens in 2 scenarios.

  1. Uploading document which directs you to the 'edit' page.

    • When a user goes back to the 'documents' page, since the provider does not need to re-mount the limits value is not updated.
  2. When deleting a document, we call the callback method onSuccess, which refreshes the page. This refresh only serves purpose for server pages and refetches the new data for the table. It does not un-mount provider, which makes the limits value stale.

Proposal

We can create a new triggerRefetchLimits() function from the Limits context and add it to the consumable values. Or we can use refetchLimits().

This can be used when deleted a document inside onSuccess or it can be used when uploading a document before redirection to the editing page.

This is my first contribution, so I would love some feedback!

Do you want to work on this improvement?

Yes

Please check the boxes that apply to this improvement suggestion.

  • I have searched the existing issues and improvement suggestions to avoid duplication.
  • I have provided a clear description of the improvement being suggested.
  • I have explained the rationale behind this improvement.
  • I have included any relevant technical details or design suggestions.
  • I understand that this is a suggestion and that there is no guarantee of implementation.
Originally created by @emmpaz on GitHub (Jun 21, 2024). Original GitHub issue: https://github.com/documenso/documenso/issues/1192 ### Describe the improvement you are suggesting in detail Currently when a user creates a document and does not complete it (draft), the limit does not update until a full page refresh. Similarly, when a user deletes a document. <img width="259" alt="Screenshot 2024-06-21 at 1 05 55 PM" src="https://github.com/documenso/documenso/assets/59887297/d5d7dadc-f8e9-4016-b65b-29e702853736"> ### Useful information ``` const refreshLimits = async () => { const newLimits = await getLimits({ teamId }); setLimits((oldLimits) => { if (equals(oldLimits, newLimits)) { return oldLimits; } return newLimits; }); }; ``` This method refreshes the limit to see if it was updated. It's current use case is only in 2 ```useEffect()``` to be called when the Limits provider component mounts. This inaccuracy happens in 2 scenarios. 1. Uploading document which directs you to the 'edit' page. - When a user goes back to the 'documents' page, since the provider does not need to re-mount the limits value is not updated. 2. When deleting a document, we call the callback method ```onSuccess```, which refreshes the page. This refresh only serves purpose for server pages and refetches the new data for the table. It does not un-mount provider, which makes the limits value stale. ### Proposal We can create a new ```triggerRefetchLimits()``` function from the Limits context and add it to the consumable values. Or we can use ```refetchLimits()```. This can be used when deleted a document inside ```onSuccess``` or it can be used when uploading a document before redirection to the editing page. This is my first contribution, so I would love some feedback! ### Do you want to work on this improvement? Yes ### Please check the boxes that apply to this improvement suggestion. - [X] I have searched the existing issues and improvement suggestions to avoid duplication. - [X] I have provided a clear description of the improvement being suggested. - [x] I have explained the rationale behind this improvement. - [x] I have included any relevant technical details or design suggestions. - [x] I understand that this is a suggestion and that there is no guarantee of implementation.
kerem 2026-02-26 18:46:36 +03:00
Author
Owner

@github-actions[bot] commented on GitHub (Jun 21, 2024):

Thank you for opening your first issue and for being a part of the open signing revolution!

One of our team members will review it and get back to you as soon as it possible 💚

Meanwhile, please feel free to hop into our community in Discord

<!-- gh-comment-id:2183204251 --> @github-actions[bot] commented on GitHub (Jun 21, 2024): Thank you for opening your first issue and for being a part of the open signing revolution! <br /> One of our team members will review it and get back to you as soon as it possible 💚 <br /> Meanwhile, please feel free to hop into our community in [Discord](https://documen.so/discord)
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#340
No description provided.