Skip to content

Commit

Permalink
Merge pull request #51 from ntnui-darts/50-walkonendtime
Browse files Browse the repository at this point in the history
feat: add walkonendtime field. Fixes #50
  • Loading branch information
magnetenstad authored Oct 16, 2023
2 parents a30ea2d + 0dbdb5c commit 6889790
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/components/Youtube.vue
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<template>
<iframe
:src="`https://www.youtube.com/embed/${videoId}?amp;start=${startTime}&autoplay=1&playsinline=1`"
:src="`https://www.youtube.com/embed/${videoId}?amp;start=${startTime}&end=${endTime}&autoplay=1&playsinline=1`"
title="YouTube video player"
allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share"
></iframe>
Expand All @@ -9,5 +9,6 @@
defineProps<{
videoId: string
startTime: number
endTime: number
}>()
</script>
1 change: 1 addition & 0 deletions src/stores/auth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ export const useAuthStore = defineStore('auth', {
id: user.id,
walkOn: user.walkOn,
walkOnTime: user.walkOnTime,
walkOnEndTime: user.walkOnEndTime,
} satisfies Partial<User>
if (prevName.data?.length == 0) {
await supabase.from('users').insert(copy)
Expand Down
3 changes: 3 additions & 0 deletions src/stores/game.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ export const useGameStore = defineStore('game', {

walkOn: null as string | null,
walkOnTime: 0,
walkOnEndTime: 0,

// Don't access controller directly, use getController()
_controller: null as GameController | null,
Expand All @@ -45,6 +46,7 @@ export const useGameStore = defineStore('game', {

this.walkOn = null
this.walkOnTime = 0
this.walkOnEndTime = 0
if (
this.game &&
this.gameState.userId &&
Expand All @@ -54,6 +56,7 @@ export const useGameStore = defineStore('game', {
if (user) {
this.walkOn = user.walkOn
this.walkOnTime = user.walkOnTime
this.walkOnEndTime = user.walkOnEndTime
}
}

Expand Down
3 changes: 3 additions & 0 deletions src/types/supabase.ts
Original file line number Diff line number Diff line change
Expand Up @@ -171,20 +171,23 @@ export interface Database {
id: string
name: string
walkOn: string | null
walkOnEndTime: number
walkOnTime: number
}
Insert: {
created_at?: string
id?: string
name?: string
walkOn?: string | null
walkOnEndTime?: number
walkOnTime?: number
}
Update: {
created_at?: string
id?: string
name?: string
walkOn?: string | null
walkOnEndTime?: number
walkOnTime?: number
}
Relationships: []
Expand Down
1 change: 1 addition & 0 deletions src/views/GameView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
v-if="gameStore.walkOn"
:video-id="gameStore.walkOn"
:start-time="gameStore.walkOnTime"
:end-time="gameStore.walkOnEndTime"
>
</Youtube>
</div>
Expand Down
14 changes: 14 additions & 0 deletions src/views/UserView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,13 @@
type="number"
@change="updateWalkOnTime"
/>
<label for="videoId">Walk-on Video End Time</label>
<input
id="walkOnEnd"
:value="usersStore.getCurrentUser?.walkOnEndTime"
type="number"
@change="updateWalkOnEndTime"
/>
<button @click="router.push({ name: 'password' })">Change Password</button>
<div class="row">
<button v-if="changed" id="discard" @click="discardChanges">
Expand Down Expand Up @@ -65,6 +72,13 @@ const updateWalkOnTime = (e: Event) => {
changed.value = true
}
const updateWalkOnEndTime = (e: Event) => {
const el = e.target as HTMLInputElement
if (!usersStore.getCurrentUser) return
usersStore.getCurrentUser.walkOnEndTime = el.valueAsNumber
changed.value = true
}
const saveChanges = () => {
if (!usersStore.getCurrentUser) return
authStore.setUserParams(usersStore.getCurrentUser)
Expand Down

0 comments on commit 6889790

Please sign in to comment.