|
1 | 1 | // GitHub API configuration |
2 | 2 | const GITHUB_API_BASE = 'https://api.github.com'; |
3 | 3 |
|
4 | | -// Cache configuration (15 minutes default) |
5 | | -const CACHE_DURATION_MS = 15 * 60 * 1000; |
| 4 | +// Cache configuration (1 hour default) |
| 5 | +const CACHE_DURATION_MS = 60 * 60 * 1000; |
6 | 6 | const CACHE_KEY_PREFIX = 'github_cache_'; |
7 | 7 |
|
8 | 8 | // State |
@@ -219,9 +219,11 @@ export async function fetchRepositoryData(repo, openOnly = false) { |
219 | 219 | // Check cache first |
220 | 220 | const cached = getCachedData(repo, openOnly); |
221 | 221 | if (cached) { |
| 222 | + console.log(`Using cache for ${repo}`); |
222 | 223 | return cached; |
223 | 224 | } |
224 | 225 |
|
| 226 | + console.log(`Fetching fresh data for ${repo}`); |
225 | 227 | try { |
226 | 228 | const state = openOnly ? 'open' : 'all'; |
227 | 229 | const issuesAndPRsUrl = `${GITHUB_API_BASE}/repos/${owner}/${repoName}/issues?state=${state}&per_page=100`; |
@@ -461,6 +463,21 @@ export function getCacheAgeText(repoData) { |
461 | 463 | return `📦 Cached ${timeAgo} (expires in ${remainingMinutes}m)`; |
462 | 464 | } |
463 | 465 |
|
| 466 | +/** |
| 467 | + * Handle force refresh - clears cache if checkbox is checked |
| 468 | + */ |
| 469 | +export function handleForceRefresh(repos) { |
| 470 | + const forceRefresh = document.getElementById('forceRefresh'); |
| 471 | + if (forceRefresh && forceRefresh.checked) { |
| 472 | + const clearedCount = clearCache(repos); |
| 473 | + console.log(`Force refresh: cleared ${clearedCount} cache entries for`, repos); |
| 474 | + // Uncheck the box after clearing |
| 475 | + forceRefresh.checked = false; |
| 476 | + return true; |
| 477 | + } |
| 478 | + return false; |
| 479 | +} |
| 480 | + |
464 | 481 | /** |
465 | 482 | * Get initial repositories (from query string or textarea) |
466 | 483 | */ |
@@ -522,15 +539,13 @@ export function setupLoadButton(onLoad) { |
522 | 539 | url.searchParams.set('repos', repos.join(',')); |
523 | 540 | window.history.pushState({}, '', url); |
524 | 541 |
|
525 | | - // Clear cache for selected repos if force refresh is checked |
526 | | - if (forceRefresh && forceRefresh.checked) { |
527 | | - clearCache(repos); |
528 | | - } |
| 542 | + // Handle force refresh |
| 543 | + handleForceRefresh(repos); |
529 | 544 |
|
530 | 545 | await onLoad(repos); |
531 | 546 |
|
532 | | - // Update cache status after loading |
533 | | - updateCacheStatus(); |
| 547 | + // Update cache status after loading (with small delay to ensure cache writes complete) |
| 548 | + setTimeout(() => updateCacheStatus(), 100); |
534 | 549 | }); |
535 | 550 |
|
536 | 551 | // Setup share button |
|
0 commit comments