Fixed broken get_current_user not working

Signed-off-by: Robear Selwans <robear.selwans@outlook.com>
This commit is contained in:
2026-04-11 00:01:05 +02:00
parent 1d478708ad
commit 6c9e4db8bf
2 changed files with 8 additions and 8 deletions

View File

@@ -26,13 +26,13 @@ function M.get_current_user(callback)
"-s", "-s",
"--fail", "--fail",
"-X", "-X",
"POST", "GET",
config.host .. "/api/v1/auth/status", config.host .. "/api/v1/auth/me",
}, function(job, return_val) }, function(job, return_val)
if return_val == 0 then if return_val == 0 then
local result_string = table.concat(job:result(), "") local result_string = table.concat(job:result(), "")
local data = vim.json.decode(result_string) local data = vim.json.decode(result_string)
callback(data or nil) callback(data and data.user or nil)
else else
vim.schedule(function() vim.schedule(function()
vim.notify("Failed to get user info.", vim.log.levels.ERROR) vim.notify("Failed to get user info.", vim.log.levels.ERROR)

View File

@@ -298,12 +298,12 @@ function M.show_memos_list(filter)
vim.notify("Getting user info...") vim.notify("Getting user info...")
end) end)
api.get_current_user(function(user) api.get_current_user(function(user)
if user and user.name then if user and user.username then
current_user = user current_user = user
vim.schedule(function() vim.schedule(function()
vim.notify("Fetching memos for " .. user.name .. "...") vim.notify("Fetching memos for " .. user.username .. "...")
end) end)
api.list_memos(user.name, current_filter, config.page_size, nil, function(data) api.list_memos(user.username, current_filter, config.page_size, nil, function(data)
M.render_memos(data, false) M.render_memos(data, false)
end) end)
else else
@@ -353,14 +353,14 @@ function M.load_next_page()
vim.notify("No more pages to load.", vim.log.levels.INFO) vim.notify("No more pages to load.", vim.log.levels.INFO)
return return
end end
if not current_user or not current_user.name then if not current_user or not current_user.username then
vim.notify("User info not available.", vim.log.levels.WARN) vim.notify("User info not available.", vim.log.levels.WARN)
return return
end end
vim.schedule(function() vim.schedule(function()
vim.notify("Loading next page...") vim.notify("Loading next page...")
end) end)
api.list_memos(current_user.name, current_filter, config.page_size, current_page_token, function(data) api.list_memos(current_user.username, current_filter, config.page_size, current_page_token, function(data)
M.render_memos(data, true) M.render_memos(data, true)
end) end)
end end