Skip to content

Commit

Permalink
Extra debouncing for slow devices #2909 (#2922)
Browse files Browse the repository at this point in the history
Our main debouncing strategy of setting $scope.saving and having angular
disable the button on that value mostly works, but on slower phones
you're able to get more than one action in before Angular gets itself
together.

This doubly-checks to make sure save isn't called more than once.
  • Loading branch information
SCdF authored and garethbowen committed Nov 29, 2016
1 parent d905a22 commit 1e42edb
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 0 deletions.
5 changes: 5 additions & 0 deletions static/js/controllers/contacts-edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,11 @@ var _ = require('underscore');
});

$scope.save = function() {
if ($scope.saving) {
$log.debug('Attempted to call contacts-edit:$scope.save more than once');
return;
}

var form = $scope.enketoContact.formInstance;
var docId = $scope.enketoContact.docId;
$scope.saving = true;
Expand Down
5 changes: 5 additions & 0 deletions static/js/controllers/contacts-report.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,11 @@
};

$scope.save = function() {
if ($scope.saving) {
$log.debug('Attempted to call contacts-report:$scope.save more than once');
return;
}

$scope.saving = true;
Enketo.save($state.params.formId, $scope.form)
.then(function(doc) {
Expand Down
5 changes: 5 additions & 0 deletions static/js/controllers/reports-add.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,11 @@
});

$scope.save = function() {
if ($scope.saving) {
$log.debug('Attempted to call reports-add:$scope.save more than once');
return;
}

$scope.saving = true;
var doc = $scope.selected[0].report;
Enketo.save(doc.form, $scope.form, doc._id)
Expand Down
5 changes: 5 additions & 0 deletions static/js/controllers/tasks-content.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,11 @@
};

$scope.save = function() {
if ($scope.saving) {
$log.debug('Attempted to call tasks-content:$scope.save more than once');
return;
}

$scope.saving = true;
Enketo.save($scope.formId, $scope.form)
.then(function(doc) {
Expand Down

0 comments on commit 1e42edb

Please sign in to comment.