mirror of
https://github.com/pezkuwichain/pwap.git
synced 2026-07-19 18:25:41 +00:00
Add Pezkuwi SDK UI - Polkadot.js Apps clone
- Clone Polkadot.js Apps repository - Update package.json with Pezkuwi branding - Add Pezkuwi endpoint to production chains (wss://pezkuwichain.app:9944) - Create comprehensive README for SDK UI - Set up project structure with all packages Next steps: - Apply Kurdistan colors (Kesk, Sor, Zer, Spi + Black) to UI theme - Replace logos with Pezkuwi branding - Test build and deployment
This commit is contained in:
@@ -0,0 +1,57 @@
|
||||
// Copyright 2017-2025 @polkadot/app-staking authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import { useEffect } from 'react';
|
||||
|
||||
export interface CacheValue<T> {
|
||||
value?: T;
|
||||
}
|
||||
|
||||
type CacheMapKey = `use${'Exposure' | 'Heartbeat'}`;
|
||||
|
||||
type CacheValKey = `use${'ElectedValidators' | 'Points' | 'ValidatorsActive' | 'ValidatorsAll' | 'ValidatorsWaiting'}`;
|
||||
|
||||
const cacheMap: Record<CacheMapKey, Record<string, CacheValue<any>>> = {
|
||||
useExposure: {},
|
||||
useHeartbeat: {}
|
||||
};
|
||||
|
||||
const cacheVal: Record<CacheValKey, CacheValue<any>> = {
|
||||
useElectedValidators: {},
|
||||
usePoints: {},
|
||||
useValidatorsActive: {},
|
||||
useValidatorsAll: {},
|
||||
useValidatorsWaiting: {}
|
||||
};
|
||||
|
||||
export function clearCache (): void {
|
||||
for (const k of Object.keys(cacheMap)) {
|
||||
cacheMap[k as CacheMapKey] = {};
|
||||
}
|
||||
|
||||
for (const k of Object.keys(cacheVal)) {
|
||||
cacheVal[k as CacheValKey] = {};
|
||||
}
|
||||
}
|
||||
|
||||
export function useCacheMap <T> (section: CacheMapKey, id: string, value?: T): T | undefined {
|
||||
// update the cached result on value changes
|
||||
useEffect((): void => {
|
||||
if (value) {
|
||||
cacheMap[section][id] = { value };
|
||||
}
|
||||
}, [id, section, value]);
|
||||
|
||||
return value || (cacheMap[section][id] as CacheValue<T>)?.value;
|
||||
}
|
||||
|
||||
export function useCacheValue <T> (section: CacheValKey, value?: T): T | undefined {
|
||||
// update the cached result on value changes
|
||||
useEffect((): void => {
|
||||
if (value) {
|
||||
cacheVal[section] = { value };
|
||||
}
|
||||
}, [section, value]);
|
||||
|
||||
return value || (cacheVal[section] as CacheValue<T>)?.value;
|
||||
}
|
||||
Reference in New Issue
Block a user