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

6796
yarn-error.log Normal file

File diff suppressed because it is too large Load Diff