File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -82,14 +82,16 @@ function VoteButtons(props: {
8282 < div className = "flex flex-col self-center mr-3 pb-8" >
8383 < button
8484 onClick = { async ( ) => {
85- if ( props . post . upVoteByViewer ?. totalCount === 0 ) {
85+ if ( ! user ) {
86+ router . push ( "/login" ) ;
87+ } else if ( props . post . upVoteByViewer ?. totalCount === 0 ) {
8688 await deleteVote ( {
8789 postId : props . post . id ,
88- profileId : user ! . id ,
90+ profileId : user . id ,
8991 } ) ;
9092 vote ( {
9193 postId : props . post . id ,
92- profileId : user ! . id ,
94+ profileId : user . id ,
9395 voteDirection : "UP" ,
9496 } ) ;
9597 }
@@ -101,14 +103,16 @@ function VoteButtons(props: {
101103 </ button >
102104 < button
103105 onClick = { async ( ) => {
104- if ( props . post . downVoteByViewer ?. totalCount === 0 ) {
106+ if ( ! user ) {
107+ router . push ( "/login" ) ;
108+ } else if ( props . post . downVoteByViewer ?. totalCount === 0 ) {
105109 await deleteVote ( {
106110 postId : props . post . id ,
107- profileId : user ! . id ,
111+ profileId : user . id ,
108112 } ) ;
109113 vote ( {
110114 postId : props . post . id ,
111- profileId : user ! . id ,
115+ profileId : user . id ,
112116 voteDirection : "DOWN" ,
113117 } ) ;
114118 }
You can’t perform that action at this time.
0 commit comments