Try to improve history of book creation/title (BL-16313)#7921
Try to improve history of book creation/title (BL-16313)#7921JohnThomson wants to merge 2 commits into
Conversation
There was a problem hiding this comment.
1 issue found across 3 files
Reply with feedback, questions, or to request a fix.
Re-trigger cubic
JohnThomson
left a comment
There was a problem hiding this comment.
@JohnThomson made 1 comment and resolved 1 discussion.
Reviewable status: 0 of 3 files reviewed, all discussions resolved.
c292ae2 to
9e9be28
Compare
andrew-polk
left a comment
There was a problem hiding this comment.
@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
l1Lang = sourceBook.BookData.Language1Tag→ "es"sourceL1Title = sourceBook.BookInfo.GetTitleForLanguage("es")→ "Mi Libro"- After
BringBookUpToDate,newBook.BookData.Language1Tag→ "tok" currentL1Title = BookInfo.GetTitleForLanguage("tok")→ "" (no tok title)- "Mi Libro" != "" → event fires immediately, even though user hasn't edited the title
9e9be28 to
1aa1de3
Compare
JohnThomson
left a comment
There was a problem hiding this comment.
@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,PendingCreationSourceTitleis captured using the source book'sLanguage1Tag, but the comparison inRecordPendingCreatedHistoryEventatsrc/BloomExe/Book/Book.cs:262looks up the current L1 title using the new book'sBookData.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 hasLanguage1=esinto a collection withLanguage1=tok), the capturedsourceTitlewill be a title in one language (e.g., "Mi Libro" in Spanish) whilecurrentL1Titlewill 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
l1Lang = sourceBook.BookData.Language1Tag→ "es"sourceL1Title = sourceBook.BookInfo.GetTitleForLanguage("es")→ "Mi Libro"- After
BringBookUpToDate,newBook.BookData.Language1Tag→ "tok"currentL1Title = BookInfo.GetTitleForLanguage("tok")→ "" (no tok title)- "Mi Libro" != "" → event fires immediately, even though user hasn't edited the title
Done
This change is