haufen sachen

This commit is contained in:
th committed 2026-04-08 22:46:48 +02:00
1 parent 416ca9e854
commit e6243701a3
20 files changed
+1562 -116

No files matched your search

+43 -3
View File
@@ -16,7 +16,7 @@ import { undo, canUndo } from './modules/undo.js';
import { openGallery, closeGallery } from './modules/gallery.js';
import { refreshTasksView, openTasks, closeTasks } from './modules/tasks.js';
import { openCalendar, closeCalendar, refreshCalendar } from './modules/calendar.js';
import { startBackgroundSync, triggerSync } from './modules/caldav.js';
import { startBackgroundSync, triggerSync, loadSettings as loadCaldavSettings } from './modules/caldav.js';
// ── Global API (for inline onclick handlers and cross-module calls) ──
@@ -28,13 +28,14 @@ window._closeTasks = closeTasks;
window._renderBoard = renderBoard;
window._openCalendar = openCalendar;
window._triggerSync = triggerSync;
window._loadCaldavSettings = loadCaldavSettings;
window._renderTagBar = renderTagBar;
window._showContextMenu = showContextMenu;
window._ungroupCard = ungroupCard;
window._getSelectedIds = getSelectedIds;
window._clearSelection = clearSelection;
window._refreshTasks = refreshTasksView;
window._reloadAll = async () => { state.cards = await api('api/cards'); renderBoard(); refreshCalendar(); };
window._reloadAll = async () => { state.cards = await api('api/cards') || []; renderBoard(); refreshCalendar(); };
window._extractToCard = async (text) => {
if (!text?.trim()) return;
const lines = text.trim().split('\n');
@@ -52,10 +53,49 @@ window._extractToCard = async (text) => {
// ── Data loading ──
const CARDS_CACHE_KEY = 'hyprcrd-cards-cache';
function getCachedCards() {
try { return JSON.parse(localStorage.getItem(CARDS_CACHE_KEY) || '[]'); } catch { return []; }
}
function setCachedCards(cards) {
try {
const slim = cards.map(c => ({ id: c.id, title: c.title, color: c.color, tags: c.tags, bucket_id: c.bucket_id, bucket_name: c.bucket_name, parent_id: c.parent_id, position: c.position, created_at: c.created_at, updated_at: c.updated_at, due_date: c.due_date, caldav_uid: c.caldav_uid, caldav_rrule: c.caldav_rrule }));
localStorage.setItem(CARDS_CACHE_KEY, JSON.stringify(slim));
} catch {}
}
async function loadCards() {
state.cards = await api('api/cards');
// Phase 0: Show cached cards instantly (from previous session)
const cached = getCachedCards();
if (cached.length) {
state.cards = cached.map(c => ({ ...c, body: null }));
updateSortUI();
renderBoard();
}
// Phase 1: Load metadata → update board with fresh titles/tags/dates
const meta = await api('api/cards/meta');
if (!meta) return;
state.cards = meta.map(c => ({ ...c, body: null }));
setCachedCards(meta);
updateSortUI();
renderBoard();
// Phase 2: Load full cards in batches → replace spinners with content
const batchSize = 25;
for (let i = 0; i < meta.length; i += batchSize) {
const batch = meta.slice(i, i + batchSize);
const ids = batch.map(c => c.id).join(',');
const full = await api('api/cards?ids=' + ids);
if (!full) continue;
for (const card of full) {
const idx = state.cards.findIndex(c => c.id === card.id);
if (idx >= 0) state.cards[idx] = card;
}
renderBoard();
}
}
// ── Help ──