Prevent IDE reload race condition

This commit is contained in:
R. Richard 2020-05-26 15:34:54 +02:00
parent ea5bf30a95
commit 4f3a6057a4
3 changed files with 6809 additions and 2 deletions

View File

@ -32,6 +32,7 @@ export class IdeComponent implements OnInit {
files: string[];
filename = '';
lastFilename = '';
reloadFile = false;
code = 'Loading your file...';
codeState = CodeState.SAVED;
@ -85,10 +86,18 @@ export class IdeComponent implements OnInit {
}
reloadHandler(message: WebSocketMessage) {
this.requestCode();
if (!this.reloadFile) {
this.reloadFile = true;
this.requestCode();
}
}
readHandler(message: IDEMessage) {
if (!this.reloadFile && message.reload) {
return;
}
this.reloadFile = false;
if (this.codeState === CodeState.SAVED) {
if (this.filename !== message.filename) {
this.filename = message.filename;
@ -189,7 +198,8 @@ export class IdeComponent implements OnInit {
requestCode() {
this.webSocketService.send({
'key': 'ide.read',
'filename': this.filename
'filename': this.filename,
'reload': this.reloadFile
});
}
}

View File

@ -4,4 +4,5 @@ export interface IDEMessage extends WebSocketMessage {
filename: string;
content?: string;
files?: string[];
reload?: boolean;
}

6796
yarn-error.log Normal file

File diff suppressed because it is too large Load Diff