Skip to content

Conversation

@danxuliu
Copy link
Member

This fixes a regression introduced in #15124

Before OC.Notification was changed to use Toastify show() internally called showHtml(), which set the timeout to 0 if none was given. After the move to Toastify show() called OCP.Toast directly without passing any timeout, so the default timeout of OCP.Toast, which is 7 seconds, was used instead. Also, after the move to Toastify showHtml() passed the infinite timeout to OCP.Toast, but only if it was explicitly set to 0 due to using a strict comparison, so again when no timeout was given the notification was also hidden after 7 seconds. Now both show() and showHtml() show the notification indefinitely (or until hide() is explicitly called) if no timeout is given.

Besides the fix itself I have also fixed and extended a bit the unit tests.

danxuliu added 4 commits July 26, 2019 18:46
Tje jQuery object created through "$('#testArea .toastify')" will be
always defined even if no elements were found, so the check does not
really work; instead, it should be checked the number of elements found.

Signed-off-by: Daniel Calviño Sánchez <danxuliu@gmail.com>
"showTemporary()" when a timeout was given was being tested along with
the "show()" tests; now there are two separate tests when a timeout is
given, one for "showTemporary()" and one for "show()".

Signed-off-by: Daniel Calviño Sánchez <danxuliu@gmail.com>
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>
Signed-off-by: Daniel Calviño Sánchez <danxuliu@gmail.com>
@danxuliu danxuliu added this to the Nextcloud 17 milestone Jul 26, 2019
Copy link
Member

@rullzer rullzer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

More tests than code.awesome :)

@rullzer rullzer merged commit d6bb261 into master Jul 28, 2019
@delete-merged-branch delete-merged-branch bot deleted the fix-default-timeouts-in-oc-notification branch July 28, 2019 18:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants