Skip to content

Commit

Permalink
refactor: don't close all questions on session expired
Browse files Browse the repository at this point in the history
  • Loading branch information
kawre committed Mar 6, 2024
1 parent f137d78 commit 9cb20d5
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions lua/leetcode/command/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -81,10 +81,11 @@ function cmd.cookie_prompt(cb)
end

function cmd.sign_out()
cmd.menu()

log.warn("You're now signed out")
cmd.delete_cookie()
cmd.set_menu_page("signin")
cmd.q_close_all()
end

---Sign out
Expand Down Expand Up @@ -119,9 +120,7 @@ cmd.expire = vim.schedule_wrap(function()
end
log.info("Successful re-login")
else
cmd.delete_cookie()
cmd.set_menu_page("signin")
cmd.q_close_all()
cmd.sign_out()
end
end)
end)
Expand Down Expand Up @@ -359,7 +358,6 @@ end

function cmd.restore()
local utils = require("leetcode.utils")
utils.auth_guard()
local q = utils.curr_question()
if not q then
return
Expand All @@ -385,7 +383,6 @@ end

function cmd.inject()
local utils = require("leetcode.utils")
utils.auth_guard()
local q = utils.curr_question()
if not q then
return
Expand Down Expand Up @@ -439,6 +436,8 @@ function cmd.get_session_by_name(name)
end

function cmd.change_session(opts)
require("leetcode.utils").auth_guard()

local name = opts.name[1] or config.sessions.default

local session = cmd.get_session_by_name(name)
Expand All @@ -457,6 +456,8 @@ function cmd.change_session(opts)
end

function cmd.create_session(opts)
require("leetcode.utils").auth_guard()

local name = opts.name[1]
if not name then
return log.error("Session name not provided")
Expand All @@ -472,6 +473,8 @@ function cmd.create_session(opts)
end

function cmd.update_sessions()
require("leetcode.utils").auth_guard()

config.stats.update_sessions()
end

Expand Down

0 comments on commit 9cb20d5

Please sign in to comment.