Support dash separator in chore name parsing (Chris - Dishes)
This commit is contained in:
@@ -21,23 +21,26 @@ interface ChoreItem {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function parseChore(item: { uid: string; summary: string; status: string }): ChoreItem {
|
function parseChore(item: { uid: string; summary: string; status: string }): ChoreItem {
|
||||||
// "Becca: Do dishes" → person=Becca, task=Do dishes
|
// Supports "Becca: Dishes", "Chris - Dishes", or just "Dishes"
|
||||||
// "Take out trash" → person=null, task=Take out trash
|
|
||||||
const colonIdx = item.summary.indexOf(':');
|
|
||||||
let person: string | null = null;
|
let person: string | null = null;
|
||||||
let task = item.summary;
|
let task = item.summary;
|
||||||
let color = FALLBACK_COLOR;
|
let color = FALLBACK_COLOR;
|
||||||
|
|
||||||
if (colonIdx > 0 && colonIdx < 20) {
|
// Try splitting on ":" or " - "
|
||||||
const prefix = item.summary.slice(0, colonIdx).trim().toLowerCase();
|
for (const sep of [':', ' - ', ' – ']) {
|
||||||
|
const idx = item.summary.indexOf(sep);
|
||||||
|
if (idx > 0 && idx < 20) {
|
||||||
|
const prefix = item.summary.slice(0, idx).trim().toLowerCase();
|
||||||
if (PEOPLE[prefix]) {
|
if (PEOPLE[prefix]) {
|
||||||
person = item.summary.slice(0, colonIdx).trim();
|
person = item.summary.slice(0, idx).trim();
|
||||||
task = item.summary.slice(colonIdx + 1).trim();
|
task = item.summary.slice(idx + sep.length).trim();
|
||||||
color = PEOPLE[prefix];
|
color = PEOPLE[prefix];
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Also check if any person name appears anywhere in summary
|
// Fallback: check if any person name appears anywhere
|
||||||
if (!person) {
|
if (!person) {
|
||||||
for (const [name, c] of Object.entries(PEOPLE)) {
|
for (const [name, c] of Object.entries(PEOPLE)) {
|
||||||
if (item.summary.toLowerCase().includes(name)) {
|
if (item.summary.toLowerCase().includes(name)) {
|
||||||
|
|||||||
Reference in New Issue
Block a user