- Home: "Your five minutes": a rotating Observe/Interpret/Apply prompt on the passage whose matching note is thinnest in your own words, a 5:00 clock and a box that appends to that note. Pasting is blocked; sessions show in Insights. - Study: a Reading list tab (R) for the study: books and articles to consult, with a note and a tick; merges across devices. - Starting a study from a reading-plan day now uses the notes template you last picked when starting a study by hand (logic moved to utils/planStudy.js). Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
54 lines
3.5 KiB
JavaScript
54 lines
3.5 KiB
JavaScript
// Daily five minutes: one short prompt a day, on a passage from your studies where that kind of note is thinnest.
|
||
// What you write is added to the matching note (Observe, Interpret or Apply) and counts as your own words.
|
||
import { formatChunkReference, getChunkVerseEntries } from './bibleUtils.jsx';
|
||
import { ownWords } from './ownWork.js';
|
||
|
||
export const MINUTES = 5;
|
||
|
||
export const PROMPTS = [
|
||
{ field: 'observation', text: 'Read the passage slowly. Write three things you notice: a repeated word, who is speaking, something that surprises you.' },
|
||
{ field: 'interpretation', text: 'What would the first hearers have understood? Write one or two sentences about the situation they were in.' },
|
||
{ field: 'application', text: 'Write one thing you will believe differently, and one thing you will do, because of this passage.' },
|
||
{ field: 'observation', text: 'What does this passage say about God? Say it using only what the text itself says.' },
|
||
{ field: 'interpretation', text: 'How does this passage connect to what comes just before or after it? Write how it fits.' },
|
||
{ field: 'application', text: 'Who is one person this passage speaks to? Write what you would say to them.' },
|
||
{ field: 'observation', text: 'Read it aloud. Which word or phrase stands out most? Write down why.' },
|
||
];
|
||
export const FIELD_NAMES = { observation: 'Observe', interpretation: 'Interpret', application: 'Apply' };
|
||
|
||
const dayNumber = (now) => { const d = new Date(now); return Math.floor(Date.UTC(d.getFullYear(), d.getMonth(), d.getDate()) / 86400000); };
|
||
export const promptFor = (now = Date.now()) => PROMPTS[dayNumber(now) % PROMPTS.length];
|
||
const sameDay = (a, b) => new Date(a).toDateString() === new Date(b).toDateString();
|
||
|
||
// Did you already do your five minutes today?
|
||
export function doneToday(projects, now = Date.now()) {
|
||
return (projects ?? []).some((p) => (p?.chapters ?? []).some((ch) => (ch.chunks ?? []).some((c) => (c.fiveMinutes ?? []).some((f) => sameDay(f.at, now)))));
|
||
}
|
||
|
||
// Today's prompt and the passage to use it on: the chunk whose notes for that prompt have the fewest words of
|
||
// your own (oldest first on a tie). null when there are no studies, or today's five minutes are done.
|
||
export function pickDaily(projects, now = Date.now()) {
|
||
if (doneToday(projects, now)) return null;
|
||
const prompt = promptFor(now);
|
||
const all = (projects ?? []).flatMap((project) => (project?.chapters ?? []).flatMap((chapter, chapterIndex) => (chapter.chunks ?? []).map((chunk) => ({ project, chapterIndex, chunk }))));
|
||
const [best] = all.sort((a, b) => ownWords(a.chunk, prompt.field) - ownWords(b.chunk, prompt.field) || (a.chunk.editedAt ?? 0) - (b.chunk.editedAt ?? 0));
|
||
if (!best) return null;
|
||
return {
|
||
prompt, projectId: best.project.id, projectTitle: best.project.title, chunk: best.chunk,
|
||
reference: formatChunkReference(best.project, best.chapterIndex, best.chunk, '–'),
|
||
verses: getChunkVerseEntries(best.project, best.chapterIndex, best.chunk).map((v) => ({ number: v.number, text: v.text })),
|
||
};
|
||
}
|
||
|
||
const marker = (now) => `— five minutes, ${new Date(now).toLocaleDateString([], { month: 'short', day: 'numeric' })} —`;
|
||
|
||
// The patch that adds what you wrote to the chunk (below what's already there) and records the session.
|
||
export function dailyPatch(chunk, field, text, now = Date.now()) {
|
||
const added = text.trim();
|
||
const have = (chunk[field] ?? '').replace(/\s+$/, '');
|
||
return {
|
||
[field]: have ? `${have}\n\n${marker(now)}\n${added}` : added,
|
||
fiveMinutes: [...(chunk.fiveMinutes ?? []), { at: now, field }],
|
||
};
|
||
}
|