From 5d117cf1a0564ff0245a40672b031df8321e79ff Mon Sep 17 00:00:00 2001 From: Henrik Giesel Date: Tue, 22 Dec 2020 22:25:47 +0100 Subject: [PATCH] Bubble up days and search to caller --- ts/graphs/GraphsPage.svelte | 5 +++-- ts/graphs/bootstrap.ts | 10 +++++++++- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/ts/graphs/GraphsPage.svelte b/ts/graphs/GraphsPage.svelte index c150b297a..2312d825c 100644 --- a/ts/graphs/GraphsPage.svelte +++ b/ts/graphs/GraphsPage.svelte @@ -11,6 +11,9 @@ export let nightMode: boolean; export let graphs: any[]; + export let search: string; + export let days: number; + let sourceData: pb.BackendProto.GraphsOut | null = null; enum SearchRange { @@ -21,10 +24,8 @@ let searchRange: SearchRange = SearchRange.Deck; let revlogRange: RevlogRange = RevlogRange.Year; - let days: number = 31; let refreshing = false; - let search = "deck:current"; let displayedSearch = search; const refresh = async () => { diff --git a/ts/graphs/bootstrap.ts b/ts/graphs/bootstrap.ts index 12a5b6b31..2877fe8e2 100644 --- a/ts/graphs/bootstrap.ts +++ b/ts/graphs/bootstrap.ts @@ -16,7 +16,13 @@ export { default as FutureDue } from "./FutureDue.svelte"; export { default as ReviewsGraph } from "./ReviewsGraph.svelte"; export { default as CalendarGraph } from "./CalendarGraph.svelte"; -export function graphs(target: HTMLDivElement, graphs: any[]): void { +export function graphs( + target: HTMLDivElement, + graphs: any[], { + search = "deck:current", + days = 31, + } = {}, +): void { const nightMode = checkNightMode(); setupI18n().then((i18n) => { @@ -26,6 +32,8 @@ export function graphs(target: HTMLDivElement, graphs: any[]): void { i18n, graphs, nightMode, + search, + days, }, }); });