mirror of
https://github.com/tapframe/NuvioStreaming.git
synced 2026-04-21 08:41:57 +00:00
removed config cache
This commit is contained in:
parent
53a572ecac
commit
183d30c720
2 changed files with 11 additions and 12 deletions
|
|
@ -9,7 +9,7 @@ export const useLibrary = () => {
|
||||||
const [libraryItems, setLibraryItems] = useState<StreamingContent[]>([]);
|
const [libraryItems, setLibraryItems] = useState<StreamingContent[]>([]);
|
||||||
const [loading, setLoading] = useState(true);
|
const [loading, setLoading] = useState(true);
|
||||||
|
|
||||||
// Load library items from storage
|
//Load library items from storage
|
||||||
const loadLibraryItems = useCallback(async () => {
|
const loadLibraryItems = useCallback(async () => {
|
||||||
try {
|
try {
|
||||||
setLoading(true);
|
setLoading(true);
|
||||||
|
|
@ -24,7 +24,7 @@ export const useLibrary = () => {
|
||||||
storedItems = legacy;
|
storedItems = legacy;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (storedItems) {
|
if (storedItems) {
|
||||||
const parsedItems = JSON.parse(storedItems);
|
const parsedItems = JSON.parse(storedItems);
|
||||||
// Handle both array and object formats
|
// Handle both array and object formats
|
||||||
|
|
@ -94,7 +94,7 @@ export const useLibrary = () => {
|
||||||
// Toggle item in library
|
// Toggle item in library
|
||||||
const toggleLibrary = useCallback(async (item: StreamingContent) => {
|
const toggleLibrary = useCallback(async (item: StreamingContent) => {
|
||||||
const exists = libraryItems.some(i => i.id === item.id);
|
const exists = libraryItems.some(i => i.id === item.id);
|
||||||
|
|
||||||
if (exists) {
|
if (exists) {
|
||||||
return await removeFromLibrary(item.id);
|
return await removeFromLibrary(item.id);
|
||||||
} else {
|
} else {
|
||||||
|
|
|
||||||
|
|
@ -20,17 +20,17 @@ export interface SettingsConfig {
|
||||||
}
|
}
|
||||||
|
|
||||||
class ConfigService {
|
class ConfigService {
|
||||||
private configCache: Record<string, any> = {};
|
|
||||||
|
|
||||||
async getConfig<T>(key: string): Promise<T | null> {
|
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 {
|
try {
|
||||||
console.log(`[ConfigService] Fetching config for key: ${key}`);
|
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) {
|
if (!response.ok) {
|
||||||
return null;
|
return null;
|
||||||
|
|
@ -43,7 +43,6 @@ class ConfigService {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
this.configCache[key] = data;
|
|
||||||
return data as T;
|
return data as T;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.warn('[ConfigService] Error fetching config:', error);
|
console.warn('[ConfigService] Error fetching config:', error);
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue