Skip to content

Commit

Permalink
Cache custom profiles
Browse files Browse the repository at this point in the history
  • Loading branch information
Phyks committed Oct 8, 2019
1 parent a77413e commit f331773
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
13 changes: 11 additions & 2 deletions js/control/Profile.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,11 +82,15 @@ BR.Profile = L.Evented.extend({
$(button).button('uploading');
evt.preventDefault();

var that = this;
this.fire('update', {
profileText: profile,
callback: function() {
callback: function(err, profileId, profileText) {
$(button).button('reset');
$(button).blur();
if (!err) {
that.cache[profileId] = profileText;
}
}
});
},
Expand Down Expand Up @@ -116,9 +120,14 @@ BR.Profile = L.Evented.extend({

_save: function(evt) {
var profileText = this._buildCustomProfile();
var that = this;
this.fire('update', {
profileText: profileText,
callback: function() {}
callback: function(err, profileId, profileText) {
if (!err) {
that.cache[profileId] = profileText;
}
}
});
},

Expand Down
2 changes: 1 addition & 1 deletion js/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@
}

if (evt.callback) {
evt.callback();
evt.callback(err, profileId, evt.profileText);
}
});
});
Expand Down

0 comments on commit f331773

Please sign in to comment.