1
1
import { globalCtx } from '@/ctx/global-ctx'
2
- import { PostService } from '@/service/post/post'
3
2
import { window } from 'vscode'
4
3
import { postDataProvider } from '@/tree-view/provider/post-data-provider'
5
4
import { Alert } from '@/infra/alert'
@@ -53,8 +52,6 @@ function updatePostListViewTitle() {
53
52
}
54
53
55
54
export namespace PostListView {
56
- import calcPageCount = PageList . calcPageCount
57
-
58
55
export async function refresh ( { queue = false , pageIndex = 1 } = { } ) : Promise < boolean > {
59
56
if ( isRefreshing && ! queue ) {
60
57
await refreshTask
@@ -67,13 +64,13 @@ export namespace PostListView {
67
64
const fut = async ( ) => {
68
65
await setRefreshing ( true )
69
66
const page = await postDataProvider . loadPosts ( pageIndex )
70
- const postCount = await PostService . getCount ( )
71
- const pageCount = calcPageCount ( page . cap , postCount )
67
+ const pageSize = page ?. size ?? 30
68
+ const pageCount = page ?. count ?? 1
72
69
const hasPrev = PageList . hasPrev ( pageIndex )
73
70
const hasNext = PageList . hasNext ( pageIndex , pageCount )
74
71
75
72
await setPostListContext ( pageCount , hasPrev , hasNext )
76
- await updatePostListState ( pageIndex , page . cap , page . items . length , pageCount )
73
+ await updatePostListState ( pageIndex , pageSize , pageCount , hasPrev , hasNext )
77
74
updatePostListViewTitle ( )
78
75
await postDataProvider . refreshSearch ( )
79
76
await setRefreshing ( false )
0 commit comments