MCPcopy Create free account
hub / github.com/Monogatari/Monogatari / constructor

Method constructor

src/actions/Notify.ts:43–77  ·  view source on GitHub ↗
([show, type, name, time]: string[])

Source from the content-addressed store, hash-verified

41 time: number | undefined;
42
43 constructor([show, type, name, time]: string[]) {
44 super();
45
46 this.hasPermission = false;
47
48 // First check if HTML5 notifications are available
49 if (!('Notification' in window)) {
50 console.warn('Notifications are not supported in this platform.');
51 }
52
53 // Finally check if the given notification exists in the object
54 if (typeof Notify.notifications(name) !== 'undefined') {
55 this.notification = Object.assign({}, Notify.notifications(name));
56
57 if (typeof time !== 'undefined') {
58 if (!isNaN(Number(time))) {
59 this.time = parseInt(time);
60 } else {
61 FancyError.show('action:notification:invalid_time', {
62 time: time,
63 statement: `<code class='language=javascript'>"${this._statement}"</code>`,
64 label: this.engine.state('label'),
65 step: this.engine.state('step')
66 });
67 }
68 }
69 } else {
70 FancyError.show('action:notification:not_found', {
71 name: name,
72 availableNotifications: Object.keys(Notify.notifications()),
73 label: this.engine.state('label'),
74 step: this.engine.state('step')
75 });
76 }
77 }
78
79 override async willApply(): Promise<void> {
80 if (!this.notification) {

Callers

nothing calls this directly

Calls 4

notificationsMethod · 0.80
stateMethod · 0.80
keysMethod · 0.65
showMethod · 0.45

Tested by

no test coverage detected