refactor(cleint/textui): cancel showTextUI if text is unchanged

Because people continue to excessively call it in a loop.
This commit is contained in:
Linden
2023-05-19 21:41:58 +10:00
parent 21c835b78d
commit dbfb0227aa

View File

@@ -5,16 +5,23 @@
---@field style? string | table;
local isOpen = false
local currentText
---@param text string
---@param options? TextUIOptions
function lib.showTextUI(text, options)
if currentText == text then return end
if not options then options = {} end
options.text = text
currentText = text
SendNUIMessage({
action = 'textUi',
data = options
})
isOpen = true
end
@@ -22,7 +29,9 @@ function lib.hideTextUI()
SendNUIMessage({
action = 'textUiHide'
})
isOpen = false
currentText = nil
end
---@return boolean