Configure label and tags only if changed

This commit is contained in:
Girish Ramakrishnan
2019-09-27 13:38:30 -07:00
parent b90550d6ba
commit 6788d37b6f

View File

@@ -154,13 +154,17 @@ angular.module('Application').controller('AppController', ['$scope', '$location'
}, 1000);
}
// TODO break those apart
Client.configureApp($scope.app.id, 'label', { label: $scope.display.label }, function (error) {
var NOOP = function (next) { return next(); };
var configureLabel = $scope.display.label === $scope.app.label ? NOOP : Client.configureApp.bind(null, $scope.app.id, 'label', { label: $scope.display.label });
configureLabel(function (error) {
if (error) return Client.error(error);
var tags = $scope.display.tags.split(',').map(function (t) { return t.trim(); }).filter(function (t) { return !!t; });
Client.configureApp($scope.app.id, 'tags', { tags: tags }, function (error) {
var configureTags = angular.equals(tags, $scope.app.tags) ? NOOP : Client.configureApp.bind(null, $scope.app.id, 'tags', { tags: tags });
configureTags(function (error) {
if (error) return Client.error(error);
// skip if icon is unchanged