Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

start to use the ui to send leaderboard info to supabase #271

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 43 additions & 0 deletions ui/src/utils/supabase.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
// TODO: this is a standalone file and needs to be integrated with the rest of the ui to be useful

const { createClient, SupabaseClient } = require('@supabase/supabase-js');
require('dotenv').config({ path: '.env' });

const supabaseUrl = process.env.SUPABASE_URL
const supabaseKey = process.env.SUPABASE_SECRET
console.log(supabaseKey)
const supabase = createClient(supabaseUrl, supabaseKey)

// lists all rows in connections table
async function fetchConnections() {
let { data: connections, error } = await supabase
.from('connections')
.select('*')

if (error) {
console.error('Error fetching connections:', error)
} else {
console.log('Connections:', connections)
}
}
fetchConnections()


// inserts to the connections table using the record_connection function
const testUUID = 'some_uuid' // replace with actual UUID
async function insertConnection() {
let { data, error } = await supabase
.rpc('record_connection', {"user_id_input": testUUID})
if (error) console.error(error)
else console.log(data)
}
insertConnection()

async function signInAnon() {
let { data, error } = await supabase.auth.signInAnonymously()
if (error) {
console.error('Error with anon sign in:', error)
} else {
console.log('signed in:', data)
}
}
1 change: 1 addition & 0 deletions ui/src/utils/wasmInterface.ts
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,7 @@ export class WasmInterface {
if (existingState === -1 && state === 1) {
lifetimeConnectionsEmitter.update(lifetimeConnectionsEmitter.state + 1)
}
// TODO: send to supabase/leaderboard here, alert("handleConnection: "+lifetimeConnectionsEmitter.state)
}

handleReady = () => {
Expand Down