0001-misc-stop-calling-autosave-after-5-errors-65539.patch
wcs/qommon/static/js/qommon.forms.js | ||
---|---|---|
130 | 130 | |
131 | 131 |
if ($('form[data-has-draft]:not([data-autosave=false])').length == 1) { |
132 | 132 |
var last_auto_save = $('form[data-has-draft]').serialize(); |
133 |
var error_counter = 0; |
|
133 | 134 |
function autosave() { |
134 | 135 |
var $form = $('form[data-has-draft]'); |
135 | 136 |
if ($form.hasClass('disabled-during-submit')) return; |
... | ... | |
145 | 146 |
data: new_auto_save, |
146 | 147 |
success: function(json) { |
147 | 148 |
if (json.result == 'success') { |
149 |
error_counter = -1; |
|
148 | 150 |
last_auto_save = new_auto_save; |
149 | 151 |
} |
150 | 152 |
}, |
151 | 153 |
complete: function() { |
154 |
error_counter++; |
|
155 |
if (error_counter > 5) { |
|
156 |
// stop trying to autosave unless there are new changes |
|
157 |
last_auto_save = new_auto_save; |
|
158 |
} |
|
152 | 159 |
autosave_is_running = false; |
153 | 160 |
if (autosave_timeout_id !== null) { |
154 | 161 |
install_autosave(); |
... | ... | |
175 | 182 |
$(window).on('pagehide', function () { |
176 | 183 |
if (autosave_timeout_id !== null && ! $('body').hasClass('autosaving')) { |
177 | 184 |
window.clearTimeout(autosave_timeout_id); |
185 |
autosave_timeout_id = null; |
|
178 | 186 |
autosave(); |
179 | 187 |
} |
180 | 188 |
}); |
... | ... | |
182 | 190 |
$(document).on('visibilitychange', function () { |
183 | 191 |
if (document.visibilityState == 'hidden' && autosave_timeout_id !== null && ! $('body').hasClass('autosaving')) { |
184 | 192 |
window.clearTimeout(autosave_timeout_id); |
193 |
autosave_timeout_id = null; |
|
185 | 194 |
autosave(); |
186 | 195 |
} |
187 | 196 |
}); |
188 |
- |