only load beats if challenge/difficulty changes

This commit is contained in:
Kevin Ngo
2018-10-09 16:56:34 -07:00
parent 5e1b8de7e7
commit 78e1a54e8f

View File

@@ -28,9 +28,13 @@ AFRAME.registerComponent('beat-loader', {
this.el.addEventListener('cleargame', this.clearBeats.bind(this));
},
update: function () {
if (!this.data.challengeId || !this.data.difficulty) { return; }
this.loadBeats();
update: function (oldData) {
const data = this.data;
if (!data.challengeId || !data.difficulty) { return; }
if (data.challengeId !== oldData.challengeId ||
data.difficulty !== oldData.difficulty) {
this.loadBeats();
}
},
/**