@@ -23,11 +23,7 @@ import {
2323 isRunningInQueue ,
2424 RunningExperiment
2525} from '../webview/contract'
26- import {
27- definedAndNonEmpty ,
28- reorderListSubset ,
29- reorderObjectList
30- } from '../../util/array'
26+ import { definedAndNonEmpty , reorderListSubset } from '../../util/array'
3127import {
3228 ExperimentsOutput ,
3329 EXPERIMENT_WORKSPACE_ID
@@ -141,8 +137,8 @@ export class ExperimentsModel extends ModelWithPersistence {
141137
142138 const current = this . coloredStatus [ id ]
143139 if ( current ) {
144- this . unassignColor ( current )
145140 this . coloredStatus [ id ] = UNSELECTED
141+ this . unassignColor ( current )
146142 } else if ( this . availableColors . length > 0 ) {
147143 this . coloredStatus [ id ] = this . availableColors . shift ( ) as Color
148144 }
@@ -151,6 +147,10 @@ export class ExperimentsModel extends ModelWithPersistence {
151147 return this . coloredStatus [ id ]
152148 }
153149
150+ public unselectWorkspace ( ) {
151+ this . coloredStatus [ EXPERIMENT_WORKSPACE_ID ] = UNSELECTED
152+ }
153+
154154 public hasRunningExperiment ( ) {
155155 return this . running . length > 0
156156 }
@@ -247,10 +247,6 @@ export class ExperimentsModel extends ModelWithPersistence {
247247 return this . getSelectedFromList ( ( ) => this . getCombinedList ( ) )
248248 }
249249
250- public getSelectedExperiments ( ) {
251- return this . getSelectedFromList ( ( ) => this . getExperimentsAndQueued ( ) )
252- }
253-
254250 public setSelected ( selectedExperiments : Experiment [ ] ) {
255251 if ( tooManySelected ( selectedExperiments ) ) {
256252 selectedExperiments = limitToMaxSelected ( selectedExperiments )
@@ -474,6 +470,10 @@ export class ExperimentsModel extends ModelWithPersistence {
474470 }
475471
476472 private unassignColor ( color : Color ) {
473+ if ( new Set ( Object . values ( this . coloredStatus ) ) . has ( color ) ) {
474+ return
475+ }
476+
477477 this . availableColors . unshift ( color )
478478 this . availableColors = reorderListSubset (
479479 this . availableColors ,
@@ -536,10 +536,10 @@ export class ExperimentsModel extends ModelWithPersistence {
536536 }
537537 }
538538
539- return reorderObjectList < SelectedExperimentWithColor > (
540- copyOriginalColors ( ) ,
541- acc ,
542- 'displayColor'
543- )
539+ return copyOriginalColors ( )
540+ . flatMap ( orderedItem =>
541+ acc . filter ( item => item . displayColor === orderedItem )
542+ )
543+ . filter ( Boolean )
544544 }
545545}
0 commit comments