feat(budgets,categories,tags): in-place limits with pace, category shares, tag tree and clean-up
This commit is contained in:
1 parent
4a693a83c9
commit
89bbf56062
54 files changed
+5135
-1
No files matched your search
@@ -0,0 +1,34 @@
|
||||
import { untrack } from "svelte";
|
||||
import { period } from "#lib/period.svelte.js";
|
||||
import { goto } from "$app/navigation";
|
||||
import { page } from "$app/state";
|
||||
|
||||
export function periodPath(base: string, start: string, end: string) {
|
||||
return `${base}/${start}/${end}?start=${start}&end=${end}`;
|
||||
}
|
||||
|
||||
export function usePeriodPath(base: () => string) {
|
||||
$effect(() => {
|
||||
const { start, end } = page.params;
|
||||
if (period.ready && start && end && start <= end) {
|
||||
untrack(() => period.set({ end, start }));
|
||||
}
|
||||
});
|
||||
$effect(() => {
|
||||
if (!period.ready) {
|
||||
return;
|
||||
}
|
||||
const { start, end } = period;
|
||||
untrack(() => {
|
||||
const { start: from, end: to } = page.params;
|
||||
if (from && to && (from !== start || to !== end)) {
|
||||
const target = base();
|
||||
setTimeout(() => {
|
||||
if (page.url.pathname.startsWith(`${target}/${from}`)) {
|
||||
goto(periodPath(target, start, end), { replace: true });
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
Reference in new issue
Block a user