Skip to content

Commit

Permalink
Throttle some unnecessary update messages.
Browse files Browse the repository at this point in the history
  • Loading branch information
malloch committed Sep 13, 2024
1 parent 1bd79c5 commit 2a17a66
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 29 deletions.
1 change: 0 additions & 1 deletion js/SaverLoader.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,6 @@ class SaverLoader {
}

updateSessions() {
console.log("saverLoader.updateSessions()!");
$('#sessionMenu').empty();
let active_sessions = graph.active_sessions;
if (active_sessions.length > 0) {
Expand Down
26 changes: 16 additions & 10 deletions js/ViewManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -181,29 +181,36 @@ class ViewManager
remove_object_svg(obj, 0);
return;
}
if (event == 'removed') {
// check here if tooltip is visible and has same key as the removed object
if (self.tooltip.is_visible && self.tooltip.key == obj.key)
self.tooltip.hide();
}

switch (type) {
case 'device':
self._update_devices(obj, event, repaint);
// only graph view might use device properties
if (event != 'modified' || this.currentView == 'graph')
self._update_devices(obj, event, repaint);
break;
case 'link':
self._update_links(obj, event, repaint);
if (event != 'modified' && this.currentView == 'chord')
self._update_links(obj, event, repaint);
break;
case 'signal':
self._update_signals(obj, event, repaint);
// only graph view might use signal properties
if (this.currentView == 'chord' || this.currentView == 'console')
break;
if (event != 'modified' || this.currentView == 'graph')
self._update_signals(obj, event, repaint);
break;
case 'map':
self._update_maps(obj, event, repaint);
break;
case 'session':
console.log("got graph sessions callback!");
self._update_sessions();
break;
}
if (event == 'removed') {
// check here if tooltip is visible and has same key as the removed object
if (self.tooltip.is_visible && self.tooltip.key == obj.key)
self.tooltip.hide();
}
});
};

Expand Down Expand Up @@ -270,7 +277,6 @@ class ViewManager
}

_update_sessions() {
console.log("ViewManager._update_sessions()");
$('#container').trigger("updateSessions");
}

Expand Down
21 changes: 4 additions & 17 deletions js/views/ChordView.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,14 +47,6 @@ class ChordView extends View {
// remove associated svg elements for maps
this.graph.maps.forEach(function(map) { remove_object_svg(map); });

this.devCount = this.canvas.text(this.mapPane.cx, this.mapPane.cy, " ")
.attr({'font-size': 100,
'opacity': 0.25,
'fill': 'white',
'x': this.mapPane.cx,
'y': this.mapPane.cy});
this.devCount.node.setAttribute('pointer-events', 'none');

this.updateDevices();
this.resize();
}
Expand All @@ -68,9 +60,6 @@ class ChordView extends View {
this.mapPane.cy = this.frame.height * 0.5;

this.radius = Math.min(this.frame.width, this.frame.height) * 0.25;

this.devCount.attr({'x': this.mapPane.cx,
'y': this.mapPane.cy});
}

gap(numDevs) {
Expand Down Expand Up @@ -605,10 +594,6 @@ class ChordView extends View {
let updated = false;
if (elements.indexOf('devices') >= 0) {
this.updateDevices();
if (this.onlineDevs)
this.devCount.attr({'text': ''});
else
this.devCount.attr({'text': 'waiting for devices'});
updated = true;
}
if (elements.indexOf('links') >= 0) {
Expand All @@ -628,8 +613,6 @@ class ChordView extends View {
super.cleanup();

// clean up any objects created only for this view
if (this.devCount)
this.devCount.remove();
graph.links.forEach(function(link) {
if (!link.view)
return;
Expand All @@ -642,6 +625,10 @@ class ChordView extends View {
dev.view.stick.remove();
dev.view.stick = null;
}
if (dev.view.label) {
dev.view.label.remove();
dev.view.label = null;
}
dev.view.unclick();
dev.view.unhover();
});
Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
netifaces==0.11.0
libmapper==2.4.6
libmapper==2.4.11
mappersession==0.0.15

0 comments on commit 2a17a66

Please sign in to comment.