default selection is now none

This commit is contained in:
undergroundwires
2020-01-06 20:02:12 +01:00
parent 20020af7c1
commit 3140cc663b
21 changed files with 295 additions and 237 deletions

View File

@@ -6,7 +6,7 @@ import { IUserSelection } from './Selection/IUserSelection';
import { AsyncLazy } from '../../infrastructure/Threading/AsyncLazy';
import { Signal } from '../../infrastructure/Events/Signal';
import { ICategory } from '../../domain/ICategory';
import { buildApplication } from '../Parser/ApplicationParser';
import { parseApplication } from '../Parser/ApplicationParser';
import { IApplicationState } from './IApplicationState';
import { Script } from '../../domain/Script';
import { Application } from '../../domain/Application';
@@ -21,8 +21,9 @@ export class ApplicationState implements IApplicationState {
/** Application instance with all scripts. */
private static instance = new AsyncLazy<IApplicationState>(() => {
const app = buildApplication();
const state = new ApplicationState(app.application, app.selectedScripts);
const application = parseApplication();
const selectedScripts = new Array<Script>();
const state = new ApplicationState(application, selectedScripts);
return Promise.resolve(state);
});
@@ -33,33 +34,13 @@ export class ApplicationState implements IApplicationState {
private constructor(
/** Inner instance of the all scripts */
private readonly app: Application,
public readonly app: Application,
/** Initially selected scripts */
public readonly defaultScripts: Script[]) {
this.selection = new UserSelection(app, defaultScripts);
this.code = new ApplicationCode(this.selection, app.version.toString());
this.filter = new UserFilter(app);
}
public getCategory(categoryId: number): ICategory | undefined {
return this.app.findCategory(categoryId);
}
public get categories(): ReadonlyArray<ICategory> {
return this.app.categories;
}
public get appName(): string {
return this.app.name;
}
public get appVersion(): number {
return this.app.version;
}
public get appTotalScripts(): number {
return this.app.totalScripts;
}
}
export { IApplicationState, IUserFilter };

View File

@@ -1,3 +1,4 @@
import { IApplication } from './../../domain/IApplication';
import { IUserFilter } from './Filter/IUserFilter';
import { IUserSelection } from './Selection/IUserSelection';
import { ISignal } from '@/infrastructure/Events/ISignal';
@@ -10,11 +11,6 @@ export interface IApplicationState {
readonly code: IApplicationCode;
readonly filter: IUserFilter;
readonly stateChanged: ISignal<IApplicationState>;
readonly categories: ReadonlyArray<ICategory>;
readonly appName: string;
readonly appVersion: number;
readonly appTotalScripts: number;
readonly selection: IUserSelection;
readonly defaultScripts: ReadonlyArray<IScript>;
getCategory(categoryId: number): ICategory | undefined;
readonly app: IApplication;
}