@@ -9,7 +9,6 @@ import { getWebServerEndpoint } from "@/util/endpoints";
99import { fetch } from "@/util/fetchutil" ;
1010import { fireAndForget } from "@/util/util" ;
1111import { atom , Atom , Getter , PrimitiveAtom , Setter , useAtomValue } from "jotai" ;
12- import { useEffect } from "react" ;
1312import { globalStore } from "./jotaiStore" ;
1413import { ObjectService } from "./services" ;
1514
@@ -21,8 +20,6 @@ type WaveObjectDataItemType<T extends WaveObj> = {
2120type WaveObjectValue < T extends WaveObj > = {
2221 pendingPromise : Promise < T > ;
2322 dataAtom : PrimitiveAtom < WaveObjectDataItemType < T > > ;
24- refCount : number ;
25- holdTime : number ;
2623} ;
2724
2825function splitORef ( oref : string ) : [ string , string ] {
@@ -151,12 +148,6 @@ function callBackendService(service: string, method: string, args: any[], noUICo
151148
152149const waveObjectValueCache = new Map < string , WaveObjectValue < any > > ( ) ;
153150
154- function clearWaveObjectCache ( ) {
155- waveObjectValueCache . clear ( ) ;
156- }
157-
158- const defaultHoldTime = 5000 ; // 5-seconds
159-
160151function reloadWaveObject < T extends WaveObj > ( oref : string ) : Promise < T > {
161152 let wov = waveObjectValueCache . get ( oref ) ;
162153 if ( wov === undefined ) {
@@ -171,7 +162,7 @@ function reloadWaveObject<T extends WaveObj>(oref: string): Promise<T> {
171162}
172163
173164function createWaveValueObject < T extends WaveObj > ( oref : string , shouldFetch : boolean ) : WaveObjectValue < T > {
174- const wov = { pendingPromise : null , dataAtom : null , refCount : 0 , holdTime : Date . now ( ) + 5000 } ;
165+ const wov = { pendingPromise : null , dataAtom : null } ;
175166 wov . dataAtom = atom ( { value : null , loading : true } ) ;
176167 if ( ! shouldFetch ) {
177168 return wov ;
@@ -210,7 +201,6 @@ function getWaveObjectValue<T extends WaveObj>(oref: string, createIfMissing = t
210201
211202function loadAndPinWaveObject < T extends WaveObj > ( oref : string ) : Promise < T > {
212203 const wov = getWaveObjectValue < T > ( oref ) ;
213- wov . refCount ++ ;
214204 if ( wov . pendingPromise == null ) {
215205 const dataValue = globalStore . get ( wov . dataAtom ) ;
216206 return Promise . resolve ( dataValue . value ) ;
@@ -260,12 +250,6 @@ function isWaveObjectNullAtom(oref: string): Atom<boolean> {
260250
261251function useWaveObjectValue < T extends WaveObj > ( oref : string ) : [ T , boolean ] {
262252 const wov = getWaveObjectValue < T > ( oref ) ;
263- useEffect ( ( ) => {
264- wov . refCount ++ ;
265- return ( ) => {
266- wov . refCount -- ;
267- } ;
268- } , [ oref ] ) ;
269253 const atomVal = useAtomValue ( wov . dataAtom ) ;
270254 return [ atomVal . value , atomVal . loading ] ;
271255}
@@ -291,7 +275,6 @@ function updateWaveObject(update: WaveObjUpdate) {
291275 console . log ( "WaveObj updated" , oref ) ;
292276 globalStore . set ( wov . dataAtom , { value : update . obj , loading : false } ) ;
293277 }
294- wov . holdTime = Date . now ( ) + defaultHoldTime ;
295278 return ;
296279}
297280
@@ -301,15 +284,6 @@ function updateWaveObjects(vals: WaveObjUpdate[]) {
301284 }
302285}
303286
304- function cleanWaveObjectCache ( ) {
305- const now = Date . now ( ) ;
306- for ( const [ oref , wov ] of waveObjectValueCache ) {
307- if ( wov . refCount == 0 && wov . holdTime < now ) {
308- waveObjectValueCache . delete ( oref ) ;
309- }
310- }
311- }
312-
313287// gets the value of a WaveObject from the cache.
314288// should provide getFn if it is available (e.g. inside of a jotai atom)
315289// otherwise it will use the globalStore.get function
@@ -342,8 +316,6 @@ function setObjectValue<T extends WaveObj>(value: T, setFn?: Setter, pushToServe
342316
343317export {
344318 callBackendService ,
345- cleanWaveObjectCache ,
346- clearWaveObjectCache ,
347319 getObjectValue ,
348320 getWaveObjectAtom ,
349321 getWaveObjectLoadingAtom ,
0 commit comments