Skip to content

Commit

Permalink
cleaned up code-editor further
Browse files Browse the repository at this point in the history
  • Loading branch information
Tahler committed Sep 13, 2016
1 parent 63e2937 commit 3a502b9
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 11 deletions.
29 changes: 19 additions & 10 deletions src/app/code-editor/code-editor.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,22 +16,31 @@ export class CodeEditorComponent implements OnInit {
@ViewChild('langDropdown') langDropdown: LanguageDropdownComponent;

lang: Language;
submission: Submission;

submission: Submission;
@Output() submissionChange = new EventEmitter();

constructor(private templateService: SubmissionTemplateService) { }

ngOnInit() {
this.templateService
.getDefaultSubmission()
.take(1)
.subscribe(submission => {
this.submission = submission;
// Initial setup
this.codeMirror.src = submission.src;
this.langDropdown.lang = submission.lang;
});
if (this.submission) {
this.onSubmissionInit();
} else {
this.templateService
.getDefaultSubmission()
.take(1)
.subscribe(submission => {
this.submission = submission;
this.onSubmissionInit();
});
}
}

onSubmissionInit() {
// Initial setup
this.codeMirror.src = this.submission.src;
this.langDropdown.lang = this.submission.lang;
this.submissionChange.emit(this.submission);
}

// Called on codemirror text change
Expand Down
4 changes: 3 additions & 1 deletion src/app/problems/problem/view/view.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,9 @@ export class ViewComponent implements OnInit, OnDestroy {
.subscribe(user => this.creator = user);
}
});
this.sharingService.submissionObservable.subscribe(submission => this.submission = submission);
this.sharingService
.submissionObservable
.subscribe(submission => this.submission = submission);
}

ngOnDestroy() {
Expand Down

0 comments on commit 3a502b9

Please sign in to comment.