Skip to content

Commit

Permalink
fix(multiplayer): don't attempt to go online there is a connection issue
Browse files Browse the repository at this point in the history
  • Loading branch information
jeremyckahn committed Apr 30, 2024
1 parent a87eee3 commit 4ed955b
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/components/Farmhand/Farmhand.js
Original file line number Diff line number Diff line change
Expand Up @@ -668,6 +668,7 @@ export default class Farmhand extends FarmhandReducers {

const decodedRoom = decodeURIComponent(newRoom)

// NOTE: This indicates that the client should attempt to connect to the server
const newIsOnline = path.startsWith('/online')

if (newIsOnline !== this.state.isOnline || decodedRoom !== room) {
Expand All @@ -679,7 +680,9 @@ export default class Farmhand extends FarmhandReducers {
}

if (isOnline !== prevState.isOnline || room !== prevState.room) {
this.syncToRoom()
if (newIsOnline) {
this.syncToRoom()
}

if (!isOnline && typeof heartbeatTimeoutId === 'number') {
clearTimeout(heartbeatTimeoutId)
Expand Down

0 comments on commit 4ed955b

Please sign in to comment.