fix(VirtualList): fix some TODOs (#1851)

* fix(VirtualList): fix some TODOs

* fix: fix memory leak

* fix: remove dead code
issue-1763
Nolan Lawson 2020-08-29 19:19:16 -07:00 zatwierdzone przez GitHub
rodzic 4d1a72bb98
commit 40e9b44adc
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: 4AEE18F83AFDEB23
1 zmienionych plików z 3 dodań i 8 usunięć

Wyświetl plik

@ -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)
},