@@ -109,7 +109,7 @@ export const Home = () => {
109109 < Header
110110 share = { async ( ) => {
111111 const url = new URL ( document . location . origin ) ;
112- url . pathname = context . user . latest ! . display ;
112+ url . pathname = params . user || context . user . latest ! . display ;
113113 return url . toString ( ) ;
114114 } }
115115 />
@@ -151,8 +151,10 @@ export const Home = () => {
151151 < thead >
152152 < tr class = "border-b border-neutral-600 font-medium" >
153153 < th class = "pb-2 w-6/10 text-left" > Title</ th >
154- < th class = "pb-2 w-32 text-left" > Edited</ th >
155- < th class = "pb-2 w-20 text-right" > Options</ th >
154+ < th class = "pb-2 w-32 text-left last:text-right" > Edited</ th >
155+ < Show when = { ! params . user } >
156+ < th class = "pb-2 w-20 text-right" > Options</ th >
157+ </ Show >
156158 </ tr >
157159 </ thead >
158160 < tbody >
@@ -184,47 +186,51 @@ export const Home = () => {
184186 < td >
185187 < a href = { `${ params . user || context . user ( ) ?. display } /${ repl . id } ` } > { repl . title } </ a >
186188 </ td >
187- < td > { timeAgo ( Date . now ( ) - new Date ( repl . updated_at || repl . created_at ) . getTime ( ) ) } </ td >
188- < td class = "text-right" >
189- < Icon
190- path = { repl . public ? eye : eyeOff }
191- class = "w-6 inline m-2 ml-0 cursor-pointer"
192- onClick = { async ( ) => {
193- fetch ( `${ API } /repl/${ repl . id } ` , {
194- method : 'PUT' ,
195- headers : {
196- 'authorization' : `Bearer ${ context . token } ` ,
197- 'Content-Type' : 'application/json' ,
198- } ,
199- body : JSON . stringify ( {
200- ...repl ,
201- public : ! repl . public ,
202- } ) ,
203- } ) ;
204- setRepls (
205- produce ( ( x ) => {
206- x ! . list [ i ( ) ] . public = ! repl . public ;
207- } ) ,
208- ) ;
209- } }
210- />
211- < Icon
212- path = { x }
213- class = "w-6 inline m-2 mr-0 text-red-700 cursor-pointer"
214- onClick = { async ( ) => {
215- fetch ( `${ API } /repl/${ repl . id } ` , {
216- method : 'DELETE' ,
217- headers : {
218- authorization : `Bearer ${ context . token } ` ,
219- } ,
220- } ) ;
221- setRepls ( {
222- total : repls . total - 1 ,
223- list : repls . list . filter ( ( x ) => x . id !== repl . id ) ,
224- } ) ;
225- } }
226- />
189+ < td class = "last:text-right" >
190+ { timeAgo ( Date . now ( ) - new Date ( repl . updated_at || repl . created_at ) . getTime ( ) ) }
227191 </ td >
192+ < Show when = { ! params . user } >
193+ < td class = "text-right" >
194+ < Icon
195+ path = { repl . public ? eye : eyeOff }
196+ class = "w-6 inline m-2 ml-0 cursor-pointer"
197+ onClick = { async ( ) => {
198+ fetch ( `${ API } /repl/${ repl . id } ` , {
199+ method : 'PUT' ,
200+ headers : {
201+ 'authorization' : `Bearer ${ context . token } ` ,
202+ 'Content-Type' : 'application/json' ,
203+ } ,
204+ body : JSON . stringify ( {
205+ ...repl ,
206+ public : ! repl . public ,
207+ } ) ,
208+ } ) ;
209+ setRepls (
210+ produce ( ( x ) => {
211+ x ! . list [ i ( ) ] . public = ! repl . public ;
212+ } ) ,
213+ ) ;
214+ } }
215+ />
216+ < Icon
217+ path = { x }
218+ class = "w-6 inline m-2 mr-0 text-red-700 cursor-pointer"
219+ onClick = { async ( ) => {
220+ fetch ( `${ API } /repl/${ repl . id } ` , {
221+ method : 'DELETE' ,
222+ headers : {
223+ authorization : `Bearer ${ context . token } ` ,
224+ } ,
225+ } ) ;
226+ setRepls ( {
227+ total : repls . total - 1 ,
228+ list : repls . list . filter ( ( x ) => x . id !== repl . id ) ,
229+ } ) ;
230+ } }
231+ />
232+ </ td >
233+ </ Show >
228234 </ tr >
229235 ) }
230236 </ For >
0 commit comments