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