Make calendar window smaller to avoid tag limits

This commit is contained in:
Jon Staab
2025-04-03 15:56:37 -07:00
parent 1b318a7a52
commit 33902dbefe
2 changed files with 8 additions and 6 deletions

View File

@@ -65,7 +65,7 @@
tags: [
["d", initialValues?.d || randomId()],
["title", title],
["location", location],
["location", location || ""],
["start", start.toString()],
["end", end.toString()],
...daysBetween(start, end).map(D => ["D", D.toString()]),

View File

@@ -8,7 +8,7 @@ import {
uniq,
int,
YEAR,
MONTH,
DAY,
insert,
sortBy,
assoc,
@@ -203,9 +203,11 @@ export const makeCalendarFeed = ({
onExhausted?: () => void
initialEvents?: TrustedEvent[]
}) => {
const interval = int(5, DAY)
let exhaustedScrollers = 0
let backwardWindow = [now() - MONTH, now()]
let forwardWindow = [now(), now() + MONTH]
let backwardWindow = [now() - interval, now()]
let forwardWindow = [now(), now() + interval]
const getStart = (event: TrustedEvent) => parseInt(getTagValue("start", event.tags) || "")
@@ -273,7 +275,7 @@ export const makeCalendarFeed = ({
onScroll: () => {
const [since, until] = backwardWindow
backwardWindow = [since - MONTH, since]
backwardWindow = [since - interval, since]
if (until > now() - int(2, YEAR)) {
loadTimeframe(since, until)
@@ -289,7 +291,7 @@ export const makeCalendarFeed = ({
onScroll: () => {
const [since, until] = forwardWindow
forwardWindow = [until, until + MONTH]
forwardWindow = [until, until + interval]
if (until < now() + int(2, YEAR)) {
loadTimeframe(since, until)