Skip to content

Update page properly when changing custom cover image metadata (BL-16100)#7823

Open
JohnThomson wants to merge 1 commit intomasterfrom
coverMetadataChange
Open

Update page properly when changing custom cover image metadata (BL-16100)#7823
JohnThomson wants to merge 1 commit intomasterfrom
coverMetadataChange

Conversation

@JohnThomson
Copy link
Copy Markdown
Contributor

@JohnThomson JohnThomson commented Apr 8, 2026


Open with Devin

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.

No issues found across 3 files

Copy link
Copy Markdown

@devin-ai-integration devin-ai-integration bot left a comment

Choose a reason for hiding this comment

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

Devin Review found 2 potential issues.

View 2 additional findings in Devin Review.

Open in Devin Review

Comment on lines +1113 to +1119
private void UpdateDataDivFromCurrentPage()
{
CurrentBook.BookData.SuckInDataFromEditedDom(
_pageSelection.CurrentSelection.GetDivNodeForThisPage(),
CurrentBook.BookInfo
);
}
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟡 Missing comment on private method UpdateDataDivFromCurrentPage

The new private method UpdateDataDivFromCurrentPage at src/BloomExe/Edit/EditingModel.cs:1113 has no summary comment. AGENTS.md states: "All public methods should have a comment. So should most private ones!" While "most" is a soft qualifier for private methods, this is a brand-new method being added in this PR and its purpose (syncing the data-div from the master DOM's current page to prevent stale data-div from overwriting metadata updates during a full save) is non-obvious without a comment.

Suggested change
private void UpdateDataDivFromCurrentPage()
{
CurrentBook.BookData.SuckInDataFromEditedDom(
_pageSelection.CurrentSelection.GetDivNodeForThisPage(),
CurrentBook.BookInfo
);
}
/// <summary>
/// Update the data div from the current page's content in the master DOM.
/// This ensures the data div reflects recent changes (e.g., image metadata updates)
/// before a full save that would otherwise overwrite them with stale data-div content.
/// </summary>
private void UpdateDataDivFromCurrentPage()
{
CurrentBook.BookData.SuckInDataFromEditedDom(
_pageSelection.CurrentSelection.GetDivNodeForThisPage(),
CurrentBook.BookInfo
);
}
Open in Devin Review

Was this helpful? React with 👍 or 👎 to provide feedback.

Comment on lines +1101 to +1109
if (_nextSaveMustBeFull)
{
// We've changed the metadata on the current page, but a full save will
// try to sync everything using the data-div, which has not yet been updated.
// It comes before the page, so the out-of-date copy there will overwrite the
// changes we just made. The simplest way to prevent this is to update the
// data-div to match the current page before we do the full save.
UpdateDataDivFromCurrentPage();
}
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🚩 UpdateDataDivFromCurrentPage only runs when _nextSaveMustBeFull — metadata updates on non-full-save pages may not sync to data-div

The new guard at src/BloomExe/Edit/EditingModel.cs:1101 only calls UpdateDataDivFromCurrentPage when _nextSaveMustBeFull is true. When it's false (quick save), the image metadata updated by UpdateImgMetadataAttributesToMatchImage on the master DOM page won't be synced to the data-div. For non-custom-layout pages this is fine (image metadata isn't stored in the data-div). But for custom layout pages where the entire margin box is stored in the data-div, a quick save could leave the data-div with stale metadata. This may be acceptable if custom layout pages always trigger a full save, but it's worth confirming that NeedToDoFullSave / _nextSaveMustBeFull is always true for custom layout pages when metadata changes.

Open in Devin Review

Was this helpful? React with 👍 or 👎 to provide feedback.

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.

1 participant