mirror of
https://github.com/CommunityOx/ox_lib.git
synced 2026-08-17 15:06:02 +01:00
refactor(cleint/textui): cancel showTextUI if text is unchanged
Because people continue to excessively call it in a loop.
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user