diff --git a/src/routes/_components/virtualList/VirtualList.html b/src/routes/_components/virtualList/VirtualList.html index 4faa9d36..7d63f729 100644 --- a/src/routes/_components/virtualList/VirtualList.html +++ b/src/routes/_components/virtualList/VirtualList.html @@ -64,6 +64,8 @@ this.store.setForRealm({ items: newItems }) stop('set items') }) + // We observe on the component rather than the store to avoid a leak in store listeners + // (Svelte automatically removes component listeners, but not store listeners) this.observe('allVisibleItemsHaveHeight', allVisibleItemsHaveHeight => { this.calculateListOffset() if (allVisibleItemsHaveHeight) { @@ -71,18 +73,12 @@ } }) - let observedOnce = false - this.observe('distanceFromBottom', (distanceFromBottom) => { - if (!observedOnce) { - observedOnce = true // TODO: the first time is always 0... need better way to handle this - return - } if (distanceFromBottom >= 0 && distanceFromBottom <= DISTANCE_FROM_BOTTOM_TO_FIRE) { this.fireScrollToBottom() } - }) + }, { init: false }) this.observe('scrollTop', (scrollTop) => { this.fire('scrollTopChanged', scrollTop) @@ -107,7 +103,6 @@ return $scrollHeight - $scrollTop - $offsetHeight }, scrollTop: ({ $scrollTop }) => $scrollTop, - // TODO: bug in svelte store, shouldn't need to do this allVisibleItemsHaveHeight: ({ $allVisibleItemsHaveHeight }) => $allVisibleItemsHaveHeight, visibleItemKeys: ({ $visibleItems }) => ($visibleItems || []).map(_ => _.key) },