namirasoft-site-react 1.4.329 → 1.4.330
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.
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { NSBarNotificationProps } from "../components/NSBarNotification";
|
|
2
2
|
import { IStorage } from "namirasoft-core";
|
|
3
3
|
export declare class NSNotifier {
|
|
4
|
+
private static mutex_mofify;
|
|
5
|
+
private static mutex_set;
|
|
4
6
|
private storage;
|
|
5
7
|
private setState;
|
|
6
8
|
timeout: number;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import axios from "axios";
|
|
2
2
|
import { NSBarNotificationColor, NotificationType } from "../components/NSBarNotification";
|
|
3
3
|
import { BaseUUID, TimeOperation } from "namirasoft-core";
|
|
4
|
+
import { Mutex } from 'async-mutex';
|
|
4
5
|
export class NSNotifier {
|
|
5
6
|
constructor(storage, setState) {
|
|
6
7
|
this.timeout = 5000;
|
|
@@ -31,22 +32,28 @@ export class NSNotifier {
|
|
|
31
32
|
return ans;
|
|
32
33
|
}
|
|
33
34
|
setNotifications(notifications) {
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
n.expired_at
|
|
35
|
+
NSNotifier.mutex_set.runExclusive(() => {
|
|
36
|
+
notifications.forEach(n => {
|
|
37
|
+
if (!n.expired_at)
|
|
38
|
+
n.expired_at = TimeOperation.millisecondsLater(this.timeout, new Date());
|
|
39
|
+
});
|
|
40
|
+
this.storage.set("ns-notifications", JSON.stringify(notifications));
|
|
41
|
+
this.setState();
|
|
37
42
|
});
|
|
38
|
-
this.storage.set("ns-notifications", JSON.stringify(notifications));
|
|
39
|
-
this.setState();
|
|
40
43
|
}
|
|
41
44
|
delNotification(id) {
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
+
NSNotifier.mutex_mofify.runExclusive(() => {
|
|
46
|
+
let notifications = this.getNotifications();
|
|
47
|
+
notifications = notifications.filter(x => x.id !== id);
|
|
48
|
+
this.setNotifications(notifications);
|
|
49
|
+
});
|
|
45
50
|
}
|
|
46
51
|
notify(message) {
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
52
|
+
NSNotifier.mutex_mofify.runExclusive(() => {
|
|
53
|
+
let notifications = this.getNotifications();
|
|
54
|
+
notifications.push(message);
|
|
55
|
+
this.setNotifications(notifications);
|
|
56
|
+
});
|
|
50
57
|
setTimeout(() => {
|
|
51
58
|
this.delNotification(message.id);
|
|
52
59
|
}, this.timeout);
|
|
@@ -79,4 +86,6 @@ export class NSNotifier {
|
|
|
79
86
|
this.notify({ id, text, type: NotificationType.Error, color: NSBarNotificationColor.RED });
|
|
80
87
|
}
|
|
81
88
|
}
|
|
89
|
+
NSNotifier.mutex_mofify = new Mutex();
|
|
90
|
+
NSNotifier.mutex_set = new Mutex();
|
|
82
91
|
//# sourceMappingURL=NSNotifier.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NSNotifier.js","sourceRoot":"","sources":["../../src/routing/NSNotifier.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,sBAAsB,EAA0B,gBAAgB,EAAE,MAAM,iCAAiC,CAAC;AACnH,OAAO,EAAE,QAAQ,EAAY,aAAa,EAAE,MAAM,iBAAiB,CAAC;
|
|
1
|
+
{"version":3,"file":"NSNotifier.js","sourceRoot":"","sources":["../../src/routing/NSNotifier.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,sBAAsB,EAA0B,gBAAgB,EAAE,MAAM,iCAAiC,CAAC;AACnH,OAAO,EAAE,QAAQ,EAAY,aAAa,EAAE,MAAM,iBAAiB,CAAC;AACpE,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AAEpC,MAAM,OAAO,UAAU;IAOnB,YAAY,OAAiB,EAAE,QAAoB;QAD5C,YAAO,GAAW,IAAI,CAAC;QAG1B,IA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K,CAAC,QAAQ,0CAAE,IAAI;oBACpB,IAAI,GAAG,KAAK,CAAC,QAAQ,CAAC,IAAI,CAAC;QACvC,CAAC;;YAEG,IAAI,GAAG,KAAK,CAAC;QACjB,IAAI,CAAC,MAAM,CAAC,EAAE,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,gBAAgB,CAAC,KAAK,EAAE,KAAK,EAAE,sBAAsB,CAAC,GAAG,EAAE,CAAC,CAAC;IAC/F,CAAC;;AArGc,uBAAY,GAAU,IAAI,KAAK,EAAE,AAArB,CAAsB;AAClC,oBAAS,GAAU,IAAI,KAAK,EAAE,AAArB,CAAsB"}
|
package/package.json
CHANGED
|
@@ -1,9 +1,12 @@
|
|
|
1
1
|
import axios from "axios";
|
|
2
2
|
import { NSBarNotificationColor, NSBarNotificationProps, NotificationType } from "../components/NSBarNotification";
|
|
3
3
|
import { BaseUUID, IStorage, TimeOperation } from "namirasoft-core";
|
|
4
|
+
import { Mutex } from 'async-mutex';
|
|
4
5
|
|
|
5
6
|
export class NSNotifier
|
|
6
7
|
{
|
|
8
|
+
private static mutex_mofify: Mutex = new Mutex();
|
|
9
|
+
private static mutex_set: Mutex = new Mutex();
|
|
7
10
|
private storage: IStorage;
|
|
8
11
|
private setState: () => void;
|
|
9
12
|
public timeout: number = 5000;
|
|
@@ -40,25 +43,34 @@ export class NSNotifier
|
|
|
40
43
|
}
|
|
41
44
|
setNotifications(notifications: NSBarNotificationProps[]): void
|
|
42
45
|
{
|
|
43
|
-
|
|
46
|
+
NSNotifier.mutex_set.runExclusive(() =>
|
|
44
47
|
{
|
|
45
|
-
|
|
46
|
-
|
|
48
|
+
notifications.forEach(n =>
|
|
49
|
+
{
|
|
50
|
+
if (!n.expired_at)
|
|
51
|
+
n.expired_at = TimeOperation.millisecondsLater(this.timeout, new Date());
|
|
52
|
+
});
|
|
53
|
+
this.storage.set("ns-notifications", JSON.stringify(notifications));
|
|
54
|
+
this.setState();
|
|
47
55
|
});
|
|
48
|
-
this.storage.set("ns-notifications", JSON.stringify(notifications));
|
|
49
|
-
this.setState();
|
|
50
56
|
}
|
|
51
57
|
delNotification(id: string): void
|
|
52
58
|
{
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
59
|
+
NSNotifier.mutex_mofify.runExclusive(() =>
|
|
60
|
+
{
|
|
61
|
+
let notifications: NSBarNotificationProps[] = this.getNotifications();
|
|
62
|
+
notifications = notifications.filter(x => x.id !== id);
|
|
63
|
+
this.setNotifications(notifications);
|
|
64
|
+
});
|
|
56
65
|
}
|
|
57
66
|
private notify(message: NSBarNotificationProps)
|
|
58
67
|
{
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
68
|
+
NSNotifier.mutex_mofify.runExclusive(() =>
|
|
69
|
+
{
|
|
70
|
+
let notifications: NSBarNotificationProps[] = this.getNotifications();
|
|
71
|
+
notifications.push(message);
|
|
72
|
+
this.setNotifications(notifications);
|
|
73
|
+
});
|
|
62
74
|
setTimeout(() =>
|
|
63
75
|
{
|
|
64
76
|
this.delNotification(message.id);
|