AFFiNE icon indicating copy to clipboard operation
AFFiNE copied to clipboard

feat(core): add use guard hook

Open EYHN opened this issue 9 months ago • 3 comments

Previously, we used useLiveData(guardService.can$()) to get the guard result, but guardService.can$() will request the server to revalidate the permission when calling it, will cause additional network requests when re-render.

This pr make a new hook useGuard to fix this problem.

And the side effect in can$ is moved to revalidateCan() to make that the subscribe method is pure

EYHN avatar Mar 25 '25 11:03 EYHN


How to use the Graphite Merge Queue

Add either label to this PR to merge it via the merge queue:

  • merge - adds this PR to the back of the merge queue
  • hotfix - for urgent hot fixes, skip the queue and merge this PR next

You must have a Graphite account in order to use the merge queue. Sign up using this link.

An organization admin has enabled the Graphite Merge Queue in this repository.

Please do not merge from GitHub as this will restart CI on PRs being processed by the merge queue.

This stack of pull requests is managed by Graphite. Learn more about stacking.

EYHN avatar Mar 25 '25 11:03 EYHN

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

Project coverage is 54.36%. Comparing base (a10acf3) to head (3df51a2). Report is 1 commits behind head on canary.

Additional details and impacted files
@@           Coverage Diff           @@
##           canary   #11180   +/-   ##
=======================================
  Coverage   54.36%   54.36%           
=======================================
  Files        2547     2547           
  Lines      115108   115108           
  Branches    18716    18717    +1     
=======================================
+ Hits        62578    62581    +3     
+ Misses      51200    51198    -2     
+ Partials     1330     1329    -1     
Flag Coverage Δ
server-test 78.90% <ø> (+<0.01%) :arrow_up:
unittest 30.28% <ø> (-0.01%) :arrow_down:

Flags with carried forward coverage won't be shown. Click here to find out more.

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

:rocket: New features to boost your workflow:
  • :snowflake: Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • :package: JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

codecov[bot] avatar Mar 25 '25 11:03 codecov[bot]

Merge activity

graphite-app[bot] avatar Mar 25 '25 13:03 graphite-app[bot]