Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Re-add removal & sorting #7

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
77 changes: 39 additions & 38 deletions main.lua
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
local RF = select(2, ...)
local servers = RF.servers
local posts = RF.posts
RF.version = "1.5.0"
RF.togRemove = false
RF.version = "1.6.0"
RF.togRemove = true

local spaced_realm = string.gsub(GetRealmName(), "%s+", "")
RF.myRealm = string.gsub(spaced_realm, "'", "")
Expand All @@ -24,30 +24,31 @@ if RF.region == 'OC' then RF.postType = posts.oc_post end
if RF.region == 'LA' then RF.postType = posts.la_post end
if RF.region == 'BR' then RF.postType = posts.br_post end
---- Removing Enrties when togRemove is enabled
-- function RF.removeEntries(results)
-- if RF.togRemove then
-- for i=1, #results do
-- local resultID = results[i]
-- local searchResults = C_LFGList.GetSearchResultInfo(resultID)
function RF.sortEntries(results)
if RF.togRemove then
for i=1, #results do
local resultID = results[i]
if (resultID ~= nil) then
local searchResultData = C_LFGList.GetSearchResultInfo(resultID)
local leaderName = searchResultData.leaderName

-- local leaderName = searchResults.leaderName

-- if leaderName ~= nil then -- Filter out nil entries from LFG Pane
-- local name, realm = RF:sanitiseName(leaderName)
-- local info = servers[realm]
-- if info ~= nil then
-- local region = info[1]
-- if RF.region ~= region then
-- table.remove(results, i)
-- end
-- end
-- end
-- end
-- end
-- table.sort(results)
-- LFGListFrame.SearchPanel.totalResults = #results
-- return true
-- end
if leaderName ~= nil then -- Filter out nil entries from LFG Pane
local name, realm = RF:sanitiseName(leaderName)
local info = servers[realm]
if info ~= nil then
local region = info[1]
if RF.region ~= region then
table.remove(results, i)
end
end
end
end
end
end
table.sort(results)
LFGListFrame.SearchPanel.totalResults = #results
return true
end

---- Updating the text of entries
function RF.updateEntries(results)
Expand Down Expand Up @@ -81,17 +82,17 @@ function RF.updateEntries(results)
end


-- SLASH_RFILTER1 = "/rfilter"
-- SlashCmdList["RFILTER"] = function(msg)
-- if RF.togRemove then
-- print('|cff00ffff[Region Filter]: |cffFF6EB4 Not filtering outside regions')
-- else
-- print('|cff00ffff[Region Filter]: |cffFF6EB4 Filtering outside regions')
-- end
-- RF.togRemove = not RF.togRemove
-- LFGListSearchPanel_UpdateResultList (LFGListFrame.SearchPanel)
-- LFGListSearchPanel_UpdateResults (LFGListFrame.SearchPanel)
-- end
SLASH_RFILTER1 = "/rfilter"
SlashCmdList["RFILTER"] = function(msg)
if RF.togRemove then
print('|cff00ffff[Region Filter]: |cffFF6EB4 Not filtering outside regions')
else
print('|cff00ffff[Region Filter]: |cffFF6EB4 Filtering outside regions')
end
RF.togRemove = not RF.togRemove
LFGListSearchPanel_UpdateResultList (LFGListFrame.SearchPanel)
LFGListSearchPanel_UpdateResults (LFGListFrame.SearchPanel)
end

---- Print When Loaded ----
local welcomePrompt = CreateFrame("Frame")
Expand All @@ -103,5 +104,5 @@ welcomePrompt:SetScript("OnEvent", function(_, event)
end
end)

-- hooksecurefunc("LFGListUtil_SortSearchResults", RF.sortEntries)
hooksecurefunc("LFGListSearchEntry_Update", RF.updateEntries)
hooksecurefunc("LFGListUtil_SortSearchResults", RF.sortEntries)
hooksecurefunc("LFGListSearchEntry_Update", RF.updateEntries)