Merge pull request #25035 from owncloud/stable9-err-reload-delay
[stable9] Delay reloading the page if an ajax error occurs, show notification
This commit is contained in:
commit
72b76228fc
|
@ -752,7 +752,8 @@ var OC={
|
||||||
// sometimes "beforeunload" happens later, so need to defer the reload a bit
|
// sometimes "beforeunload" happens later, so need to defer the reload a bit
|
||||||
setTimeout(function() {
|
setTimeout(function() {
|
||||||
if (!self._userIsNavigatingAway && !self._reloadCalled) {
|
if (!self._userIsNavigatingAway && !self._reloadCalled) {
|
||||||
OC.reload();
|
OC.Notification.show(t('core', 'Problem loading page, reloading in 5 seconds'));
|
||||||
|
setTimeout(OC.reload, 5000);
|
||||||
// only call reload once
|
// only call reload once
|
||||||
self._reloadCalled = true;
|
self._reloadCalled = true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -935,10 +935,13 @@ describe('Core base tests', function() {
|
||||||
});
|
});
|
||||||
describe('global ajax errors', function() {
|
describe('global ajax errors', function() {
|
||||||
var reloadStub, ajaxErrorStub, clock;
|
var reloadStub, ajaxErrorStub, clock;
|
||||||
|
var notificationStub;
|
||||||
|
var waitTimeMs = 6000;
|
||||||
|
|
||||||
beforeEach(function() {
|
beforeEach(function() {
|
||||||
clock = sinon.useFakeTimers();
|
clock = sinon.useFakeTimers();
|
||||||
reloadStub = sinon.stub(OC, 'reload');
|
reloadStub = sinon.stub(OC, 'reload');
|
||||||
|
notificationStub = sinon.stub(OC.Notification, 'show');
|
||||||
// unstub the error processing method
|
// unstub the error processing method
|
||||||
ajaxErrorStub = OC._processAjaxError;
|
ajaxErrorStub = OC._processAjaxError;
|
||||||
ajaxErrorStub.restore();
|
ajaxErrorStub.restore();
|
||||||
|
@ -946,6 +949,7 @@ describe('Core base tests', function() {
|
||||||
});
|
});
|
||||||
afterEach(function() {
|
afterEach(function() {
|
||||||
reloadStub.restore();
|
reloadStub.restore();
|
||||||
|
notificationStub.restore();
|
||||||
clock.restore();
|
clock.restore();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -970,7 +974,7 @@ describe('Core base tests', function() {
|
||||||
$(document).trigger(new $.Event('ajaxError'), xhr);
|
$(document).trigger(new $.Event('ajaxError'), xhr);
|
||||||
|
|
||||||
// trigger timers
|
// trigger timers
|
||||||
clock.tick(1000);
|
clock.tick(waitTimeMs);
|
||||||
|
|
||||||
if (expectedCall) {
|
if (expectedCall) {
|
||||||
expect(reloadStub.calledOnce).toEqual(true);
|
expect(reloadStub.calledOnce).toEqual(true);
|
||||||
|
@ -986,7 +990,7 @@ describe('Core base tests', function() {
|
||||||
$(document).trigger(new $.Event('ajaxError'), xhr);
|
$(document).trigger(new $.Event('ajaxError'), xhr);
|
||||||
|
|
||||||
// trigger timers
|
// trigger timers
|
||||||
clock.tick(1000);
|
clock.tick(waitTimeMs);
|
||||||
|
|
||||||
expect(reloadStub.calledOnce).toEqual(true);
|
expect(reloadStub.calledOnce).toEqual(true);
|
||||||
});
|
});
|
||||||
|
@ -997,9 +1001,17 @@ describe('Core base tests', function() {
|
||||||
|
|
||||||
$(document).trigger(new $.Event('ajaxError'), xhr);
|
$(document).trigger(new $.Event('ajaxError'), xhr);
|
||||||
|
|
||||||
clock.tick(1000);
|
clock.tick(waitTimeMs);
|
||||||
expect(reloadStub.notCalled).toEqual(true);
|
expect(reloadStub.notCalled).toEqual(true);
|
||||||
});
|
});
|
||||||
|
it('displays notification', function() {
|
||||||
|
var xhr = { status: 401 };
|
||||||
|
|
||||||
|
$(document).trigger(new $.Event('ajaxError'), xhr);
|
||||||
|
|
||||||
|
clock.tick(waitTimeMs);
|
||||||
|
expect(notificationStub.calledOnce).toEqual(true);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue