zavadil-ts-common 1.2.60 → 1.2.62
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/component/UserAlerts.d.ts +2 -2
- package/dist/index.d.ts +3 -3
- package/dist/index.esm.js +1 -1
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/type/UserAlert.d.ts +1 -1
- package/package.json +1 -1
- package/src/component/UserAlerts.ts +10 -9
- package/src/type/UserAlert.ts +1 -1
package/package.json
CHANGED
@@ -6,7 +6,7 @@ export class UserAlerts {
|
|
6
6
|
|
7
7
|
private maxAlerts: number;
|
8
8
|
|
9
|
-
public
|
9
|
+
public maxVisibilityMs: number;
|
10
10
|
|
11
11
|
private em: EventManager;
|
12
12
|
|
@@ -14,9 +14,9 @@ export class UserAlerts {
|
|
14
14
|
|
15
15
|
public visibleAlerts: Array<UserAlert>;
|
16
16
|
|
17
|
-
constructor(maxAlerts: number =
|
17
|
+
constructor(maxAlerts: number = 20, maxVisibilityMs: number = 7000) {
|
18
18
|
this.maxAlerts = maxAlerts;
|
19
|
-
this.
|
19
|
+
this.maxVisibilityMs = maxVisibilityMs;
|
20
20
|
this.em = new EventManager();
|
21
21
|
this.alerts = [];
|
22
22
|
this.visibleAlerts = [];
|
@@ -53,11 +53,12 @@ export class UserAlerts {
|
|
53
53
|
updateVisibility() {
|
54
54
|
this.visibleAlerts.forEach(
|
55
55
|
a => {
|
56
|
-
const
|
57
|
-
|
58
|
-
|
56
|
+
const elapsedMs = DateUtil.getSinceDurationMs(a.time) || this.maxVisibilityMs;
|
57
|
+
const remainsMs = this.maxVisibilityMs - elapsedMs;
|
58
|
+
if (remainsMs > 0) {
|
59
|
+
a.remainsMs = remainsMs;
|
59
60
|
} else {
|
60
|
-
a.
|
61
|
+
a.remainsMs = undefined;
|
61
62
|
this.hide(a);
|
62
63
|
}
|
63
64
|
}
|
@@ -71,8 +72,8 @@ export class UserAlerts {
|
|
71
72
|
};
|
72
73
|
|
73
74
|
add(alert: UserAlert) {
|
74
|
-
if (alert.
|
75
|
-
alert.
|
75
|
+
if (alert.remainsMs === undefined) {
|
76
|
+
alert.remainsMs = this.maxVisibilityMs;
|
76
77
|
}
|
77
78
|
this.alerts.push(alert);
|
78
79
|
this.visibleAlerts.push(alert);
|
package/src/type/UserAlert.ts
CHANGED