Skip to content

Commit

Permalink
Fix import with discriminators (#8361)
Browse files Browse the repository at this point in the history
* fix Import With Discriminators

* make it use `#` instead of `-`

* update to only gsub on page downloads, and fix account name dropdown

* fix saved value

* cleanup extra gsub
  • Loading branch information
Regisle authored Nov 18, 2024
1 parent 78b52c9 commit 3a0e067
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions src/Classes/ImportTab.lua
Original file line number Diff line number Diff line change
Expand Up @@ -411,7 +411,7 @@ function ImportTabClass:DownloadCharacterList()
accountName = self.controls.accountName.buf:gsub("^[%s?]+", ""):gsub("[%s?]+$", ""):gsub("%s", "+")
end
local sessionID = #self.controls.sessionInput.buf == 32 and self.controls.sessionInput.buf or (main.gameAccounts[accountName] and main.gameAccounts[accountName].sessionID)
launch:DownloadPage(realm.hostName.."character-window/get-characters?accountName="..accountName.."&realm="..realm.realmCode, function(response, errMsg)
launch:DownloadPage(realm.hostName.."character-window/get-characters?accountName="..accountName:gsub("-", "%%23"):gsub("#", "%%23").."&realm="..realm.realmCode, function(response, errMsg)
if errMsg == "Response code: 401" then
self.charImportStatus = colorCodes.NEGATIVE.."Sign-in is required."
self.charImportMode = "GETSESSIONID"
Expand Down Expand Up @@ -443,7 +443,7 @@ function ImportTabClass:DownloadCharacterList()
end
-- GGG's character API has an issue where for /get-characters the account name is not case-sensitive, but for /get-passive-skills and /get-items it is.
-- This workaround grabs the profile page and extracts the correct account name from one of the URLs.
launch:DownloadPage(realm.hostName..realm.profileURL..accountName, function(response, errMsg)
launch:DownloadPage(realm.hostName..realm.profileURL..accountName:gsub("#", "%%23"), function(response, errMsg)
if errMsg then
self.charImportStatus = colorCodes.NEGATIVE.."Error retrieving character list, try again ("..errMsg:gsub("\n"," ")..")"
self.charImportMode = "GETACCOUNTNAME"
Expand All @@ -455,6 +455,7 @@ function ImportTabClass:DownloadCharacterList()
self.charImportMode = "GETSESSIONID"
return
end
realAccountName = realAccountName:gsub("-", "#")
self.controls.accountName:SetText(realAccountName)
accountName = realAccountName
self.charImportStatus = "Character list successfully retrieved."
Expand Down Expand Up @@ -558,11 +559,11 @@ function ImportTabClass:SaveAccountHistory()
if not historyList[self.controls.accountName.buf] then
t_insert(historyList, self.controls.accountName.buf)
historyList[self.controls.accountName.buf] = true
self.controls.accountHistory:SelByValue(self.controls.accountName.buf)
table.sort(historyList, function(a,b)
return a:lower() < b:lower()
end)
self.controls.accountHistory:CheckDroppedWidth(true)
self.controls.accountHistory:SelByValue(self.controls.accountName.buf)
end
end

Expand All @@ -574,7 +575,7 @@ function ImportTabClass:DownloadPassiveTree()
local sessionID = #self.controls.sessionInput.buf == 32 and self.controls.sessionInput.buf or (main.gameAccounts[accountName] and main.gameAccounts[accountName].sessionID)
local charSelect = self.controls.charSelect
local charData = charSelect.list[charSelect.selIndex].char
launch:DownloadPage(realm.hostName.."character-window/get-passive-skills?accountName="..accountName.."&character="..charData.name.."&realm="..realm.realmCode, function(response, errMsg)
launch:DownloadPage(realm.hostName.."character-window/get-passive-skills?accountName="..accountName:gsub("#", "%%23").."&character="..charData.name.."&realm="..realm.realmCode, function(response, errMsg)
self.charImportMode = "SELECTCHAR"
if errMsg then
self.charImportStatus = colorCodes.NEGATIVE.."Error importing character data, try again ("..errMsg:gsub("\n"," ")..")"
Expand All @@ -596,7 +597,7 @@ function ImportTabClass:DownloadItems()
local sessionID = #self.controls.sessionInput.buf == 32 and self.controls.sessionInput.buf or (main.gameAccounts[accountName] and main.gameAccounts[accountName].sessionID)
local charSelect = self.controls.charSelect
local charData = charSelect.list[charSelect.selIndex].char
launch:DownloadPage(realm.hostName.."character-window/get-items?accountName="..accountName.."&character="..charData.name.."&realm="..realm.realmCode, function(response, errMsg)
launch:DownloadPage(realm.hostName.."character-window/get-items?accountName="..accountName:gsub("#", "%%23").."&character="..charData.name.."&realm="..realm.realmCode, function(response, errMsg)
self.charImportMode = "SELECTCHAR"
if errMsg then
self.charImportStatus = colorCodes.NEGATIVE.."Error importing character data, try again ("..errMsg:gsub("\n"," ")..")"
Expand Down

0 comments on commit 3a0e067

Please sign in to comment.