fix(project): keep sidebar on week navigation
This commit is contained in:
+31
-16
@@ -8,24 +8,36 @@
|
||||
"use strict";
|
||||
|
||||
// ── 공용 fetch ─────────────────────────────────────────────
|
||||
const navigationSavers = [];
|
||||
let navigationWrites = 0;
|
||||
// 오른쪽 회의록을 바꾸기 전에 입력 칸 저장을 끝낸다. 실패하면 기존 화면을 유지한다.
|
||||
window.PJFlushForNavigation = async function () {
|
||||
if (document.activeElement && document.activeElement.blur) document.activeElement.blur();
|
||||
await Promise.all(navigationSavers.map(function (flush) { return flush(); }));
|
||||
if (navigationWrites) throw new Error("저장 중입니다. 저장이 끝난 뒤 다시 이동해 주세요.");
|
||||
};
|
||||
// extra.keepalive — 페이지를 떠나는 중에도 요청을 보내 달라고 브라우저에 부탁(보장은 아님, createFieldSaver 참고)
|
||||
async function api(method, url, body, extra) {
|
||||
const opts = { method, headers: { "Content-Type": "application/json" } };
|
||||
if (body !== undefined) opts.body = JSON.stringify(body);
|
||||
if (extra && extra.keepalive) opts.keepalive = true;
|
||||
const res = await fetch(url, opts);
|
||||
if (!res.ok) {
|
||||
let msg = res.statusText, detail = null;
|
||||
try { detail = (await res.json()).detail; } catch (_) {}
|
||||
if (typeof detail === "string") msg = detail;
|
||||
else if (detail && detail.message) msg = detail.message;
|
||||
const err = new Error(msg);
|
||||
err.status = res.status; // 403(권한 없음)·404 를 일시 오류와 구분하려고
|
||||
err.detail = detail;
|
||||
throw err;
|
||||
}
|
||||
if (res.status === 204) return null;
|
||||
return res.json();
|
||||
const writing = method !== "GET";
|
||||
if (writing) navigationWrites++;
|
||||
try {
|
||||
const opts = { method, headers: { "Content-Type": "application/json" } };
|
||||
if (body !== undefined) opts.body = JSON.stringify(body);
|
||||
if (extra && extra.keepalive) opts.keepalive = true;
|
||||
const res = await fetch(url, opts);
|
||||
if (!res.ok) {
|
||||
let msg = res.statusText, detail = null;
|
||||
try { detail = (await res.json()).detail; } catch (_) {}
|
||||
if (typeof detail === "string") msg = detail;
|
||||
else if (detail && detail.message) msg = detail.message;
|
||||
const err = new Error(msg);
|
||||
err.status = res.status; // 403(권한 없음)·404 를 일시 오류와 구분하려고
|
||||
err.detail = detail;
|
||||
throw err;
|
||||
}
|
||||
if (res.status === 204) return null;
|
||||
return await res.json();
|
||||
} finally { if (writing) navigationWrites--; }
|
||||
}
|
||||
|
||||
function el(id) { return document.getElementById(id); }
|
||||
@@ -347,6 +359,7 @@
|
||||
if (warn && e) { e.preventDefault(); e.returnValue = ""; }
|
||||
return warn;
|
||||
}
|
||||
navigationSavers.push(flushAll);
|
||||
return {
|
||||
track: track, queue: queue, flush: flush, flushAll: flushAll, isDirty: isDirty, anyDirty: anyDirty,
|
||||
prune: prune, onBeforeUnload: onBeforeUnload,
|
||||
@@ -8338,6 +8351,8 @@
|
||||
let failures = 0;
|
||||
let timer = null;
|
||||
async function syncOnce() {
|
||||
// 회의록 패널을 보는 동안은 이전 프로젝트 화면의 자동 갱신이 왼쪽 메뉴를 다시 만들지 않게 한다.
|
||||
if (document.querySelector(".pj-meeting-panel-host")) return;
|
||||
if (syncing || observed === null || observed === applied) return;
|
||||
syncing = true;
|
||||
const target = observed;
|
||||
|
||||
Reference in New Issue
Block a user