File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -425,7 +425,6 @@ const server = Bun.serve({
425425
426426 if ( authentication ?. user ) {
427427 const rating = await sql `select thumbs_up from ratings where user_id = ${ authentication . user } AND level_id = ${ levelId } `
428- console . log ( rating )
429428 currentRating = rating !== [ ] ? rating [ 0 ] . thumbs_up : null
430429 }
431430
Original file line number Diff line number Diff line change @@ -7,7 +7,21 @@ const serverUrl = window.location.origin
77async function getLevel ( level = 1 ) {
88 try {
99 const raw = await fetch ( `${ serverUrl } /api/level?levelId=${ level } ` )
10- const levels = raw . json ( )
10+ const levels = await raw . json ( )
11+
12+ const approvalWrapper = document . querySelector ( ".thumbs-up-wrapper" )
13+ const disapprovalWrapper = document . querySelector ( ".thumbs-down-wrapper" )
14+
15+ console . log ( levels )
16+
17+ console . log ( levels . current_user_rating )
18+
19+ if ( levels . current_user_rating ) {
20+ approvalWrapper . classList . add ( "clicked" )
21+ } else if ( levels . current_user_rating === false ) {
22+ disapprovalWrapper . classList . add ( "clicked" )
23+ }
24+
1125 window . dispatchEvent ( new CustomEvent ( 'level:loaded' , { detail : levels } ) )
1226 return await levels
1327 } catch ( e ) {
@@ -203,4 +217,4 @@ disapprovalButton.addEventListener("click", () => {
203217 approvalWrapper . classList . remove ( "clicked" )
204218
205219 rateLevel ( false )
206- } )
220+ } )
Original file line number Diff line number Diff line change 2121- options page
2222- sign out button
2323- you can still request levels from the server that are private
24- - opening a page of a level you've rated should show your rating
2524
2625** Editor**
2726
You can’t perform that action at this time.
0 commit comments