Skip to content

Commit

Permalink
update logic scroll item
Browse files Browse the repository at this point in the history
  • Loading branch information
JustinBeBoy committed May 11, 2024
1 parent 14b7a26 commit 933dd62
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 22 deletions.
12 changes: 1 addition & 11 deletions ui/page/components/items_scroll.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ func (s *Scroll[T]) FetchScrollData(isScrollUp bool, window app.WindowNavigator,
s.itemsCount = 0
s.data = nil
s.cacheData = nil
s.list.Position.Offset = 0
}
s.mu.Unlock()
if s.data == nil || len(s.data.items) == 0 {
Expand Down Expand Up @@ -157,7 +158,6 @@ func (s *Scroll[T]) fetchScrollData(isScrollUp bool, window app.WindowNavigator)
s.mu.Unlock()
return
}

}

// handle when there is a need to load more items.
Expand Down Expand Up @@ -291,22 +291,12 @@ func (s *Scroll[T]) OnScrollChangeListener(window app.WindowNavigator) {
s.prevScrollView = s.scrollView

if isScrollingDown {
// Enforce the first item to be at the list top.
s.list.ScrollToEnd = false
s.list.Position.BeforeEnd = false

s.mu.Unlock()

go s.fetchScrollData(false, window)
}

if isScrollingUp {
// Enforce the first item to be at the list bottom.
s.list.ScrollToEnd = true
s.list.Position.BeforeEnd = true

s.mu.Unlock()

go s.fetchScrollData(true, window)
}

Expand Down
12 changes: 1 addition & 11 deletions ui/page/governance/proposals_page.go
Original file line number Diff line number Diff line change
Expand Up @@ -167,15 +167,6 @@ func (pg *ProposalsPage) fetchProposals(offset, pageSize int32) ([]*components.P
}

orderNewest := pg.orderDropDown.Selected() != values.String(values.StrOldest)

isReset := proposalFilter != pg.previousFilter.TypeFilter || orderNewest == pg.previousFilter.OrderNewest
if isReset {
// reset the offset to zero
offset = 0
pg.previousFilter.TypeFilter = proposalFilter
pg.previousFilter.OrderNewest = orderNewest
}

searchKey := pg.searchEditor.Editor.Text()
proposalItems := components.LoadProposals(pg.Load, proposalFilter, offset, pageSize, orderNewest, strings.TrimSpace(searchKey))
listItems := make([]*components.ProposalItem, 0)
Expand All @@ -192,7 +183,7 @@ func (pg *ProposalsPage) fetchProposals(offset, pageSize int32) ([]*components.P
listItems = proposalItems
}

return listItems, len(listItems), isReset, nil
return listItems, len(listItems), true, nil
}

// HandleUserInteractions is called just before Layout() to determine
Expand Down Expand Up @@ -483,7 +474,6 @@ func (pg *ProposalsPage) listenForSyncNotifications() {
if status == libutils.ProposalStatusSynced {
pg.syncCompleted = true
pg.isSyncing = false

go pg.scroll.FetchScrollData(false, pg.ParentWindow(), false)
pg.ParentWindow().Reload()
}
Expand Down

0 comments on commit 933dd62

Please sign in to comment.