Skip to content

Commit

Permalink
Merge pull request #4313 from jaswilli/issue-4309
Browse files Browse the repository at this point in the history
Cancel pending auto-save if manual save occurs.
  • Loading branch information
ErisDS committed Oct 20, 2014
2 parents 78d845d + 6ef58a9 commit 7e123c8
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 6 deletions.
3 changes: 1 addition & 2 deletions core/client/components/gh-codemirror.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,7 @@ var onChangeHandler = function (cm, changeObj) {

cm.component.set('value', cm.getValue());

// Send an action notifying a 5 second pause in typing/changes.
Ember.run.debounce(component, 'sendAction', 'typingPause', 3000);
component.sendAction('typingPause');
};

var onScrollHandler = function (cm) {
Expand Down
15 changes: 13 additions & 2 deletions core/client/mixins/editor-base-controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -194,9 +194,16 @@ var EditorControllerMixin = Ember.Mixin.create(MarkerManager, {
var status = this.get('willPublish') ? 'published' : 'draft',
prevStatus = this.get('status'),
isNew = this.get('isNew'),
autoSaveId = this.get('autoSaveId'),
self = this;

options = options || {};

if(autoSaveId) {
Ember.run.cancel(autoSaveId);
this.set('autoSaveId', null);
}

self.notifications.closePassive();

// ensure an incomplete tag is finalised before save
Expand Down Expand Up @@ -296,13 +303,17 @@ var EditorControllerMixin = Ember.Mixin.create(MarkerManager, {

autoSave: function () {
if (this.get('model.isDraft')) {
this.send('save', {silent: true, disableNProgress: true});
var autoSaveId;

autoSaveId = Ember.run.debounce(this, 'send', 'save', {silent: true, disableNProgress: true}, 3000);

this.set('autoSaveId', autoSaveId);
}
},

autoSaveNew: function () {
if (this.get('isNew')) {
this.send('autoSave');
this.send('save', {silent: true, disableNProgress: true});
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions core/test/functional/base.js
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@ casper.on('remote.message', function (msg) {
// output any errors
casper.on('error', function (msg, trace) {
casper.echoConcise('ERROR, ' + msg, 'ERROR');
if (trace) {
if (trace && trace[0]) {
casper.echoConcise('file: ' + trace[0].file, 'WARNING');
casper.echoConcise('line: ' + trace[0].line, 'WARNING');
casper.echoConcise('function: ' + trace[0]['function'], 'WARNING');
Expand All @@ -258,7 +258,7 @@ casper.on('error', function (msg, trace) {
// output any page errors
casper.on('page.error', function (msg, trace) {
casper.echoConcise('PAGE ERROR: ' + msg, 'ERROR');
if (trace) {
if (trace && trace[0]) {
casper.echoConcise('file: ' + trace[0].file, 'WARNING');
casper.echoConcise('line: ' + trace[0].line, 'WARNING');
casper.echoConcise('function: ' + trace[0]['function'], 'WARNING');
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@
"devDependencies": {
"blanket": "~1.1.6",
"bower": "~1.3.10",
"ember-template-compiler": "1.7.0",
"grunt": "~0.4.5",
"grunt-cli": "~0.1.13",
"grunt-autoprefixer": "1.0.1",
Expand Down

0 comments on commit 7e123c8

Please sign in to comment.