Skip to content

Commit

Permalink
Fix a bug where the web app qrcode doesn't show up
Browse files Browse the repository at this point in the history
  • Loading branch information
iBicha committed Aug 11, 2024
1 parent 825b9e5 commit 088377f
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 3 deletions.
4 changes: 3 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
18 changes: 18 additions & 0 deletions playlet-lib/src/components/QrCodePoster/QrCodePoster.bs
Original file line number Diff line number Diff line change
@@ -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"

Expand All @@ -13,6 +14,8 @@ function Init()
OnSizeChange()

m.busySpinnerPoster.uri = "pkg:/images/spinner.png"

m.top.observeField("loadStatus", FuncName(OnLoadStatusChange))
end function

function OnSizeChange()
Expand All @@ -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
Expand Down
4 changes: 2 additions & 2 deletions playlet-lib/src/source/QrCode/QrImage.bs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 088377f

Please sign in to comment.