Skip to content

calculate speed (test pull request)#3

Open
killer415tv wants to merge 1 commit intoelectaco:feature/speedometerfrom
killer415tv:feature/speedometer
Open

calculate speed (test pull request)#3
killer415tv wants to merge 1 commit intoelectaco:feature/speedometerfrom
killer415tv:feature/speedometer

Conversation

@killer415tv
Copy link

just a test for pull request

calculateSpeed() {

this.setState({now_position: this.state.gw2data_ws?.coordinates.playerPosition})
this.setState({now_timestamp: new Date().getTime()})
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.


calculateSpeed() {

this.setState({now_position: this.state.gw2data_ws?.coordinates.playerPosition})
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You're not using now_position and now_timestamp, so might want to skip these :)

let speed = (distance * 39.3700787) / 0.01 ;
speed = Math.round((speed*100/10000)*99/72)

this.setState({speed: speed})
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These three setstate can be done in one call :)

interface IState {
gw2data_ipc: IGw2MumbleLinkData | null;
gw2data_ws: IGw2MumbleLinkData | null;
now_position: any;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would be nice if you had type here, it's an interface IPosition that has this structure.

That would also highlight a bug on line 28 where you use small xyz instead of capital XYZ

now_timestamp: any;
last_position: any;
last_timestamp: any;
speed: any;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

speed is number :) Also consider if it should be null before calculating speed the first time.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants