mirror of
https://github.com/avatao-content/frontend-tutorial-framework
synced 2024-12-04 18:21:32 +00:00
Prevent IDE reload race condition
This commit is contained in:
parent
ea5bf30a95
commit
4f3a6057a4
@ -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) {
|
||||
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
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@ -4,4 +4,5 @@ export interface IDEMessage extends WebSocketMessage {
|
||||
filename: string;
|
||||
content?: string;
|
||||
files?: string[];
|
||||
reload?: boolean;
|
||||
}
|
||||
|
6796
yarn-error.log
Normal file
6796
yarn-error.log
Normal file
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue
Block a user