refactor(submit): consolidate credentials into main cache file
Problem: credentials were stored in a separate file, cp-nvim-credentials.json, alongside the main cp-nvim.json cache. Two files for one plugin's persistent state was unnecessary. Solution: add get_credentials/set_credentials to cache.lua, storing credentials under _credentials[platform] in the shared cache. Update clear_all() to preserve _credentials across cache wipes. Remove the separate file, load_credentials, and save_credentials from submit.lua.
This commit is contained in:
parent
52cf54d05c
commit
a08d1f0c5e
2 changed files with 24 additions and 35 deletions
|
|
@ -371,8 +371,29 @@ function M.get_contest_start_time(platform, contest_id)
|
|||
return cache_data[platform][contest_id].start_time
|
||||
end
|
||||
|
||||
---@param platform string
|
||||
---@return table?
|
||||
function M.get_credentials(platform)
|
||||
if not cache_data._credentials then
|
||||
return nil
|
||||
end
|
||||
return cache_data._credentials[platform]
|
||||
end
|
||||
|
||||
---@param platform string
|
||||
---@param creds table
|
||||
function M.set_credentials(platform, creds)
|
||||
cache_data._credentials = cache_data._credentials or {}
|
||||
cache_data._credentials[platform] = creds
|
||||
M.save()
|
||||
end
|
||||
|
||||
function M.clear_all()
|
||||
local creds = cache_data._credentials
|
||||
cache_data = {}
|
||||
if creds then
|
||||
cache_data._credentials = creds
|
||||
end
|
||||
M.save()
|
||||
end
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue