From 7ed9c1e3cd1788b2c980173e0dc50e320ca03104 Mon Sep 17 00:00:00 2001 From: Fangjun Zhou Date: Thu, 27 Jun 2024 01:54:06 -0500 Subject: [PATCH] fix: provide an option for not showing the expired window when getting 401/403 This is a suggested temprary fix for http 401/403 error from leetcode. --- lua/leetcode/api/utils.lua | 2 +- lua/leetcode/config/template.lua | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/lua/leetcode/api/utils.lua b/lua/leetcode/api/utils.lua index 01210743..166d86c8 100644 --- a/lua/leetcode/api/utils.lua +++ b/lua/leetcode/api/utils.lua @@ -151,7 +151,7 @@ function utils.check_err(err) end if err.status then - if err.status == 401 or err.status == 403 then + if (err.status == 401 or err.status == 403) and config.user.show_menu_when_expire then require("leetcode.command").expire() err.msg = "Session expired? Enter a new cookie to keep using `leetcode.nvim`" end diff --git a/lua/leetcode/config/template.lua b/lua/leetcode/config/template.lua index 27590e0b..600450d8 100644 --- a/lua/leetcode/config/template.lua +++ b/lua/leetcode/config/template.lua @@ -127,6 +127,9 @@ local M = { ---@type boolean image_support = false, + + ---@type boolean + show_menu_when_expire = false, } return M