Skip to content

Commit 8c23863

Browse files
authored
SF-3565 Fix error when opening a note in a Lynx insight (#3473)
1 parent 6f977db commit 8c23863

File tree

2 files changed

+16
-9
lines changed

2 files changed

+16
-9
lines changed

src/SIL.XForge.Scripture/ClientApp/src/app/shared/text/quill-editor-registration/quill-formats/quill-blots.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -313,6 +313,12 @@ export class NoteThreadEmbed extends QuillEmbedBlot {
313313
};
314314
}
315315

316+
appendChild(_child: Node): void {
317+
// An embed cannot have children. As such, we will just ignore this request.
318+
// This function can be called by wrap() if the embed is inside an inline of block,
319+
// and this embed is having a format applied to it (i.e. 'highlight' in EditorComponent).
320+
}
321+
316322
format(name: string, value: any): void {
317323
if (name === NoteThreadEmbed.blotName && value != null) {
318324
const ref = value as NoteThread;

src/SIL.XForge.Scripture/ClientApp/src/app/translate/editor/editor.component.ts

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -750,17 +750,15 @@ export class EditorComponent extends DataLoadingComponent implements OnDestroy,
750750
this.userService.currentUserId
751751
);
752752

753-
this.initLynxFeatureStates(this.projectUserConfigDoc);
754-
755753
this.sourceProjectDoc = await this.getSourceProjectDoc();
756754
if (this.projectUserConfigChangesSub != null) {
757755
this.projectUserConfigChangesSub.unsubscribe();
758756
}
759-
this.projectUserConfigChangesSub = this.projectUserConfigDoc.remoteChanges$.subscribe(() => {
757+
this.projectUserConfigChangesSub = this.projectUserConfigDoc.remoteChanges$.subscribe(async () => {
760758
if (this.projectUserConfigDoc?.data != null) {
761759
// Reload config if the checksum has been reset on the server
762760
if (this.projectUserConfigDoc.data.selectedSegmentChecksum == null) {
763-
this.loadProjectUserConfig();
761+
await this.loadProjectUserConfig();
764762
} else {
765763
this.loadTranslateSuggesterConfidence();
766764
}
@@ -791,7 +789,10 @@ export class EditorComponent extends DataLoadingComponent implements OnDestroy,
791789
this.updateVerseNumber();
792790

793791
// Set chapter from route if provided
794-
this.loadProjectUserConfig(chapterNum != null ? Number.parseInt(chapterNum) : undefined);
792+
await this.loadProjectUserConfig(chapterNum != null ? Number.parseInt(chapterNum) : undefined);
793+
794+
// Lynx must be initialized after the adding of notes and other text-change related events
795+
this.initLynxFeatureStates(this.projectUserConfigDoc);
795796

796797
if (this.projectDoc.id !== prevProjectId) {
797798
this.setupTranslationEngine();
@@ -2030,7 +2031,7 @@ export class EditorComponent extends DataLoadingComponent implements OnDestroy,
20302031
});
20312032
}
20322033

2033-
private loadProjectUserConfig(chapterFromUrl?: number): void {
2034+
private async loadProjectUserConfig(chapterFromUrl?: number): Promise<void> {
20342035
let chapter: number = chapterFromUrl ?? this.chapters[0] ?? 1;
20352036
this.loadTranslateSuggesterConfidence();
20362037

@@ -2052,10 +2053,10 @@ export class EditorComponent extends DataLoadingComponent implements OnDestroy,
20522053
}
20532054
this.toggleNoteThreadVerses(false);
20542055
this.chapter$.next(chapter);
2055-
this.changeText();
2056+
await this.changeText();
20562057
this.toggleNoteThreadVerses(true);
2057-
this.updateAutoDraftTabVisibility();
2058-
this.updateBiblicalTermsTabVisibility();
2058+
await this.updateAutoDraftTabVisibility();
2059+
await this.updateBiblicalTermsTabVisibility();
20592060
}
20602061

20612062
private loadTranslateSuggesterConfidence(): void {

0 commit comments

Comments
 (0)