Skip to content
This repository has been archived by the owner on Nov 29, 2020. It is now read-only.

Commit

Permalink
Fixed schema, loading issues and prop mutation
Browse files Browse the repository at this point in the history
  • Loading branch information
prefixaut committed Jul 18, 2019
1 parent 2bb053e commit 2f08bfb
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 11 deletions.
15 changes: 11 additions & 4 deletions src/components/segments-editor.vue
Original file line number Diff line number Diff line change
Expand Up @@ -73,15 +73,21 @@ import { Vue, Component, Prop, Watch } from 'vue-property-decorator';
import { v4 as uuid } from 'uuid';
import { cloneDeep } from 'lodash';
import { Segment, isSegment } from '../common/interfaces/segment';
import { Segment } from '../common/interfaces/segment';
import { ValidatorService, VALIDATOR_SERVICE_TOKEN } from '../services/validator.service';
@Component({ name: 'spl-segments-editor' })
export default class SegmentsEditorComponent extends Vue {
@Prop()
public value: Segment[] = [];
@Prop({ default: () => [] })
public value: Segment[];
public segments: Segment[] = [];
private validator: ValidatorService = null;
created() {
this.validator = this.$services.get(VALIDATOR_SERVICE_TOKEN);
}
addSegment() {
this.segments.push({
Expand All @@ -105,7 +111,8 @@ export default class SegmentsEditorComponent extends Vue {
if (!Array.isArray(newValue)) {
newValue = [newValue];
}
this.segments = cloneDeep(newValue).map(tmp => cloneDeep(tmp)).filter(tmp => isSegment(tmp));
this.segments = cloneDeep(newValue)
.filter(tmp => this.validator.isSegment(tmp));
}
}
</script>
Expand Down
2 changes: 1 addition & 1 deletion src/schemas/game-info.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"title": "Game Information",
"description": "Detailed information about the Game and run details",
"type": "object",
"required": ["name", "catergory"],
"required": ["name", "category"],
"properties": {
"name": {
"description": "Name of the Game that is currently being run",
Expand Down
16 changes: 10 additions & 6 deletions src/services/io.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ export class IOService {
@Inject(VALIDATOR_SERVICE_TOKEN) protected validator: ValidatorService
) {
const isDevelopment = process.env.NODE_ENV !== 'production';
this.assetDir = join(this.electron.getAppPath(), isDevelopment ? 'ressources' : '..');
this.assetDir = join(this.electron.getAppPath(), isDevelopment ? 'resources' : '..');
}

protected readonly assetDir;
Expand Down Expand Up @@ -302,12 +302,16 @@ export class IOService {
): Promise<ApplicationSettings> {
const appSettings = this.loadJSONFromFile(this.appSettingsFileName) as ApplicationSettings;

if (splitsFile != null && typeof splitsFile === 'string') {
await this.loadSplitsFromFileToStore(store, splitsFile);
} else if (appSettings != null && typeof appSettings === 'object') {
if (typeof appSettings.lastOpenedSplitsFile === 'string') {
await this.loadSplitsFromFileToStore(store, appSettings.lastOpenedSplitsFile);
try {
if (splitsFile != null && typeof splitsFile === 'string') {
await this.loadSplitsFromFileToStore(store, splitsFile);
} else if (appSettings != null && typeof appSettings === 'object') {
if (typeof appSettings.lastOpenedSplitsFile === 'string') {
await this.loadSplitsFromFileToStore(store, appSettings.lastOpenedSplitsFile);
}
}
} catch (error) {
// Ignore errors, logs are already printed
}

return appSettings || { windowOptions: {} };
Expand Down

0 comments on commit 2f08bfb

Please sign in to comment.