mirror of
https://github.com/Qortal/qapp-core.git
synced 2025-06-15 09:51:21 +00:00
cache refetch bugfix
This commit is contained in:
parent
27641f2cfc
commit
a1b4377f62
@ -77,7 +77,7 @@ const displayedItems = disablePagination ? items : items?.length < (displayedLim
|
|||||||
</React.Fragment>
|
</React.Fragment>
|
||||||
))}
|
))}
|
||||||
>
|
>
|
||||||
{!disablePagination && displayedItems?.length >= (displayedLimit * 3) && (
|
{(disablePagination || (!disablePagination && displayedItems?.length >= limit)) && (
|
||||||
<LazyLoad
|
<LazyLoad
|
||||||
onLoadMore={async () => {
|
onLoadMore={async () => {
|
||||||
await onLoadMore(displayedLimit);
|
await onLoadMore(displayedLimit);
|
||||||
|
@ -137,6 +137,10 @@ export const MemorizedComponent = ({
|
|||||||
const [isLoading, setIsLoading] = useState(list?.length > 0 ? false : true);
|
const [isLoading, setIsLoading] = useState(list?.length > 0 ? false : true);
|
||||||
|
|
||||||
const isListExpired = useCacheStore().isListExpired(listName)
|
const isListExpired = useCacheStore().isListExpired(listName)
|
||||||
|
const isListExpiredRef = useRef<boolean>(true)
|
||||||
|
useEffect(()=> {
|
||||||
|
isListExpiredRef.current = isListExpired
|
||||||
|
}, [isListExpired])
|
||||||
|
|
||||||
const filterOutDeletedResources = useCacheStore((s) => s.filterOutDeletedResources);
|
const filterOutDeletedResources = useCacheStore((s) => s.filterOutDeletedResources);
|
||||||
const deletedResources = useCacheStore((s) => s.deletedResources);
|
const deletedResources = useCacheStore((s) => s.deletedResources);
|
||||||
@ -230,6 +234,7 @@ const addItems = useListStore((s) => s.addItems);
|
|||||||
res(null)
|
res(null)
|
||||||
}, 500);
|
}, 500);
|
||||||
})
|
})
|
||||||
|
|
||||||
lastItemTimestampRef.current = null
|
lastItemTimestampRef.current = null
|
||||||
const parsedParams = {...(JSON.parse(memoizedParams))};
|
const parsedParams = {...(JSON.parse(memoizedParams))};
|
||||||
parsedParams.identifier = generatedIdentifier
|
parsedParams.identifier = generatedIdentifier
|
||||||
@ -259,7 +264,7 @@ const addItems = useListStore((s) => s.addItems);
|
|||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if(!generatedIdentifier) return
|
if(!generatedIdentifier) return
|
||||||
|
|
||||||
if(!isListExpired && !initialized.current) {
|
if(!isListExpiredRef.current && !initialized.current) {
|
||||||
setIsLoading(false)
|
setIsLoading(false)
|
||||||
initialized.current = true
|
initialized.current = true
|
||||||
return
|
return
|
||||||
@ -268,7 +273,7 @@ const addItems = useListStore((s) => s.addItems);
|
|||||||
sessionStorage.removeItem(`scroll-position-${listName}`);
|
sessionStorage.removeItem(`scroll-position-${listName}`);
|
||||||
prevGeneratedIdentifierRef.current = generatedIdentifier
|
prevGeneratedIdentifierRef.current = generatedIdentifier
|
||||||
getResourceList();
|
getResourceList();
|
||||||
}, [getResourceList, isListExpired, generatedIdentifier]); // Runs when dependencies change
|
}, [getResourceList, generatedIdentifier]); // Runs when dependencies change
|
||||||
|
|
||||||
const {elementRef} = useScrollTracker(listName, list?.length > 0, disableScrollTracker);
|
const {elementRef} = useScrollTracker(listName, list?.length > 0, disableScrollTracker);
|
||||||
|
|
||||||
|
@ -89,7 +89,7 @@ export const VerticalPaginatedList = ({
|
|||||||
</React.Fragment>
|
</React.Fragment>
|
||||||
);
|
);
|
||||||
})}
|
})}
|
||||||
{!disablePagination && displayedItems?.length >= (displayedLimit * 3) && (
|
{(disablePagination || (!disablePagination && displayedItems?.length >= limit)) && (
|
||||||
<LazyLoad
|
<LazyLoad
|
||||||
onLoadMore={async () => {
|
onLoadMore={async () => {
|
||||||
await onLoadMore(displayedLimit);
|
await onLoadMore(displayedLimit);
|
||||||
|
@ -26,12 +26,18 @@ export const useIdentifiers = (publicSalt: string, appName: string) => {
|
|||||||
return hashedQortalName
|
return hashedQortalName
|
||||||
}, [publicSalt])
|
}, [publicSalt])
|
||||||
|
|
||||||
|
const hashString = useCallback(async ( string: string, strength: EnumCollisionStrength)=> {
|
||||||
|
const hashedQortalName = await hashWord(string, strength, publicSalt)
|
||||||
|
return hashedQortalName
|
||||||
|
}, [publicSalt])
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
return {
|
return {
|
||||||
buildIdentifier: buildIdentifierFunc,
|
buildIdentifier: buildIdentifierFunc,
|
||||||
buildSearchPrefix: buildSearchPrefixFunc,
|
buildSearchPrefix: buildSearchPrefixFunc,
|
||||||
createSingleIdentifier,
|
createSingleIdentifier,
|
||||||
hashQortalName
|
hashQortalName,
|
||||||
|
hashString
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
import './index.css'
|
import './index.css'
|
||||||
|
export { EnumCollisionStrength } from './utils/encryption';
|
||||||
export { showLoading, dismissToast, showError, showSuccess } from './utils/toast';
|
export { showLoading, dismissToast, showError, showSuccess } from './utils/toast';
|
||||||
export { processText, sanitizedContent, extractComponents, handleClickText} from './utils/text';
|
export { processText, sanitizedContent, extractComponents, handleClickText} from './utils/text';
|
||||||
export { RequestQueueWithPromise } from './utils/queue';
|
export { RequestQueueWithPromise } from './utils/queue';
|
||||||
|
@ -73,7 +73,7 @@ interface CacheState {
|
|||||||
|
|
||||||
export const useCacheStore = create<CacheState>
|
export const useCacheStore = create<CacheState>
|
||||||
((set, get) => ({
|
((set, get) => ({
|
||||||
searchCacheExpiryDuration: 5 * 60 * 1000,
|
searchCacheExpiryDuration: 0.1 * 60 * 1000,
|
||||||
resourceCacheExpiryDuration: 30 * 60 * 1000,
|
resourceCacheExpiryDuration: 30 * 60 * 1000,
|
||||||
resourceCache: {},
|
resourceCache: {},
|
||||||
searchCache: {},
|
searchCache: {},
|
||||||
|
Loading…
x
Reference in New Issue
Block a user