diff --git a/CHANGELOG.md b/CHANGELOG.md index 7ea4adcf..78679960 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,7 +7,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] -- Nothing worth mentioning yet. +### Fixed + +- a bug where the web app qrcode doesn't show up ## [0.25.2] - 2024-08-05 diff --git a/playlet-lib/src/components/QrCodePoster/QrCodePoster.bs b/playlet-lib/src/components/QrCodePoster/QrCodePoster.bs index 87d3d160..0405b4f9 100644 --- a/playlet-lib/src/components/QrCodePoster/QrCodePoster.bs +++ b/playlet-lib/src/components/QrCodePoster/QrCodePoster.bs @@ -1,5 +1,6 @@ import "pkg:/source/AsyncTask/AsyncTask.bs" import "pkg:/source/AsyncTask/Tasks.bs" +import "pkg:/source/utils/Logging.bs" import "pkg:/source/utils/StringUtils.bs" import "pkg:/source/utils/Types.bs" @@ -13,6 +14,8 @@ function Init() OnSizeChange() m.busySpinnerPoster.uri = "pkg:/images/spinner.png" + + m.top.observeField("loadStatus", FuncName(OnLoadStatusChange)) end function function OnSizeChange() @@ -26,6 +29,21 @@ function OnSizeChange() end function function OnTextChange() as void + GenerateQrCode() +end function + +function OnLoadStatusChange() as void + if m.top.loadStatus <> "failed" + return + end if + + ' If the image failed to load, it might have been deleted from cachefs: + ' Try to generate it again + LogInfo("QrCode image failed to load, trying to generate it again") + GenerateQrCode() +end function + +function GenerateQrCode() as void if m.qrCodeGenTask <> invalid m.qrCodeGenTask.cancel = true end if diff --git a/playlet-lib/src/source/QrCode/QrImage.bs b/playlet-lib/src/source/QrCode/QrImage.bs index 83960be5..249913ad 100644 --- a/playlet-lib/src/source/QrCode/QrImage.bs +++ b/playlet-lib/src/source/QrCode/QrImage.bs @@ -11,9 +11,9 @@ namespace QrCode function Generate(text as string, size as integer, padding as integer, mode = QrCode.QrMode.Byte as QrCode.QrMode) as string fileName = m.GetFileName(text, mode, size, padding) - #if DEBUG + #if DISABLE_CACHE #else - #if DISABLE_CACHE + #if DEBUG #else fs = CreateObject("roFileSystem") if fs.exists(fileName)