Skip to content

Commit

Permalink
feat: enable conversion to 3.0.0 only when setting is enabled
Browse files Browse the repository at this point in the history
  • Loading branch information
Amzani committed Aug 1, 2023
1 parent 147a311 commit f7be96f
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 8 deletions.
6 changes: 0 additions & 6 deletions apps/studio/src/services/parser.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -169,10 +169,4 @@ export class ParserService extends AbstractService {
}),
);
}

isV3(): boolean {
const { editor: { v3support } } = settingsState.getState();
console.log(v3support)
return false;
}
}
20 changes: 18 additions & 2 deletions apps/studio/src/services/specification.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,29 @@ import { show } from '@ebay/nice-modal-react';

import { ConvertToLatestModal } from '../components/Modals';

import { documentsState } from '../state';
import { documentsState, settingsState } from '../state';

import type { SpecVersions } from '../types';

export class SpecificationService extends AbstractService {
private betaVersion = false;
override onInit() {
this.subcribeToDocuments();
this.subscribeToSettings();
}

get specs() {
return specs.schemas;
}

get latestVersion(): SpecVersions {
return Object.keys(this.specs).pop() as SpecVersions;
return this.betaVersion ?
Object.keys(this.specs).pop() as SpecVersions :
Object.keys(this.specs).at(-2) as SpecVersions;
}

updateBetaVersion(enable: boolean): void {
this.betaVersion = enable;
}

getSpec(version: SpecVersions) {
Expand All @@ -42,6 +50,14 @@ export class SpecificationService extends AbstractService {
});
}

private subscribeToSettings() {
settingsState.subscribe((state, prevState) => {
if (state.editor.v3support === prevState.editor.v3support) return;
const { editor: { v3support } } = settingsState.getState();
this.updateBetaVersion(v3support);
});
}

private tryInformAboutLatestVersion(
version: string,
): boolean {
Expand Down

0 comments on commit f7be96f

Please sign in to comment.