File tree Expand file tree Collapse file tree 2 files changed +15
-9
lines changed
Expand file tree Collapse file tree 2 files changed +15
-9
lines changed Original file line number Diff line number Diff line change @@ -48,9 +48,21 @@ export class BillingStore {
4848 makeAutoObservable ( this ) ;
4949
5050 createImmediateReaction (
51- ( ) => balanceStore . currentBalance$ ,
52- ( ) => {
53- this . fetchHistory ( ) ;
51+ ( ) => projectsStore . selectedProject ,
52+ project => {
53+ this . clearState ( ) ;
54+ if ( project ) {
55+ this . fetchHistory ( ) ;
56+ }
57+ }
58+ ) ;
59+
60+ createImmediateReaction (
61+ ( ) => balanceStore . balance ?. total ,
62+ total => {
63+ if ( total !== undefined && projectsStore . selectedProject ) {
64+ this . fetchHistory ( ) ;
65+ }
5466 }
5567 ) ;
5668 }
Original file line number Diff line number Diff line change @@ -14,12 +14,6 @@ const BillingBlock: FC<BillingBlockProps> = ({ billingStore }) => {
1414 const hasBillingHistory = billingStore . billingHistory . length > 0 ;
1515 const isLoading = billingStore . billingHistoryLoading ;
1616
17- // Reset state when store instance changes
18- useEffect ( ( ) => {
19- setHasEverLoaded ( false ) ;
20- setPreviousRowCount ( 0 ) ;
21- } , [ billingStore ] ) ;
22-
2317 // Track whether data has ever been loaded and remember the row count
2418 useEffect ( ( ) => {
2519 if ( ! isLoading && hasBillingHistory ) {
You can’t perform that action at this time.
0 commit comments