Skip to content

Commit

Permalink
Fix bug for language selection
Browse files Browse the repository at this point in the history
Previously, the language selected would disappear if you
refresh the page. Now, it's able to pick up the last language
selected.
  • Loading branch information
limcaaarl committed Oct 31, 2024
1 parent 849c37f commit e639b21
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions frontend/src/app/collaboration/editor/editor.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ export class EditorComponent implements AfterViewInit, OnInit {
isInitiator = false;
isForfeitClick = false;
numUniqueUsers = 0;
selectedLanguage = 'java';
selectedLanguage!: string;
languages: LanguageOption[] = [];

constructor(
Expand Down Expand Up @@ -134,10 +134,12 @@ export class EditorComponent implements AfterViewInit, OnInit {
this.ylanguage = this.ydoc.getMap('language');
this.undoManager = new Y.UndoManager(this.yeditorText);

const firstEntry = this.ysubmit.entries().next().value;

if (firstEntry && firstEntry[0] === undefined) {
const language = this.ylanguage.get('selection');
if (language == undefined) {
this.ylanguage.set('selected', 'java');
this.selectedLanguage = 'java';
} else {
this.selectedLanguage = language!;
}
}

Expand Down

0 comments on commit e639b21

Please sign in to comment.