feat(submit): show progress notifications during submit
Problem: `M.submit` gave no UI feedback between credential entry and final result, leaving users staring at a silent hang for 10-30s. Solution: Add `STATUS_MSGS` map and emit an immediate `vim.notify` on submit start. Pass an `on_status` handler to `scraper.submit` that fires a notification for each phase (`checking_login`, `logging_in`, etc.).
This commit is contained in:
parent
ecbe60cbd8
commit
9272a9660e
1 changed files with 14 additions and 0 deletions
|
|
@ -4,6 +4,13 @@ local cache = require('cp.cache')
|
|||
local logger = require('cp.log')
|
||||
local state = require('cp.state')
|
||||
|
||||
local STATUS_MSGS = {
|
||||
installing_browser = 'Installing browser (first time setup)...',
|
||||
checking_login = 'Checking login...',
|
||||
logging_in = 'Logging in...',
|
||||
submitting = 'Submitting...',
|
||||
}
|
||||
|
||||
local function prompt_credentials(platform, callback)
|
||||
local saved = cache.get_credentials(platform)
|
||||
if saved and saved.username and saved.password then
|
||||
|
|
@ -48,6 +55,8 @@ function M.submit(opts)
|
|||
local source_lines = vim.fn.readfile(source_file)
|
||||
local source_code = table.concat(source_lines, '\n')
|
||||
|
||||
vim.notify('[cp.nvim] Submitting...', vim.log.levels.INFO)
|
||||
|
||||
require('cp.scraper').submit(
|
||||
platform,
|
||||
contest_id,
|
||||
|
|
@ -55,6 +64,11 @@ function M.submit(opts)
|
|||
language,
|
||||
source_code,
|
||||
creds,
|
||||
function(status)
|
||||
vim.schedule(function()
|
||||
vim.notify('[cp.nvim] ' .. (STATUS_MSGS[status] or status), vim.log.levels.INFO)
|
||||
end)
|
||||
end,
|
||||
function(result)
|
||||
vim.schedule(function()
|
||||
if result and result.success then
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue