summaryrefslogtreecommitdiffstats
path: root/core/js
diff options
context:
space:
mode:
authorVincent Petry <pvince81@owncloud.com>2016-06-09 16:15:17 +0200
committerVincent Petry <pvince81@owncloud.com>2016-06-09 16:15:17 +0200
commit72b76228fc6f2a9e966751e81d94bfca9412c6a4 (patch)
tree66b5d7c41a0821e9cc2a6a717c2c7bc6758170d8 /core/js
parent9dff5501e887f2080192356f704d9c922b550abb (diff)
parent3f16ce740348e87fa015a825164a49151be554d9 (diff)
downloadnextcloud-server-72b76228fc6f2a9e966751e81d94bfca9412c6a4.tar.gz
nextcloud-server-72b76228fc6f2a9e966751e81d94bfca9412c6a4.zip
Merge pull request #25035 from owncloud/stable9-err-reload-delay
[stable9] Delay reloading the page if an ajax error occurs, show notification
Diffstat (limited to 'core/js')
-rw-r--r--core/js/js.js3
-rw-r--r--core/js/tests/specs/coreSpec.js18
2 files changed, 17 insertions, 4 deletions
diff --git a/core/js/js.js b/core/js/js.js
index b74775a935f..be913c6f04c 100644
--- a/core/js/js.js
+++ b/core/js/js.js
@@ -752,7 +752,8 @@ var OC={
// sometimes "beforeunload" happens later, so need to defer the reload a bit
setTimeout(function() {
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
self._reloadCalled = true;
}
diff --git a/core/js/tests/specs/coreSpec.js b/core/js/tests/specs/coreSpec.js
index f18ecbc1a44..0296a3675a3 100644
--- a/core/js/tests/specs/coreSpec.js
+++ b/core/js/tests/specs/coreSpec.js
@@ -935,10 +935,13 @@ describe('Core base tests', function() {
});
describe('global ajax errors', function() {
var reloadStub, ajaxErrorStub, clock;
+ var notificationStub;
+ var waitTimeMs = 6000;
beforeEach(function() {
clock = sinon.useFakeTimers();
reloadStub = sinon.stub(OC, 'reload');
+ notificationStub = sinon.stub(OC.Notification, 'show');
// unstub the error processing method
ajaxErrorStub = OC._processAjaxError;
ajaxErrorStub.restore();
@@ -946,6 +949,7 @@ describe('Core base tests', function() {
});
afterEach(function() {
reloadStub.restore();
+ notificationStub.restore();
clock.restore();
});
@@ -970,7 +974,7 @@ describe('Core base tests', function() {
$(document).trigger(new $.Event('ajaxError'), xhr);
// trigger timers
- clock.tick(1000);
+ clock.tick(waitTimeMs);
if (expectedCall) {
expect(reloadStub.calledOnce).toEqual(true);
@@ -986,7 +990,7 @@ describe('Core base tests', function() {
$(document).trigger(new $.Event('ajaxError'), xhr);
// trigger timers
- clock.tick(1000);
+ clock.tick(waitTimeMs);
expect(reloadStub.calledOnce).toEqual(true);
});
@@ -997,9 +1001,17 @@ describe('Core base tests', function() {
$(document).trigger(new $.Event('ajaxError'), xhr);
- clock.tick(1000);
+ clock.tick(waitTimeMs);
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);
+ });
});
});