removed config cache

This commit is contained in:
tapframe 2025-12-30 03:59:24 +05:30
parent 53a572ecac
commit 183d30c720
2 changed files with 11 additions and 12 deletions

View file

@ -9,7 +9,7 @@ export const useLibrary = () => {
const [libraryItems, setLibraryItems] = useState<StreamingContent[]>([]);
const [loading, setLoading] = useState(true);
// Load library items from storage
//Load library items from storage
const loadLibraryItems = useCallback(async () => {
try {
setLoading(true);
@ -24,7 +24,7 @@ export const useLibrary = () => {
storedItems = legacy;
}
}
if (storedItems) {
const parsedItems = JSON.parse(storedItems);
// Handle both array and object formats
@ -94,7 +94,7 @@ export const useLibrary = () => {
// Toggle item in library
const toggleLibrary = useCallback(async (item: StreamingContent) => {
const exists = libraryItems.some(i => i.id === item.id);
if (exists) {
return await removeFromLibrary(item.id);
} else {

View file

@ -20,17 +20,17 @@ export interface SettingsConfig {
}
class ConfigService {
private configCache: Record<string, any> = {};
async getConfig<T>(key: string): Promise<T | null> {
// Return memory cache if available (fetch once per session)
if (this.configCache[key]) {
return this.configCache[key] as T;
}
try {
console.log(`[ConfigService] Fetching config for key: ${key}`);
const response = await fetch(`${CAMPAIGN_API_URL}/api/config?key=${key}`);
const timestamp = Date.now();
const response = await fetch(`${CAMPAIGN_API_URL}/api/config?key=${key}&t=${timestamp}`, {
headers: {
'Cache-Control': 'no-cache, no-store, must-revalidate',
'Pragma': 'no-cache',
'Expires': '0'
}
});
if (!response.ok) {
return null;
@ -43,7 +43,6 @@ class ConfigService {
return null;
}
this.configCache[key] = data;
return data as T;
} catch (error) {
console.warn('[ConfigService] Error fetching config:', error);