diff options
author | Daniel Calviño Sánchez <danxuliu@gmail.com> | 2019-07-26 18:00:07 +0200 |
---|---|---|
committer | Daniel Calviño Sánchez <danxuliu@gmail.com> | 2019-07-26 18:46:59 +0200 |
commit | 03f2e8a10e7c900b7a66683798309010a9428b16 (patch) | |
tree | 5d0712b5be99cb50d1035b3bc10c8fe27a70b1ef /core/src/OC/notification.js | |
parent | 14006b548ec76a351c2adfeb27cc2aebaf8cf7dc (diff) | |
download | nextcloud-server-03f2e8a10e7c900b7a66683798309010a9428b16.tar.gz nextcloud-server-03f2e8a10e7c900b7a66683798309010a9428b16.zip |
Fix default timeouts in OC.Notification
When no timeout was given "show()" used the default timeout of
"OCP.Toast", which is 7 seconds instead of indefinitely as stated in the
documentation of "show()". "showHtml()" should also indefinitely show
the notification if no timeout is given, but due to the strict
comparison the notification was indefinitely shown only when a timeout
of 0 was explicitly given. Now both methods show the notification
indefinitely (or until it is explicitly hidden) when no timeout is
given.
The unit tests did not catch this error because "showHtml()" had no
tests (as before the move to Toastify it was called from "show()" and
thus implicitly tested), and because "show()" verified that "hide()" was
not called after some time; "hide()" is no longer called from "show()"
since "OCP.Toast" is used internally, so the test always passed even if
the notification was indeed hidden. Now the test is based on whether the
element is found or not, and explicit tests were added too for
"showHtml()".
Signed-off-by: Daniel Calviño Sánchez <danxuliu@gmail.com>
Diffstat (limited to 'core/src/OC/notification.js')
-rw-r--r-- | core/src/OC/notification.js | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/core/src/OC/notification.js b/core/src/OC/notification.js index 427c857f7c3..f31b37e4ba4 100644 --- a/core/src/OC/notification.js +++ b/core/src/OC/notification.js @@ -97,7 +97,7 @@ export default { showHtml: function (html, options) { options = options || {} options.isHTML = true - options.timeout = (options.timeout === 0) ? -1 : options.timeout + options.timeout = (!options.timeout) ? -1 : options.timeout const toast = window.OCP.Toast.message(html, options) return $(toast.toastElement) }, @@ -113,6 +113,8 @@ export default { * @deprecated 17.0.0 use OCP.Toast */ show: function (text, options) { + options = options || {}; + options.timeout = (!options.timeout) ? -1 : options.timeout; const toast = window.OCP.Toast.message(text, options); return $(toast.toastElement); }, |