Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion src/BloomExe/Book/Book.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5403,12 +5403,18 @@ var page in RawDom
public void UpdateSupportFiles()
{
Storage.UpdateSupportFiles();
UpdateQrCodeHtmlForCurrentSettings();
}

internal void UpdateQrCodeHtmlForCurrentSettings(bool updateQrCodeFileEvenIfItExists = true)
{
BookStorage.UpdateQrCode(
OurHtmlDom,
CollectionSettings.ShowBlorgLanguageQrCode,
Language1Tag,
CollectionSettings.BadgeQrCodeLabelLocalizedWithLang,
FolderPath
FolderPath,
updateQrCodeFileEvenIfItExists
);
}

Expand Down
10 changes: 8 additions & 2 deletions src/BloomExe/Book/BookStorage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2789,7 +2789,8 @@ public static void UpdateQrCode(
bool shouldHaveQrCode,
string langCode,
string badgeQrCodeLabelLocalizedWithLang,
string bookFolderPath
string bookFolderPath,
bool updateQrCodeFileEvenIfItExists = true
)
{
var qrWrappers = dom.SafeSelectNodes(
Expand All @@ -2799,6 +2800,8 @@ string bookFolderPath
var url = "https://bloomlibrary.org/language:" + langCode;

string qrFileName = null;
const string kQrFileName = "lang-qr-code.png";
var qrFilePath = Path.Combine(bookFolderPath, kQrFileName);

foreach (var qrWrapper in qrWrappers)
{
Expand All @@ -2823,7 +2826,10 @@ string bookFolderPath

if (qrFileName == null)
{
qrFileName = GenerateQrCodeImage(bookFolderPath, url);
if (updateQrCodeFileEvenIfItExists || !RobustFile.Exists(qrFilePath))
qrFileName = GenerateQrCodeImage(bookFolderPath, url);
else
qrFileName = kQrFileName;
}

AdjustHtmlForHavingQrCode(
Expand Down
4 changes: 4 additions & 0 deletions src/BloomExe/web/controllers/EditingViewApi.cs
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,10 @@ private void HandleToggleCustomCover(ApiRequest request)
// Bring everything up to date consistent with the new
// state. Might be enough just do the BookData update.
book.EnsureUpToDateMemory(new NullProgress());
// Toggling between custom and standard layout can replace the xMatter page HTML,
// so reapply branding QR-code HTML adjustments for the current book settings.
// This should not need to regenerate the QR code file.
book.UpdateQrCodeHtmlForCurrentSettings(updateQrCodeFileEvenIfItExists: false);

var updatedPageElt = book.GetPage(pageId)?.GetDivNodeForThisPage();
if (updatedPageElt != null)
Expand Down