some gui and performance fixes, finally fixed that text box

git [06-16-18 - 11:05]
some gui and performance fixes, finally fixed that text box
Filename
FurCControlBridge.lua
FurCGui.lua
FurCSettingsAdapter.lua
diff --git a/FurCControlBridge.lua b/FurCControlBridge.lua
index a6206fe..b4b9533 100644
--- a/FurCControlBridge.lua
+++ b/FurCControlBridge.lua
@@ -111,7 +111,8 @@ function FurC.GuiOnSearchBoxFocusOut(control)
         FurC.GuiOnSliderUpdate(FurCGui_ListHolder_Slider, 0)
 		FurC.UpdateGui()
     end
-	FurC_SearchBoxText:SetText(FURC_S_FILTERDEFAULT)
+    local text = FurC_SearchBox:GetText()
+    FurC_SearchBoxText:SetText((#text == 0 and FURC_S_FILTERDEFAULT) or "")
 end

 function FurC.GuiOnScroll(control, delta)
diff --git a/FurCGui.lua b/FurCGui.lua
index 257d0c6..5cc45be 100644
--- a/FurCGui.lua
+++ b/FurCGui.lua
@@ -129,23 +129,29 @@ local function updateScrollDataLinesData()
 	end)

 end
+local FURC_S_FILTERDEFAULT = GetString(SI_FURC_TEXTBOX_FILTER_DEFAULT)
+local cachedDefaults
+local function startLoading()
+    FurC.IsLoading(true)
+    local text = FurC_SearchBox:GetText()
+    FurC_SearchBoxText:SetText((#text == 0 and FURC_S_FILTERDEFAULT) or "")
+    FurC.LastFilter = useDefaults
+    FurC.SetFilter(useDefaults, true)
+end
+local function stopLoading()
+    FurC.IsLoading(false)
+    updateLineVisibility()
+end
+local function stopLoadingWithDelay()
+    zo_callLater(stopLoading, 500)
+end

 function FurC.UpdateGui(useDefaults)
 	if FurCGui:IsHidden() then return end
-
-	otherTask:Call(function()
-
-		FurC.IsLoading(true)
-		FurC.LastFilter = useDefaults
-		FurC.SetFilter(useDefaults, true)
-	end)
+    cachedDefaults = useDefaults
+	otherTask:Call(startLoading)
 	:Then(updateScrollDataLinesData)
-	:Then(function()  zo_callLater(function()
-
-		FurC.IsLoading(false)
-		updateLineVisibility()
-
-	end, 200) end)
+	:Then(stopLoadingWithDelay)
 end

 function FurC.UpdateInventoryScroll()
diff --git a/FurCSettingsAdapter.lua b/FurCSettingsAdapter.lua
index 6d0b1cc..0e241d2 100644
--- a/FurCSettingsAdapter.lua
+++ b/FurCSettingsAdapter.lua
@@ -249,20 +249,21 @@ function FurC.SetFilterCraftingType(craftingType)
 end


+local FURC_S_FILTERDEFAULT = GetString(SI_FURC_TEXTBOX_FILTER_DEFAULT)
+
 function FurC.GetSearchFilter()
-	if (not FurC.SearchFilter) or FurC.SearchFilter == "Filter by text search" then
+	if (not FurC.SearchFilter) or FurC.SearchFilter == FURC_S_FILTERDEFAULT then
 		FurC.SearchFilter = FurC_SearchBox:GetText() or ""
 	end
-
 	return FurC.SearchFilter or ""
 end
-
 function FurC.GuiSetSearchboxTextFrom(control)
+    control = control or FurC_SearchBox
 	-- call asynchronely to prevent lagging. Praise votan.
 	task:Call(function()
-		local text = control:GetText()
-        control:GetNamedChild("Text"):SetText((text == "" and "Filter by text search") or "")
-
+		local text = FurC_SearchBox:GetText()
+        FurC_SearchBoxText:SetText((#text == 0 and FURC_S_FILTERDEFAULT) or "")
+
 		FurC.SearchFilter = text

 		FurC.GuiOnSliderUpdate(FurCGui_ListHolder_Slider, 0)