@homecode/ui 4.27.1 → 4.27.2
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.
|
@@ -7,7 +7,7 @@ import C from './Notifications.constants.json.js';
|
|
|
7
7
|
const SHOW_TIME = 5000;
|
|
8
8
|
const STORE = createStore('notifications', {
|
|
9
9
|
items: [],
|
|
10
|
-
|
|
10
|
+
autoHide: [],
|
|
11
11
|
data: {},
|
|
12
12
|
paused: false,
|
|
13
13
|
show(data) {
|
|
@@ -18,9 +18,8 @@ const STORE = createStore('notifications', {
|
|
|
18
18
|
createdAt: Date.now(),
|
|
19
19
|
};
|
|
20
20
|
Time.after(C.ANIMATION_DURATION, () => (this.data[id].visible = true));
|
|
21
|
-
if (data.
|
|
22
|
-
this.
|
|
23
|
-
}
|
|
21
|
+
if (data.autoHide !== false)
|
|
22
|
+
this.autoHide.push(id);
|
|
24
23
|
return id;
|
|
25
24
|
},
|
|
26
25
|
pause() {
|
|
@@ -29,7 +28,7 @@ const STORE = createStore('notifications', {
|
|
|
29
28
|
},
|
|
30
29
|
unpause() {
|
|
31
30
|
const pauseTime = Date.now() - this.pausedAt;
|
|
32
|
-
this.
|
|
31
|
+
this.autoHide.forEach(id => {
|
|
33
32
|
this.data[id].createdAt += pauseTime;
|
|
34
33
|
});
|
|
35
34
|
this.paused = false;
|
|
@@ -39,18 +38,18 @@ const STORE = createStore('notifications', {
|
|
|
39
38
|
Time.after(C.ANIMATION_DURATION, () => this.remove(id));
|
|
40
39
|
},
|
|
41
40
|
remove(id) {
|
|
42
|
-
spliceWhere(this.
|
|
41
|
+
spliceWhere(this.autoHide, id);
|
|
43
42
|
spliceWhere(this.items, id);
|
|
44
43
|
delete this.data[id];
|
|
45
44
|
},
|
|
46
45
|
});
|
|
47
46
|
// worker
|
|
48
47
|
Time.every(50, function tick() {
|
|
49
|
-
const { paused,
|
|
50
|
-
if (paused ||
|
|
48
|
+
const { paused, autoHide, data } = STORE;
|
|
49
|
+
if (paused || autoHide.length === 0) {
|
|
51
50
|
return;
|
|
52
51
|
}
|
|
53
|
-
const id =
|
|
52
|
+
const id = autoHide[0]; // TODO: move trough all autoHide until some will !readyToHide
|
|
54
53
|
const item = data[id];
|
|
55
54
|
const readyToHide = Date.now() - item.createdAt > SHOW_TIME;
|
|
56
55
|
if (item.visible && readyToHide) {
|
|
@@ -1,9 +1,10 @@
|
|
|
1
|
+
import { ItemParams } from './Notifications.types';
|
|
1
2
|
declare const STORE: import("justorm/dist/esm/proxy").ProxyStore<{
|
|
2
3
|
items: string[];
|
|
3
|
-
|
|
4
|
+
autoHide: string[];
|
|
4
5
|
data: {};
|
|
5
6
|
paused: boolean;
|
|
6
|
-
show(data:
|
|
7
|
+
show(data: ItemParams): any;
|
|
7
8
|
pause(): void;
|
|
8
9
|
unpause(): void;
|
|
9
10
|
close(id: any): void;
|