diff --git a/lua/leetcode/api/auth.lua b/lua/leetcode/api/auth.lua index a677aad..cef2f94 100644 --- a/lua/leetcode/api/auth.lua +++ b/lua/leetcode/api/auth.lua @@ -36,7 +36,7 @@ function Auth.handle(res, err) err = {} if (not config.is_cn and auth.id == vim.NIL) or (config.is_cn and auth.slug == vim.NIL) then - err.msg = "Session expired?" + err.msg = "Cookie expired?" elseif not auth.is_signed_in then err.msg = "Sign-in failed" elseif not auth.is_verified then diff --git a/lua/leetcode/api/statistics.lua b/lua/leetcode/api/statistics.lua index adac765..6ce24db 100644 --- a/lua/leetcode/api/statistics.lua +++ b/lua/leetcode/api/statistics.lua @@ -135,9 +135,16 @@ function statistics.streak(cb) if err then return cb(nil, err) end + local data = res.data local streak = data["streakCounter"] - cb(streak) + + if streak == vim.NIL then + err = { msg = "Failed to load streak counter" } + cb(nil, err) + else + cb(streak) + end end, }) end diff --git a/lua/leetcode/api/utils.lua b/lua/leetcode/api/utils.lua index 0121074..455caf0 100644 --- a/lua/leetcode/api/utils.lua +++ b/lua/leetcode/api/utils.lua @@ -152,8 +152,9 @@ function utils.check_err(err) if err.status then if err.status == 401 or err.status == 403 then - require("leetcode.command").expire() - err.msg = "Session expired? Enter a new cookie to keep using `leetcode.nvim`" + -- require("leetcode.command").expire() + err.msg = + "Your cookie may have expired, or LeetCode has temporarily restricted API access" end end