mirror of
https://github.com/avatao-content/frontend-tutorial-framework
synced 2024-12-05 01:41: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[];
|
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) {
|
||||||
this.requestCode();
|
if (!this.reloadFile) {
|
||||||
|
this.reloadFile = true;
|
||||||
|
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
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -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
6796
yarn-error.log
Normal file
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue
Block a user