统一全系统资源加载、轻量趋势与缓存恢复
This commit is contained in:
@@ -0,0 +1,26 @@
|
||||
export type GovernanceResource = 'coverage' | 'protocols' | 'changes' | 'candidates' | 'documents';
|
||||
export type GovernanceFreshness = Partial<Record<GovernanceResource, boolean>>;
|
||||
|
||||
export const GOVERNANCE_RESOURCES: GovernanceResource[] = ['coverage', 'protocols', 'changes', 'candidates', 'documents'];
|
||||
|
||||
const TAB_RESOURCES: Record<string, GovernanceResource[]> = {
|
||||
coverage: ['coverage'],
|
||||
protocols: ['protocols'],
|
||||
changes: ['changes', 'candidates'],
|
||||
revisions: ['documents'],
|
||||
};
|
||||
|
||||
export function governanceResourcesForTab(tab: string): GovernanceResource[] {
|
||||
return TAB_RESOURCES[tab] || [];
|
||||
}
|
||||
|
||||
export function markGovernanceResourcesStale(
|
||||
current: GovernanceFreshness,
|
||||
resources: GovernanceResource[] = GOVERNANCE_RESOURCES,
|
||||
): GovernanceFreshness {
|
||||
return resources.reduce((next, resource) => ({ ...next, [resource]: true }), { ...current });
|
||||
}
|
||||
|
||||
export function markGovernanceResourcesFresh(current: GovernanceFreshness, resources: GovernanceResource[]): GovernanceFreshness {
|
||||
return resources.reduce((next, resource) => ({ ...next, [resource]: false }), { ...current });
|
||||
}
|
||||
Reference in New Issue
Block a user