• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

svrooij / node-sonos-ts / 13501526796

24 Feb 2025 03:22PM UTC coverage: 67.652% (-11.0%) from 78.628%
13501526796

Pull #202

github

web-flow
Merge 728bfb301 into c6d6e5d33
Pull Request #202: Feature/upgrade

748 of 1157 branches covered (64.65%)

Branch coverage included in aggregate %.

1471 of 2123 relevant lines covered (69.29%)

66.63 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

20.0
/src/models/notificationQueue.ts
1
import { PlayNotificationOptions, PlayTtsOptions } from './requests';
2

3
export interface PlayNotificationTwoOptions extends PlayNotificationOptions {
4

5
  /**
6
   *
7
   */
8
  resolveAfterRevert?: boolean;
9

10
  /**
11
    * In case no other timeout given this will result in 30 Minutes Default Timeout for Playing time only
12
    */
13
  defaultTimeout?: number;
14

15
  /**
16
    * This timeout starts as soon as this item is played next in the queue.
17
    * Thus in case of an error resolving the PlayNotificationCall with false.
18
    */
19
  specificTimeout?: number;
20

21
  /**
22
    * If an error occurs playing a notification queue, this flag would prevent the error from bubbling to your main application.
23
    */
24
  catchQueueErrors?: boolean;
25
}
26

27
export interface PlayTtsTwoOptions extends PlayTtsOptions {
28
  /**
29
 *
30
 * @deprecated Experimental feature, please dont depend on this
31
 */
32
  resolveAfterRevert?: boolean;
33

34
  /**
35
    * In case no other timeout given this will result in 30 Minutes Default Timeout for Playing time only
36
    */
37
  defaultTimeout?: number;
38

39
  /**
40
    * This timeout starts as soon as this item is played next in the queue.
41
    * Thus in case of an error resolving the PlayNotificationCall with false.
42
    */
43
  specificTimeout?: number;
44

45
  /**
46
    * If an error occurs playing a notification queue, this flag would prevent the error from bubbling to your main application.
47
    *
48
    */
49
  catchQueueErrors?: boolean;
50
}
51

52
export interface NotificationQueueItem {
53
  /**
54
   * Desired PlayNotificationOptions
55
   *
56
   * @type {number}
57
   */
58
  options: PlayNotificationTwoOptions;
59

60
  /**
61
   * The Resolve Promise we have to resolve once finished successfully
62
   *
63
   * @type {(reject: boolean | PromiseLike<boolean>) => void}
64
   */
65
  resolve: (resolve: boolean | PromiseLike<boolean>) => void;
66

67
  /**
68
   * The Reject Promise we have to resolve once finished with failure
69
   *
70
   * @type {(reject: boolean | PromiseLike<boolean>) => void}
71
   */
72
  reject: (reject: boolean | PromiseLike<boolean>) => void;
73

74
  /**
75
   * Whether we should only resolve the promise when we reverted correctly
76
   *
77
   * @type {boolean}
78
   */
79
  resolveAfterRevert: boolean;
80

81
  /**
82
   * Object with details regarding the timeout for this queue item
83
   *
84
   * @type {NotificationQueueTimeoutItem}
85
   */
86
  generalTimeout?: NotificationQueueTimeoutItem;
87

88
  /**
89
   * Object with details regarding the timeout for this specific queue item (Starting when this is Queue Item becomes first)
90
   *
91
   * @type {NotificationQueueTimeoutItem}
92
   */
93
  individualTimeout?: NotificationQueueTimeoutItem;
94
}
95

96
export class NotificationQueueTimeoutItem {
5✔
97
  public constructor(
98
    /**
99
    * The timeout reference to clear if anything is okay
100
    *
101
    * @type {NotificationQueueTimeoutItem}
102
    */
103
    public timeout: NodeJS.Timeout,
×
104

105
    /**
106
    * The timestamp when the timeout will fire
107
    *
108
    * @type {NotificationQueueTimeoutItem}
109
    */
110
    public fireTime: number,
×
111
  ) { }
112

113
  public timeLeft(): number {
114
    return this.fireTime - (new Date()).getTime();
×
115
  }
116
}
117

118
export class NotificationQueue {
5✔
119
  public queue: NotificationQueueItem[] = [];
×
120

121
  public promisesToResolve: Array<{
×
122
    promise: (resolve: boolean | PromiseLike<boolean>) => void,
123
    value: boolean,
124
    timeout?: NotificationQueueTimeoutItem,
125
  }> = [];
126

127
  public playing = false;
×
128

129
  /**
130
  * Whether any item in the Queue changed the volume
131
  *
132
  * @type {boolean}
133
  */
134
  public volumeChanged = false;
×
135

136
  /**
137
  * Whether the Queue played any item at all
138
  *
139
  * @type {boolean}
140
  */
141
  public anythingPlayed = false;
×
142
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc