File tree Expand file tree Collapse file tree 1 file changed +14
-12
lines changed
typescript/packages/lookslike-high-level/src/components Expand file tree Collapse file tree 1 file changed +14
-12
lines changed Original file line number Diff line number Diff line change @@ -56,24 +56,20 @@ export class CommonWindowManager extends LitElement {
5656 @property ( { type : Array } )
5757 sagas : Gem [ ] = [ ] ;
5858
59- private renderedSagas : { [ key : string ] : HTMLElement } = { } ;
60-
6159 override render ( ) {
60+ const idCounts : { [ key : string ] : number } = { } ;
6261 return html `
6362 ${ this . sagas . map ( ( saga ) => {
64- if ( ! this . renderedSagas [ saga [ ID ] ] )
65- this . renderedSagas [ saga [ ID ] ] = render . render (
66- include ( { content : binding ( "UI" ) } ) ,
67- {
68- UI : saga . UI ,
69- }
70- ) as HTMLElement ;
63+ idCounts [ saga [ ID ] ] ??= 0 ;
64+ const id = saga [ ID ] + "#" + idCounts [ saga [ ID ] ] ++ ;
7165
7266 return html `
73- < div class ="window " id ="${ saga [ ID ] } ">
67+ < div class ="window " id ="${ id } ">
7468 < button class ="close-button " @click ="${ this . onClose } "> ×</ button >
7569 < common-screen-element >
76- ${ this . renderedSagas [ saga [ ID ] ] }
70+ ${ render . render ( include ( { content : binding ( "UI" ) } ) , {
71+ UI : saga . UI ,
72+ } ) }
7773 </ common-screen-element >
7874 </ div >
7975 ` ;
@@ -98,7 +94,13 @@ export class CommonWindowManager extends LitElement {
9894 onClose ( e : Event ) {
9995 const id = ( e . currentTarget as HTMLElement ) . parentElement ?. id ;
10096 if ( id ) {
101- this . sagas = this . sagas . filter ( ( saga ) => saga [ ID ] + "" !== id ) ;
97+ const idCounts : { [ key : string ] : number } = { } ;
98+
99+ this . sagas = this . sagas . filter ( ( saga ) => {
100+ idCounts [ saga [ ID ] ] ??= 0 ;
101+ const sagaID = saga [ ID ] + "#" + idCounts [ saga [ ID ] ] ++ ;
102+ return sagaID !== id ;
103+ } ) ;
102104 }
103105 }
104106
You can’t perform that action at this time.
0 commit comments