Skip to content

Commit

Permalink
fix(frontend): redirect guest on connection
Browse files Browse the repository at this point in the history
  • Loading branch information
DecentM committed Oct 12, 2023
1 parent ed0edfb commit 05e15e4
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions apps/frontend/src/layouts/play-layout.vue
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@
import { watch } from 'vue'
import { useChessRtcConnection } from '../hooks/chess-rtc-connection'
import { useRouter } from 'vue-router'
const chessRtcConnection = useChessRtcConnection()
const router = useRouter()
watch(chessRtcConnection.open, (newValue) => {
if (!newValue) {
Expand All @@ -15,6 +17,8 @@ watch(chessRtcConnection.open, (newValue) => {
type: 'side-assignment',
value: Math.random() > 0.5 ? 'white' : 'black',
})
} else {
router.push(`/play/online/${chessRtcConnection.peerId.value}`)
}
})
</script>
Expand Down

0 comments on commit 05e15e4

Please sign in to comment.