fix(memory): support selected dates and separate prompt titles
This commit is contained in:
1 parent
80ad1932e1
commit
88edf64e3b
8 files changed
+42
-37
No files matched your search
+8
-6
@@ -1,7 +1,9 @@
|
||||
/* Life OS reliability and productivity add-ons. */
|
||||
(() => {
|
||||
const DRAFT_KEY = 'lifeos_today_draft_v1';
|
||||
const APP_VERSION = '1.4.2';
|
||||
const localDay = () => { const d = new Date(); return `${d.getFullYear()}-${String(d.getMonth()+1).padStart(2,'0')}-${String(d.getDate()).padStart(2,'0')}`; };
|
||||
const escapeHtml = value => String(value || '').replace(/[&<>]/g, char => ({ '&': '&', '<': '<', '>': '>' }[char]));
|
||||
const APP_VERSION = '1.4.3';
|
||||
const appIds = ['today', 'timeline', 'museum', 'insights', 'profile', 'tasks', 'calendar', 'system'];
|
||||
const t = (key, values) => LifeI18n.t(key, values);
|
||||
|
||||
@@ -9,11 +11,11 @@
|
||||
try { return JSON.parse(localStorage.getItem(DRAFT_KEY)); } catch { return null; }
|
||||
}
|
||||
function saveDraft(text) {
|
||||
localStorage.setItem(DRAFT_KEY, JSON.stringify({ date: new Date().toISOString().slice(0, 10), text, updatedAt: new Date().toISOString() }));
|
||||
localStorage.setItem(DRAFT_KEY, JSON.stringify({ date: (typeof todayTargetDate !== 'undefined' && todayTargetDate) || localDay(), text, updatedAt: new Date().toISOString() }));
|
||||
}
|
||||
function restoreDraft(entry) {
|
||||
const draft = readDraft();
|
||||
const today = new Date().toISOString().slice(0, 10);
|
||||
const today = (typeof todayTargetDate !== 'undefined' && todayTargetDate) || localDay();
|
||||
if (!draft || draft.date !== today || !draft.text || entry.value) return;
|
||||
entry.value = draft.text;
|
||||
entry.dispatchEvent(new Event('input', { bubbles: true }));
|
||||
@@ -29,7 +31,7 @@
|
||||
function wireLanguageControl() { /* The System renderer owns this control. */ }
|
||||
function clearDraftAfterSave() {
|
||||
setTimeout(() => {
|
||||
const today = new Date().toISOString().slice(0, 10);
|
||||
const today = (typeof todayTargetDate !== 'undefined' && todayTargetDate) || localDay();
|
||||
try {
|
||||
const saved = JSON.parse(localStorage.getItem('lifeos_memories') || '[]').some(m => m.date === today);
|
||||
if (saved) localStorage.removeItem(DRAFT_KEY);
|
||||
@@ -50,8 +52,8 @@
|
||||
let memories = [];
|
||||
try { memories = JSON.parse(localStorage.getItem('lifeos_memories') || '[]'); } catch {}
|
||||
const query = input.value.trim().toLowerCase();
|
||||
const found = memories.filter(m => !query || [m.filmTitle, m.text, m.mood, m.date].join(' ').toLowerCase().includes(query)).slice(0, 8);
|
||||
results.innerHTML = found.length ? found.map(m => `<button data-id="${m.id}"><small>${m.date} · ${t(`weather.${m.mood || 'cloudy'}`).toUpperCase()}</small><strong>${m.filmTitle || t('addon.untitled')}</strong><span>${(m.text || t('timeline.noNote')).replace(/[&<>]/g, c => ({'&':'&','<':'<','>':'>'}[c]))}</span></button>`).join('') : `<div class="lifeos-search-empty">${t('addon.noResults')}</div>`;
|
||||
const found = memories.filter(m => !query || [m.title, m.filmTitle, m.text, m.mood, m.date].join(' ').toLowerCase().includes(query)).slice(0, 8);
|
||||
results.innerHTML = found.length ? found.map(m => `<button data-id="${m.id}"><small>${m.date} · ${t(`weather.${m.mood || 'cloudy'}`).toUpperCase()}</small><strong>${escapeHtml(m.title || m.text?.trim().split('\n')[0].slice(0, 64) || t('timeline.untitled'))}</strong><span>${(m.text || t('timeline.noNote')).replace(/[&<>]/g, c => ({'&':'&','<':'<','>':'>'}[c]))}</span></button>`).join('') : `<div class="lifeos-search-empty">${t('addon.noResults')}</div>`;
|
||||
results.querySelectorAll('button').forEach(button => button.addEventListener('click', () => { closeSearch(); openApp('timeline'); setTimeout(() => detail(button.dataset.id), 20); }));
|
||||
};
|
||||
input.addEventListener('input', render);
|
||||
|
||||
Reference in new issue
Block a user