Skip to content

Commit

Permalink
bug: Fixed issue with sidebar not updating
Browse files Browse the repository at this point in the history
  • Loading branch information
matthe815 committed Feb 3, 2023
1 parent bf858f3 commit 8fefab6
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
1 change: 0 additions & 1 deletion public/js/classes/NetworkingManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ export class NetworkManager {

for (let i=this.app.global.world; i>this.app.worlds.length-1; i--) {
this.app.worlds.unshift(new GameWorld(this.app))
this.app.call('world update')
}

this.app.local.world.save = parsed.data.save // Overwrite the local save with the parsed save.
Expand Down
19 changes: 10 additions & 9 deletions public/js/components/Sidebar/Sidebar.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,7 @@ export default class Sidebar extends React.Component {
super(props)
this.state = { page: 0, connected: false }
this.handleChange = this.handleChange.bind(this)
this.pages = [this.homePage()];

app.subscribeToClientConnection(() => {
console.log(app.global.connected)
this.setState({ connected: app.global.connected })
})
this.pages = [this.homePage];
}

shouldComponentUpdate (_, nextState) {
Expand All @@ -40,20 +35,26 @@ export default class Sidebar extends React.Component {
componentDidMount () {
app.subscribeToClientConnection((connected) => {
this.setState({ connected })
this.forceUpdate();
});
this.pages = [this.homePage(), this.savePage(), null, this.itemPage(), this.settingsPage(), this.accountPage()]
this.pages = [this.homePage, this.savePage, null, this.itemPage, this.settingsPage, this.accountPage]
app.local.world.subscribeSync(() => {
this.forceUpdate();
})
app.local.world.subscribeChangeScene(() => {
this.forceUpdate();
})
}

renderPage () {
return this.pages[parseInt(this.state.page)]
return this.pages[parseInt(this.state.page)]();
}

handleChange (e) {
this.setState({ page: e.target.value })
}

homePage () {
console.log(app.global.connected)
return (
<>
{app.global.connected ? <PlayerList /> : <p>Connect to a tracker to see the player list.</p>}
Expand Down

0 comments on commit 8fefab6

Please sign in to comment.