Skip to content

Try to improve history of book creation/title (BL-16313)#7921

Open
JohnThomson wants to merge 2 commits into
Version6.4from
fixTitleHistory2
Open

Try to improve history of book creation/title (BL-16313)#7921
JohnThomson wants to merge 2 commits into
Version6.4from
fixTitleHistory2

Conversation

@JohnThomson
Copy link
Copy Markdown
Contributor

@JohnThomson JohnThomson commented May 19, 2026

This change is Reviewable

Copy link
Copy Markdown
Contributor

@cubic-dev-ai cubic-dev-ai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

1 issue found across 3 files

Reply with feedback, questions, or to request a fix.

Re-trigger cubic

Comment thread src/BloomExe/CollectionTab/CollectionModel.cs Outdated
Copy link
Copy Markdown
Contributor Author

@JohnThomson JohnThomson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JohnThomson made 1 comment and resolved 1 discussion.
Reviewable status: 0 of 3 files reviewed, all discussions resolved.

Comment thread src/BloomExe/CollectionTab/CollectionModel.cs Outdated
Copy link
Copy Markdown
Contributor

@andrew-polk andrew-polk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@andrew-polk reviewed 3 files and all commit messages, and made 1 comment.
Reviewable status: all files reviewed, 1 unresolved discussion (waiting on JohnThomson).


src/BloomExe/CollectionTab/CollectionModel.cs line 1044 at r2 (raw file):

                var l1Lang = sourceBook?.BookData?.Language1Tag;
                var sourceL1Title = sourceBook.BookInfo.GetTitleForLanguage(l1Lang);
                newBook.PendingCreationSourceTitle = sourceL1Title;

devin says


src/BloomExe/CollectionTab/CollectionModel.cs:R1042-1044

Source vs new book Language1Tag mismatch causes premature Created history event

In CollectionModel.cs:1042, PendingCreationSourceTitle is captured using the source book's Language1Tag, but the comparison in RecordPendingCreatedHistoryEvent at src/BloomExe/Book/Book.cs:262 looks up the current L1 title using the new book's BookData.Language1Tag. When the source book has a different L1 language than the new book's collection (e.g., creating from a downloaded shell book that has Language1=es into a collection with Language1=tok), the captured sourceTitle will be a title in one language (e.g., "Mi Libro" in Spanish) while currentL1Title will be looked up in a different language (e.g., Tok Pisin, likely returning empty). Since these will almost always differ, the Created history event fires prematurely on the first save—before the user has actually changed anything—defeating the purpose of deferring the event until the user provides their own title.

Trace of the mismatch scenario
  1. l1Lang = sourceBook.BookData.Language1Tag → "es"
  2. sourceL1Title = sourceBook.BookInfo.GetTitleForLanguage("es") → "Mi Libro"
  3. After BringBookUpToDate, newBook.BookData.Language1Tag → "tok"
  4. currentL1Title = BookInfo.GetTitleForLanguage("tok") → "" (no tok title)
  5. "Mi Libro" != "" → event fires immediately, even though user hasn't edited the title

Copy link
Copy Markdown
Contributor Author

@JohnThomson JohnThomson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JohnThomson made 1 comment.
Reviewable status: all files reviewed, 1 unresolved discussion (waiting on andrew-polk).


src/BloomExe/CollectionTab/CollectionModel.cs line 1044 at r2 (raw file):

Previously, andrew-polk wrote…

devin says


src/BloomExe/CollectionTab/CollectionModel.cs:R1042-1044

Source vs new book Language1Tag mismatch causes premature Created history event

In CollectionModel.cs:1042, PendingCreationSourceTitle is captured using the source book's Language1Tag, but the comparison in RecordPendingCreatedHistoryEvent at src/BloomExe/Book/Book.cs:262 looks up the current L1 title using the new book's BookData.Language1Tag. When the source book has a different L1 language than the new book's collection (e.g., creating from a downloaded shell book that has Language1=es into a collection with Language1=tok), the captured sourceTitle will be a title in one language (e.g., "Mi Libro" in Spanish) while currentL1Title will be looked up in a different language (e.g., Tok Pisin, likely returning empty). Since these will almost always differ, the Created history event fires prematurely on the first save—before the user has actually changed anything—defeating the purpose of deferring the event until the user provides their own title.

Trace of the mismatch scenario
  1. l1Lang = sourceBook.BookData.Language1Tag → "es"
  2. sourceL1Title = sourceBook.BookInfo.GetTitleForLanguage("es") → "Mi Libro"
  3. After BringBookUpToDate, newBook.BookData.Language1Tag → "tok"
  4. currentL1Title = BookInfo.GetTitleForLanguage("tok") → "" (no tok title)
  5. "Mi Libro" != "" → event fires immediately, even though user hasn't edited the title

Done

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants