Remove: 캘린더 캐싱 제거, 매번 최신 데이터 불러오기
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
9923ef8989
commit
cd11300f8f
@ -6,7 +6,6 @@
|
||||
'use strict';
|
||||
|
||||
var APPS_SCRIPT_URL = 'https://script.google.com/macros/s/AKfycbwoaoSmEskbJod4gR5NjLnpWSkhIDUYaGBYk0y1Q865TzaJ4gctSrTOWXxRnVa7J9AASA/exec';
|
||||
var CACHE_TTL = 30 * 60 * 1000; // 30분
|
||||
|
||||
var currentYear, currentMonth;
|
||||
var calTitle = document.getElementById('calTitle');
|
||||
@ -35,20 +34,13 @@
|
||||
function renderCalendar() {
|
||||
updateTitle();
|
||||
|
||||
var cached = getCache(currentYear, currentMonth);
|
||||
if (cached !== null) {
|
||||
buildGrid(cached);
|
||||
} else {
|
||||
// 즉시 빈 그리드 렌더링 + 로딩 표시
|
||||
buildGrid([]);
|
||||
showLoading();
|
||||
fetchBookedDates(currentYear, currentMonth, function(dates) {
|
||||
setCache(currentYear, currentMonth, dates);
|
||||
buildGrid(dates);
|
||||
hideLoading();
|
||||
prefetchAdjacent();
|
||||
});
|
||||
}
|
||||
// 매번 새로 불러오기
|
||||
buildGrid([]);
|
||||
showLoading();
|
||||
fetchBookedDates(currentYear, currentMonth, function(dates) {
|
||||
buildGrid(dates);
|
||||
hideLoading();
|
||||
});
|
||||
}
|
||||
|
||||
function showLoading() {
|
||||
@ -72,38 +64,6 @@
|
||||
if (overlay) overlay.remove();
|
||||
}
|
||||
|
||||
function prefetchAdjacent() {
|
||||
var nextM = currentMonth + 1, nextY = currentYear;
|
||||
if (nextM > 12) { nextM = 1; nextY++; }
|
||||
if (getCache(nextY, nextM) === null) {
|
||||
fetchBookedDates(nextY, nextM, function(dates) {
|
||||
setCache(nextY, nextM, dates);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
// --- localStorage 캐싱 ---
|
||||
function cacheKey(y, m) { return 'mingle_cal_' + y + '_' + m; }
|
||||
|
||||
function getCache(y, m) {
|
||||
try {
|
||||
var raw = localStorage.getItem(cacheKey(y, m));
|
||||
if (!raw) return null;
|
||||
var obj = JSON.parse(raw);
|
||||
if (Date.now() - obj.ts > CACHE_TTL) {
|
||||
localStorage.removeItem(cacheKey(y, m));
|
||||
return null;
|
||||
}
|
||||
return obj.dates;
|
||||
} catch (e) { return null; }
|
||||
}
|
||||
|
||||
function setCache(y, m, dates) {
|
||||
try {
|
||||
localStorage.setItem(cacheKey(y, m), JSON.stringify({ dates: dates, ts: Date.now() }));
|
||||
} catch (e) { /* quota exceeded 등 무시 */ }
|
||||
}
|
||||
|
||||
// --- 제목 업데이트 ---
|
||||
function updateTitle() {
|
||||
var lang = (window.i18n && window.i18n.currentLang) || 'ko';
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user