1- import type { EffectType , DiscordCustomEmbed } from "../../../types" ;
1+ import type {
2+ EffectType ,
3+ DiscordCustomEmbed ,
4+ BackendCommunicator
5+ } from "../../../types" ;
26
37import { takeScreenshot } from "../../app-management/electron/screen-helpers" ;
48import {
@@ -49,7 +53,9 @@ const effect: EffectType<{
4953 } ,
5054 optionsTemplate : `
5155 <eos-container header="Display">
52- <dropdown-select options="displayOptions" selected="effect.displayId"></dropdown-select>
56+ <firebot-dropdown
57+ options="displayOptions"
58+ ng-model="effect.displayId" />
5359 </eos-container>
5460
5561 <screenshot-effect-options effect="effect"></screenshot-effect-options>
@@ -60,20 +66,32 @@ const effect: EffectType<{
6066 </div>
6167 </eos-container>
6268 ` ,
63- optionsController : ( $scope , backendCommunicator ) => {
64- const displays = backendCommunicator . fireEventSync ( "getAllDisplays" ) as Electron . Display [ ] ;
65- const primaryDisplay = backendCommunicator . fireEventSync ( "getPrimaryDisplay" ) as Electron . Display ;
66-
67- $scope . displayOptions = displays . reduce ( ( acc , display , i ) => {
68- const isPrimary = display . id === primaryDisplay . id ;
69- acc [ display . id ] = `Display ${ i + 1 } ${ isPrimary ? ` (Primary)` : '' } ` ;
70- return acc ;
71- } , { } ) ;
72-
73- if ( $scope . effect . displayId == null ||
74- $scope . displayOptions [ $scope . effect . displayId ] == null ) {
75- $scope . effect . displayId = displays [ 0 ] . id ;
76- }
69+ optionsController : ( $scope , backendCommunicator : BackendCommunicator ) => {
70+ $scope . displayOptions = [ ] ;
71+
72+ $scope . refreshDisplays = async ( ) => {
73+ const displays : Electron . Display [ ] = await backendCommunicator . fireEventAsync ( "getAllDisplays" ) ;
74+ const primaryDisplay : Electron . Display = await backendCommunicator . fireEventAsync ( "getPrimaryDisplay" ) ;
75+
76+ let i = 1 ;
77+ $scope . displayOptions = displays . map ( ( d ) => {
78+ const isPrimary = d . id === primaryDisplay . id ;
79+ return {
80+ name : isPrimary
81+ ? `Display ${ i ++ } (${ d . label } ) (Primary)`
82+ : `Display ${ i ++ } (${ d . label } )` ,
83+ value : d . id
84+ } ;
85+ } ) ;
86+
87+ if ( $scope . effect . displayId == null
88+ || ! $scope . displayOptions . some ( d => d . value === $scope . effect . displayId )
89+ ) {
90+ $scope . effect . displayId = displays [ 0 ] . id ;
91+ }
92+ } ;
93+
94+ $scope . refreshDisplays ( ) ;
7795 } ,
7896 optionsValidator : ( effect ) => {
7997 const errors : string [ ] = [ ] ;
0 commit comments