Skip to content

Commit

Permalink
feat: remove unnecessary complexity
Browse files Browse the repository at this point in the history
  • Loading branch information
Amzani committed Aug 2, 2023
1 parent 4149943 commit 64832de
Showing 1 changed file with 2 additions and 8 deletions.
10 changes: 2 additions & 8 deletions apps/studio/src/services/specification.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import { documentsState, settingsState } from '../state';
import type { SpecVersions } from '../types';

export class SpecificationService extends AbstractService {
private betaVersion = false;
private keySessionStorage = 'informed-about-latest';
override onInit() {
this.subcribeToDocuments();
Expand All @@ -22,15 +21,12 @@ export class SpecificationService extends AbstractService {
}

get latestVersion(): SpecVersions {
return this.betaVersion ?
const { editor: { v3support } } = settingsState.getState();
return v3support ?
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) {
return this.specs[String(version) as SpecVersions];
}
Expand All @@ -54,8 +50,6 @@ 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);
sessionStorage.removeItem(this.keySessionStorage);
});
}
Expand Down

0 comments on commit 64832de

Please sign in to comment.