angular-notify
angular-notify copied to clipboard
Duration set to 0 not work
In line 21
args.duration = args.duration ? args.duration : defaultDuration;
If duration is set to 0, args.duration equals defaultDuration and it violates the doc
duration - Optional. The duration (in milliseconds) of message. A duration of 0 will prevent messages from closing automatically.
Workaround - set duration to any non-empty string. Since 'string' > 0 === false, but 'string' is truthy, it will prevent the timeout code from being triggered.
This is by no means a good solution, but it's a workable temporary workaround.
If you want to take it one step further, you could patch this for your local project globally with the following interceptor (test before using! :) ):
angular.module('myApp').config(function ($provide) {
$provide.decorator('notify', function ($delegate) {
return function (args) {
if (typeof args !== 'object') {
return $delegate(args);
}
if (args.duration === 0) {
// Workaround
args.duration = 'never close';
}
return $delegate(args);
}
});
});
This will prevent things like notify.closeAll() from working, so beware!