From ad8851ea943e1ca822859aa3dc0624af6ce77e7b Mon Sep 17 00:00:00 2001 From: qwqcode Date: Wed, 20 Dec 2023 21:34:20 +0800 Subject: [PATCH] fix(ui/pagination): auto switch page by url hashtag issue (#693) --- ui/packages/artalk/src/list/page.ts | 26 ++++++++++++++++++-------- 1 file changed, 18 insertions(+), 8 deletions(-) diff --git a/ui/packages/artalk/src/list/page.ts b/ui/packages/artalk/src/list/page.ts index 8cb5157ed..cd516ab51 100644 --- a/ui/packages/artalk/src/list/page.ts +++ b/ui/packages/artalk/src/list/page.ts @@ -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 @@ -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) - }) }