@@ -21,7 +21,7 @@ export default function Index({
2121 space,
2222 votes,
2323 voteStatus,
24- comments ,
24+ commentData ,
2525 defaultPage,
2626 myVote,
2727 isSafari,
@@ -114,7 +114,7 @@ export default function Index({
114114 space = { space }
115115 votes = { votes }
116116 voteStatus = { voteStatus }
117- comments = { comments }
117+ commentData = { commentData }
118118 defaultPage = { defaultPage }
119119 myVote = { savedMyVote }
120120 isSafari = { isSafari }
@@ -130,11 +130,21 @@ export async function getServerSideProps(context) {
130130 userAgent . includes ( "Safari" ) && ! userAgent . includes ( "Chrome" ) ;
131131
132132 const { id, space : spaceId } = context . params ;
133- const { page, discussion_page : discussionPage } = context . query ;
134-
135- const nPage = page === "last" ? "last" : parseInt ( page ) || 1 ;
136- const discusPage =
137- discussionPage === "last" ? "last" : parseInt ( discussionPage ) || 1 ;
133+ const { page, discussion_page : discussionPage , anchor = "" } = context . query ;
134+
135+ const hasVoteAnchor = anchor . startsWith ( "vote" ) ;
136+ const hasCommentAnchor = anchor . startsWith ( "comment" ) ;
137+
138+ const votePage = hasVoteAnchor
139+ ? 1
140+ : page === "last"
141+ ? "last"
142+ : parseInt ( page ) || 1 ;
143+ const discusPage = hasCommentAnchor
144+ ? 1
145+ : discussionPage === "last"
146+ ? "last"
147+ : parseInt ( discussionPage ) || 1 ;
138148
139149 const { result : detail } = await ssrNextApi . fetch (
140150 `${ spaceId } /proposal/${ id } ` ,
@@ -148,17 +158,17 @@ export async function getServerSideProps(context) {
148158 { result : space } ,
149159 { result : votes } ,
150160 { result : voteStatus } ,
151- { result : comments } ,
161+ { result : commentData } ,
152162 ] = await Promise . all ( [
153163 ssrNextApi . fetch ( `spaces/${ spaceId } ` ) ,
154164 ssrNextApi . fetch ( `${ spaceId } /proposal/${ detail ?. cid } /votes` , {
155- page : nPage ,
156- pageSize : 50 ,
165+ page : votePage ,
166+ pageSize : hasVoteAnchor ? 200 : 50 ,
157167 } ) ,
158168 ssrNextApi . fetch ( `${ spaceId } /proposal/${ detail ?. cid } /stats` ) ,
159169 ssrNextApi . fetch ( `${ spaceId } /proposal/${ detail ?. cid } /comments` , {
160170 page : discusPage ,
161- pageSize : 25 ,
171+ pageSize : hasCommentAnchor ? 200 : 25 ,
162172 } ) ,
163173 ] ) ;
164174
@@ -179,8 +189,8 @@ export async function getServerSideProps(context) {
179189 space : space ?? null ,
180190 votes : votes ?? EmptyQuery ,
181191 voteStatus : voteStatus ?? [ ] ,
182- comments : comments ?? EmptyQuery ,
183- defaultPage : { page : nPage , discussionPage : discusPage } ,
192+ commentData : commentData ?? EmptyQuery ,
193+ defaultPage : { page : votePage , discussionPage : discusPage } ,
184194 myVote : myVote ?? null ,
185195 isSafari,
186196 } ,
0 commit comments