Skip to content

Commit

Permalink
fix(ui/pagination): auto switch page by url hashtag issue (#693)
Browse files Browse the repository at this point in the history
  • Loading branch information
qwqcode committed Dec 20, 2023
1 parent def9dc2 commit ad8851e
Showing 1 changed file with 18 additions and 8 deletions.
26 changes: 18 additions & 8 deletions ui/packages/artalk/src/list/page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,24 @@ export const initListPaginatorFunc = (ctx: ContextApi) => {
})

// List goto auto next page when comment not found
// autoJumpToNextPage(ctx, paginator)

// loading
ctx.on('list-fetch', (params) => {
paginator?.setLoading(true)
})
ctx.on('list-fetched', ({ params }) => {
paginator?.setLoading(false)
})
}

function autoJumpToNextPage(ctx: ContextApi, paginator: Paginator|null) {
// TODO: Disable this feature temporarily. Because it may cause the page memory leak.
// if the comments is too much and the comment still not found.
// Consider to refactor to a better solution.
// Such as: calculate in backend and jump to the specific page directly.
return

const autoSwitchPageForFindComment = (commentID: number) => {
const comment = ctx.getData().findComment(commentID)
if (!!comment || !paginator?.getHasMore()) return
Expand All @@ -86,12 +104,4 @@ export const initListPaginatorFunc = (ctx: ContextApi) => {
ctx.on('list-goto', (commentID) => {
autoSwitchPageForFindComment(commentID)
})

// loading
ctx.on('list-fetch', (params) => {
paginator?.setLoading(true)
})
ctx.on('list-fetched', ({ params }) => {
paginator?.setLoading(false)
})
}

0 comments on commit ad8851e

Please sign in to comment.