1
1
import {
2
- action
2
+ action ,
3
+ WillDisappearEvent
3
4
} from '@elgato/streamdeck'
4
5
5
6
import {
@@ -17,7 +18,7 @@ export default class ItemsDial extends Dial {
17
18
#items: any = [ ]
18
19
#lastTotal: number = 0
19
20
20
- async #refreshItemss ( context : string ) {
21
+ async #refreshItems ( context : string ) {
21
22
if ( this . #itemsPage[ context ] === undefined )
22
23
this . #itemsPage[ context ] = 1
23
24
@@ -67,20 +68,20 @@ export default class ItemsDial extends Dial {
67
68
this . setIcon ( context , 'images/icons/pending.png' )
68
69
this . #refreshCount( context )
69
70
70
- const refreshItemss = await this . #refreshItemss ( context )
71
+ const refreshItems = await this . #refreshItems ( context )
71
72
72
- if ( refreshItemss ) {
73
+ if ( refreshItems ) {
73
74
await this . #refreshLayout( true , context )
74
75
return false
75
76
}
76
77
77
78
return true
78
79
}
79
80
80
- async #refreshLayout( refreshItemss = false , context : string ) {
81
+ async #refreshLayout( refreshItems = false , context : string ) {
81
82
const nameMarquee = this . getMarquee ( context , 'name' )
82
83
83
- if ( refreshItemss ) {
84
+ if ( refreshItems ) {
84
85
this . resetFeedbackLayout ( context , {
85
86
name : {
86
87
opacity : 1.0
@@ -105,7 +106,7 @@ export default class ItemsDial extends Dial {
105
106
this . #currentItems = { }
106
107
this . #items = { }
107
108
108
- await this . #refreshItemss ( context )
109
+ await this . #refreshItems ( context )
109
110
110
111
if ( this . #items. total === 0 ) {
111
112
this . setIcon ( context , this . originalIcon )
@@ -118,11 +119,13 @@ export default class ItemsDial extends Dial {
118
119
119
120
return
120
121
}
121
- } else if ( this . #items. items [ this . #currentItems[ context ] ] && ( ! images . isItemCached ( this . #items. items [ this . #currentItems[ context ] ] ) ) )
122
- this . setIcon ( context , 'images/icons/pending.png' )
123
122
124
- if ( this . #currentItems[ context ] === undefined )
125
- this . #currentItems[ context ] = 0
123
+ if ( this . #currentItems[ context ] === undefined )
124
+ this . #currentItems[ context ] = 0
125
+ }
126
+
127
+ if ( ! images . isItemCached ( this . #items. items [ this . #currentItems[ context ] ] ) )
128
+ this . setIcon ( context , 'images/icons/pending.png' )
126
129
127
130
this . setFeedback ( context , {
128
131
name : {
@@ -146,7 +149,9 @@ export default class ItemsDial extends Dial {
146
149
this . #refreshCount( context )
147
150
148
151
if ( nameMarquee ) {
149
- this . updateMarquee ( context , 'name' , this . #items. items [ this . #currentItems[ context ] ] . name , this . #items. items [ this . #currentItems[ context ] ] . name )
152
+ if ( nameMarquee . original !== this . #items. items [ this . #currentItems[ context ] ] . name )
153
+ this . updateMarquee ( context , 'name' , this . #items. items [ this . #currentItems[ context ] ] . name , this . #items. items [ this . #currentItems[ context ] ] . name )
154
+
150
155
this . resumeMarquee ( context , 'name' )
151
156
} else
152
157
this . marquee ( context , 'name' , this . #items. items [ this . #currentItems[ context ] ] . name , this . #items. items [ this . #currentItems[ context ] ] . name , 11 , context )
@@ -185,9 +190,16 @@ export default class ItemsDial extends Dial {
185
190
else
186
191
this . #itemsPage[ context ] = 1
187
192
188
- if ( lastPage !== this . #itemsPage[ context ] )
193
+ if ( lastPage !== this . #itemsPage[ context ] ) {
194
+ this . setFeedback ( context , {
195
+ name : {
196
+ value : '?????'
197
+ }
198
+ } )
199
+
189
200
if ( ! ( await this . #refreshPage( context ) ) )
190
201
return constants . WRAPPER_RESPONSE_API_ERROR
202
+ }
191
203
}
192
204
193
205
this . #refreshCount( context )
@@ -211,9 +223,16 @@ export default class ItemsDial extends Dial {
211
223
this . #currentItems[ context ] = this . #items. total - ( ( this . #itemsPage[ context ] - 1 ) * constants . WRAPPER_ITEMS_PER_PAGE ) - 1
212
224
}
213
225
214
- if ( lastPage !== this . #itemsPage[ context ] )
226
+ if ( lastPage !== this . #itemsPage[ context ] ) {
227
+ this . setFeedback ( context , {
228
+ name : {
229
+ value : '?????'
230
+ }
231
+ } )
232
+
215
233
if ( ! ( await this . #refreshPage( context ) ) )
216
234
return constants . WRAPPER_RESPONSE_API_ERROR
235
+ }
217
236
}
218
237
219
238
this . #refreshCount( context )
@@ -254,8 +273,14 @@ export default class ItemsDial extends Dial {
254
273
throw new Error ( 'The fetchItems method must be implemented in a subclass.' )
255
274
}
256
275
276
+
277
+ async onWillDisappear ( ev : WillDisappearEvent < any > ) : Promise < void > {
278
+ await super . onWillDisappear ( ev )
279
+ this . pauseMarquee ( ev . action . id , 'name' )
280
+ }
281
+
257
282
updateFeedback ( context : string ) : void {
258
283
super . updateFeedback ( context )
259
- this . #refreshLayout( true , context )
284
+ this . #refreshLayout( this . #lastTotal === 0 , context )
260
285
}
261
286
}
0 commit comments