Browse Source

Add is_ephemeral parameter

JC Brand 2 months ago
parent
commit
044173bdc3
2 changed files with 9 additions and 5 deletions
  1. 7 4
      src/plugins/modal/modal.js
  2. 2 1
      src/types/plugins/modal/modal.d.ts

+ 7 - 4
src/plugins/modal/modal.js

@@ -126,12 +126,15 @@ class BaseModal extends CustomElement {
     /**
      * @param {string} message
      * @param {'primary'|'secondary'|'danger'} type
+     * @param {boolean} [is_ephemeral=true]
      */
-    alert(message, type = 'primary') {
+    alert(message, type = 'primary', is_ephemeral = true) {
         this.model.set('alert', { message, type });
-        setTimeout(() => {
-            this.model.set('alert', undefined);
-        }, 5000);
+        if (is_ephemeral) {
+            setTimeout(() => {
+                this.model.set('alert', undefined);
+            }, 5000);
+        }
     }
 
     async show() {

+ 2 - 1
src/types/plugins/modal/modal.d.ts

@@ -47,8 +47,9 @@ declare class BaseModal extends CustomElement {
     /**
      * @param {string} message
      * @param {'primary'|'secondary'|'danger'} type
+     * @param {boolean} [is_ephemeral=true]
      */
-    alert(message: string, type?: "primary" | "secondary" | "danger"): void;
+    alert(message: string, type?: "primary" | "secondary" | "danger", is_ephemeral?: boolean): void;
     show(): Promise<void>;
     #private;
 }