Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -9,20 +9,27 @@
let cacheStatus: { lastUpdated: number; isStale: boolean; itemCount: number };

onMount(async () => {
console.log('Component mounted, starting to load eVaults...');
try {
loading = true;
console.log('Loading state set to true');
await loadEVaults();
cacheStatus = EVaultService.getCacheStatus();
console.log('Loaded eVaults:', evaults.length, 'items');
} catch (err) {
error = 'Failed to load eVaults';
console.error(err);
console.error('Error in onMount:', err);
} finally {
loading = false;
console.log('Loading state set to false');
}
});

async function loadEVaults() {
console.log('loadEVaults called');
try {
evaults = await EVaultService.getEVaults();
console.log('EVaultService returned:', evaults.length, 'items');
cacheStatus = EVaultService.getCacheStatus();
} catch (err) {
console.error('Error loading eVaults:', err);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,9 @@ class CacheService {

async getCachedEVaults(): Promise<EVault[]> {
if (typeof window !== 'undefined') {
// In browser, return empty array - caching only works on server
return [];
// In browser, return null to indicate we need to fetch from server
// This prevents showing "No eVaults found" prematurely
return null as any;
}

await this.init();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,12 @@ export class EVaultService {
* Returns cached data immediately, refreshes in background if stale
*/
static async getEVaults(): Promise<EVault[]> {
// Check if cache is stale
// In browser, always fetch from server since caching doesn't work here
if (typeof window !== 'undefined') {
return this.fetchEVaultsDirectly();
}

// On server, use caching
const isStale = await cacheService.isCacheStale();

if (isStale) {
Expand Down
Loading