Fix a couple calendar bugs

This commit is contained in:
Jon Staab
2025-02-06 08:55:01 -08:00
parent 72919cb1c2
commit fa4bc6894f
2 changed files with 7 additions and 10 deletions

View File

@@ -185,8 +185,6 @@ export const makeCalendarFeed = ({
events.update($events => $events.filter(e => !ids.includes(e.id)))
}
const handleDelete = (e: TrustedEvent) => removeEvents(getTagValues(["e", "a"], e.tags))
const onThunk = (thunk: Thunk) => {
if (matchFilters(feedFilters, thunk.event)) {
insertEvent(thunk.event)
@@ -194,8 +192,6 @@ export const makeCalendarFeed = ({
thunk.controller.signal.addEventListener("abort", () => {
removeEvents([thunk.event.id])
})
} else if (thunk.event.kind === DELETE) {
handleDelete(thunk.event)
}
}
@@ -204,7 +200,6 @@ export const makeCalendarFeed = ({
filters: subscriptionFilters,
onEvent: (e: TrustedEvent) => {
if (matchFilters(feedFilters, e)) insertEvent(e)
if (e.kind === DELETE) handleDelete(e)
},
})

View File

@@ -62,6 +62,10 @@
let initialScrollDone = false
$effect(() => {
if (items.length === 0) {
return
}
if (initialScrollDone) {
// If new events are prepended, adjust the scroll position so that the viewport content remains anchored
if (prevFirstEventId && items[0].event.id !== prevFirstEventId) {
@@ -72,7 +76,7 @@
element.scrollTop += delta
}
}
} else if (items.length > 0) {
} else {
const {event} = items.find(({event}) => getStart(event) >= now()) || last(items)
const {offsetTop, clientHeight} = document.querySelector(
".calendar-event-" + event.id,
@@ -83,10 +87,8 @@
initialScrollDone = true
}
if (items.length > 0) {
previousScrollHeight = element.scrollHeight
prevFirstEventId = items[0].event.id
}
previousScrollHeight = element.scrollHeight
prevFirstEventId = items[0].event.id
})
onMount(() => {