Skip to content

Commit

Permalink
Merge branch 'main' into fix-monaco-react
Browse files Browse the repository at this point in the history
  • Loading branch information
dimaMachina authored Jun 24, 2023
2 parents 9332d33 + 0fa98a2 commit 8d79e44
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 12 deletions.
1 change: 1 addition & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ module.exports = {
},
rules: {
'@shopify/prefer-early-return': ['error', { maximumStatements: 2 }],
'@shopify/prefer-class-properties': 'off', // enable after https://github.com/Shopify/web-configs/issues/387 will be fixed
'sonarjs/no-inverted-boolean-check': 'error',
'@arthurgeron/react-usememo/require-usememo': [
'error',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,10 @@ import { QueryStore } from '../query';
class StorageMock {
shouldThrow: () => boolean;
count: number;
map: any;
map = {};
storage: Storage;
constructor(shouldThrow: () => boolean) {
this.shouldThrow = shouldThrow;
this.map = {};
}

set(key: string, value: string) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,11 @@
import { TokenPattern, CharacterStreamInterface } from './types';

export default class CharacterStream implements CharacterStreamInterface {
private _start: number;
private _pos: number;
private _start = 0;
private _pos = 0;
private _sourceText: string;

constructor(sourceText: string) {
this._start = 0;
this._pos = 0;
this._sourceText = sourceText;
}

Expand Down
9 changes: 3 additions & 6 deletions packages/monaco-graphql/src/workerManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,24 +15,21 @@ const STOP_WHEN_IDLE_FOR = 2 * 60 * 1000; // 2min
export class WorkerManager {
private _defaults: MonacoGraphQLAPI;
private _idleCheckInterval: number;
private _lastUsedTime: number;
private _lastUsedTime = 0;
private _configChangeListener: IDisposable;
private _worker: editor.MonacoWebWorker<GraphQLWorker> | null;
private _client: GraphQLWorker | null;
private _worker: editor.MonacoWebWorker<GraphQLWorker> | null = null;
private _client: GraphQLWorker | null = null;

constructor(defaults: MonacoGraphQLAPI) {
this._defaults = defaults;
this._worker = null;
this._idleCheckInterval = window.setInterval(
() => this._checkIfIdle(),
30 * 1000,
);
this._lastUsedTime = 0;
// this is where we re-start the worker on config changes
this._configChangeListener = this._defaults.onDidChange(() => {
this._stopWorker();
});
this._client = null;
}

private _stopWorker(): void {
Expand Down

0 comments on commit 8d79e44

Please sign in to comment.