From df2e1e81cd7c92ff244ce0a60467c243e150723e Mon Sep 17 00:00:00 2001 From: Valexr Date: Mon, 20 May 2024 08:53:17 +0200 Subject: [PATCH] fix: quote random --- src/lib/counters.ts | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/src/lib/counters.ts b/src/lib/counters.ts index e6bfef0..a910176 100644 --- a/src/lib/counters.ts +++ b/src/lib/counters.ts @@ -3,25 +3,25 @@ import { dates } from './dates'; import { quotes } from './quotes'; import { DateTime, Interval } from "luxon"; -export const counters = derived<[Writable, Writable], Counter[]>(([dates, quotes]), - ([$dates, $quotes], set) => { +export const counters = derived, Counter[]>(dates, ($dates, set) => { - set($dates.map(({ start, title, quote }, id) => count(id, start, title, quote))) + set($dates.map(({ start, title }, id) => count(id, start, title))) - function count(id: number, start: string, title: string, quote: Quote) { - const { years, months, weeks, days, interval } = elapse(start) - return { - id, title, quote: quote || quotes.random(id), start: start, - years, months, days, weeks, - full: { - months: Math.trunc(interval.length('months')), - weeks: Math.trunc(interval.length('weeks')), - days: Math.trunc(interval.length('days')), - hours: Math.trunc(interval.length('hours')), - } + function count(id: number, start: string, title: string) { + const { years, months, weeks, days, interval } = elapse(start) + return { + id, title, start, + quote: quotes.random(id), + years, months, days, weeks, + full: { + months: Math.trunc(interval.length('months')), + weeks: Math.trunc(interval.length('weeks')), + days: Math.trunc(interval.length('days')), + hours: Math.trunc(interval.length('hours')), } } - }, []) + } +}, []) function elapse(start: string) { const TO = DateTime.now();