From b02c19615c189fa96c8822a9a39e07b7c6f9e2c0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?deniz=20g=C3=B6k=C3=A7in?= <33603535+dgokcin@users.noreply.github.com> Date: Mon, 27 Jan 2025 21:42:31 +0100 Subject: [PATCH] feat(activities): improve reminder activity configuration and detection MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - change reminder emoji from 🎯 to ⏰ for better visual representation - add 'reminder' keyword to english variants - add findMatchingActivity helper function for consistent activity detection --- Code.js | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/Code.js b/Code.js index 5db125b..adb4229 100644 --- a/Code.js +++ b/Code.js @@ -132,8 +132,8 @@ const activities = { category: "wellness", }, action: { - emoji: "🎯", - variants: { en: [], tr: ["aksiyon al"] }, + emoji: "⏰", + variants: { en: ["reminder"], tr: ["aksiyon al"] }, category: "reminders", }, dinner: { @@ -217,6 +217,18 @@ function getEventColor(input) { return activity ? categoryColors[activity.category] : null; } +const findMatchingActivity = (input) => { + const lowerInput = input.toLowerCase(); + return Object.values(activities).find((activity) => + Object.entries(activity.variants).some(([lang, variants]) => + variants.some( + (variant) => + variant && new RegExp(`\\b${variant}\\b`, "i").test(lowerInput) + ) + ) + ); +}; + // ============================================== // CALENDAR EVENT PROCESSOR // ============================================== @@ -236,7 +248,6 @@ function ColorEvents() { ? [new Date("2025-01-26"), new Date("2025-01-28")] : [today, nextThreeMonths]; - CalendarApp.getCalendarsByName("main").forEach((calendar) => { calendar.getEvents(startDate, endDate).forEach((event) => { const originalTitle = event.getTitle();