From a19183ae92df7509fb7e6c57096992e9f9d853b2 Mon Sep 17 00:00:00 2001 From: Alan Weinstock Date: Wed, 27 May 2026 15:57:15 -0700 Subject: [PATCH] fix: TS build errors in cron.ts and CampaignDetail; serve at /magpie/ MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - cron.ts: cast split+map destructuring results to tuple types ([string,string,...] and [number,number]) — length guards already ensure these are safe; TypeScript just can't infer it from split() - CampaignDetail: api.posts.trigger → api.posts.triggerSingle (correct name) - .env.example: document sessions_dir + updated reddit_session_file default - manage.sh build now produces a clean zero-warning dist --- .env.example | 8 ++++++-- frontend/src/components/CampaignDetail.vue | 2 +- frontend/src/utils/cron.ts | 5 +++-- 3 files changed, 10 insertions(+), 5 deletions(-) diff --git a/.env.example b/.env.example index 0af3786..3afc262 100644 --- a/.env.example +++ b/.env.example @@ -16,8 +16,12 @@ DEBUG=false # Database location (default: ~/.local/share/magpie/magpie.db) # DB_PATH=/path/to/magpie.db -# Session file location (default: ~/.local/share/magpie/session.json) -# REDDIT_SESSION_FILE=/path/to/session.json +# Sessions directory (multi-user layout: alan_reddit.json, cf_reddit.json, etc.) +# SESSIONS_DIR=/home/youruser/.local/share/magpie/sessions + +# Default Reddit session file (backward compat; used by campaign scheduler) +# Defaults to SESSIONS_DIR/alan_reddit.json — override if your setup differs. +# REDDIT_SESSION_FILE=/home/youruser/.local/share/magpie/sessions/alan_reddit.json # APScheduler SCHEDULER_ENABLED=true diff --git a/frontend/src/components/CampaignDetail.vue b/frontend/src/components/CampaignDetail.vue index a2a3f37..a4ef389 100644 --- a/frontend/src/components/CampaignDetail.vue +++ b/frontend/src/components/CampaignDetail.vue @@ -240,7 +240,7 @@ onMounted(async () => { async function triggerSub(sub: string) { triggeringSub.value = sub try { - await api.posts.trigger(campaignId, sub) + await api.posts.triggerSingle(campaignId, sub) recentPosts.value = await api.posts.list(campaignId, undefined, 20) } catch (e: unknown) { toast.error(`Trigger failed for ${sub}: ${e instanceof Error ? e.message : 'Unknown error'}`) diff --git a/frontend/src/utils/cron.ts b/frontend/src/utils/cron.ts index ef35b35..4cd39ad 100644 --- a/frontend/src/utils/cron.ts +++ b/frontend/src/utils/cron.ts @@ -26,7 +26,7 @@ function parseDow(dow: string): string { } // Range: 1-5 if (dow.includes('-')) { - const [start, end] = dow.split('-').map(Number) + const [start, end] = dow.split('-').map(Number) as [number, number] if (start === 1 && end === 5) return 'Weekdays' if (start === 0 && end === 6) return 'Every day' return `${DAYS[start]}-${DAYS[end]}` @@ -45,7 +45,8 @@ export function humanizeCron(expr: string | null | undefined): string { const parts = expr.trim().split(/\s+/) if (parts.length !== 5) return expr - const [minute, hour, dom, month, dow] = parts + // Cast to tuple — length guard above guarantees all five are present. + const [minute, hour, dom, month, dow] = parts as [string, string, string, string, string] const everyMinute = minute === '*' const everyHour = hour === '*'