@@ -68,11 +68,11 @@ class ReactTimeSync implements ReactTimeSyncApi {
68
68
subscribe = ( entry : ReactSubscriptionEntry ) : ( ( ) => void ) => {
69
69
const { select, id, targetRefreshInterval, onUpdate } = entry ;
70
70
71
- const patchedEntry : SubscriptionEntry = {
71
+ const fullEntry : SubscriptionEntry = {
72
72
id,
73
73
targetRefreshInterval,
74
74
onUpdate : ( newDate ) => {
75
- const prevSelection = this . getSelectionSnapshot ( id ) ;
75
+ const prevSelection = this . #selectionCache . get ( id ) ?. value ;
76
76
const newSelection = select ?.( newDate ) ?? newDate ;
77
77
if ( areValuesDeepEqual ( prevSelection , newSelection ) ) {
78
78
return ;
@@ -83,7 +83,7 @@ class ReactTimeSync implements ReactTimeSyncApi {
83
83
} ,
84
84
} ;
85
85
86
- this . #timeSync. subscribe ( patchedEntry ) ;
86
+ this . #timeSync. subscribe ( fullEntry ) ;
87
87
return ( ) => this . #timeSync. unsubscribe ( id ) ;
88
88
} ;
89
89
@@ -114,13 +114,13 @@ class ReactTimeSync implements ReactTimeSyncApi {
114
114
const dateSnapshot = this . #timeSync. getTimeSnapshot ( ) ;
115
115
const newSelection = select ?.( dateSnapshot ) ?? dateSnapshot ;
116
116
117
- const prevSelection = this . #selectionCache. get ( id ) ;
118
- if ( prevSelection === undefined ) {
117
+ const cacheEntry = this . #selectionCache. get ( id ) ;
118
+ if ( cacheEntry === undefined ) {
119
119
this . #selectionCache. set ( id , { value : newSelection } ) ;
120
120
return ;
121
121
}
122
122
123
- if ( ! areValuesDeepEqual ( newSelection , prevSelection . value ) ) {
123
+ if ( ! areValuesDeepEqual ( newSelection , cacheEntry . value ) ) {
124
124
this . #selectionCache. set ( id , { value : newSelection } ) ;
125
125
}
126
126
} ;
0 commit comments