mirror of
https://github.com/CommunityOx/ox_lib.git
synced 2026-08-18 07:26: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;
|
---@field style? string | table;
|
||||||
|
|
||||||
local isOpen = false
|
local isOpen = false
|
||||||
|
local currentText
|
||||||
|
|
||||||
---@param text string
|
---@param text string
|
||||||
---@param options? TextUIOptions
|
---@param options? TextUIOptions
|
||||||
function lib.showTextUI(text, options)
|
function lib.showTextUI(text, options)
|
||||||
|
if currentText == text then return end
|
||||||
|
|
||||||
if not options then options = {} end
|
if not options then options = {} end
|
||||||
|
|
||||||
options.text = text
|
options.text = text
|
||||||
|
currentText = text
|
||||||
|
|
||||||
SendNUIMessage({
|
SendNUIMessage({
|
||||||
action = 'textUi',
|
action = 'textUi',
|
||||||
data = options
|
data = options
|
||||||
})
|
})
|
||||||
|
|
||||||
isOpen = true
|
isOpen = true
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -22,7 +29,9 @@ function lib.hideTextUI()
|
|||||||
SendNUIMessage({
|
SendNUIMessage({
|
||||||
action = 'textUiHide'
|
action = 'textUiHide'
|
||||||
})
|
})
|
||||||
|
|
||||||
isOpen = false
|
isOpen = false
|
||||||
|
currentText = nil
|
||||||
end
|
end
|
||||||
|
|
||||||
---@return boolean
|
---@return boolean
|
||||||
|
|||||||
Reference in New Issue
Block a user