♻️ PMGR: Reuse notification

So far we were constantly removing and recreating a notification on each
plugin manager log event. We now only create the notification once and
then reuse/update it.

Potentially related to #3729
This commit is contained in:
Gina Häußge committed 2020-09-15 16:07:16 +02:00
1 parent ec4e2c7193
commit 80f2ab86c1
2 files changed
+25 -10

No files matched your search

@@ -992,19 +992,25 @@ $(function() {
var options = {
title: title,
text: text,
type: type
type: type,
hide: false
};
if (self.logNotification !== undefined) {
self.logNotification.remove();
}
if (confirm !== undefined) {
options.confirm = confirm;
options.hide = false;
self.logNotification = PNotify.singleButtonNotify(options);
if (self.logNotification === undefined) {
self.logNotification = PNotify.singleButtonNotify(options);
} else {
self.logNotification.update(options);
self.logNotification = PNotify.fixSingleButton(self.logNotification, options);
}
} else {
self.logNotification = new PNotify(options);
if (self.logNotification === undefined) {
self.logNotification = new PNotify(options);
} else {
self.logNotification.update(options);
}
}
};
+11 -2
View File
@@ -250,8 +250,7 @@ $(function() {
params.auto_display = false;
var notify = new PNotify(params);
notify.options.confirm.buttons = [notify.options.confirm.buttons[0]];
notify.modules.confirm.makeDialog(notify, notify.options.confirm);
notify = PNotify.fixSingleButton(notify, options);
if (autoDisplay) {
notify.open();
@@ -259,6 +258,16 @@ $(function() {
return notify;
};
PNotify.fixSingleButton = function(notify, options) {
if (!options.confirm || !options.confirm.buttons || !options.confirm.buttons.length) {
return notify;
}
notify.options.confirm.buttons = [notify.options.confirm.buttons[0]];
notify.modules.confirm.makeDialog(notify, notify.options.confirm);
return notify;
}
//~~ Initialize view models
// the view model map is our basic look up table for dependencies that may be injected into other view models