Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion lua/gitlab/async.lua
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,16 @@ function async:fetch(dependencies, i, argTable)

-- Call the API, set the data, and then call the next API
local body = dependency.body and dependency.body(argTable) or nil
local on_error = nil
if dependency.non_blocking then
on_error = function()
self:fetch(dependencies, i + 1, argTable)
end
end
Comment on lines +40 to +45
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a nitpick refactor suggestion: You can get rid of one line by moving the if condition into the callback body:

Suggested change
local on_error = nil
if dependency.non_blocking then
on_error = function()
self:fetch(dependencies, i + 1, argTable)
end
end
local on_error = function()
if dependency.non_blocking then
self:fetch(dependencies, i + 1, argTable)
end
end

I haven't tested this though :)

Copy link
Copy Markdown
Contributor Author

@Clement-Hue Clement-Hue May 5, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, should work. I had to do this workaround to make it work since the draft notes was not supported by my gitlab. But I think there could be better solutions like fetching everything in parallel rather than in sync? Because there could be other requests that could fail and prevent all requests left to be performed.

job.run_job(dependency.endpoint, dependency.method or "GET", body, function(data)
state[dependency.state] = dependency.key and data[dependency.key] or data
self:fetch(dependencies, i + 1, argTable)
end)
end, on_error)
end

-- Will call APIs in sequence and set global state
Expand Down
1 change: 1 addition & 0 deletions lua/gitlab/state.lua
Original file line number Diff line number Diff line change
Expand Up @@ -538,6 +538,7 @@ M.dependencies = {
key = "draft_notes",
state = "DRAFT_NOTES",
refresh = false,
non_blocking = true,
},
project_members = {
endpoint = "/project/members",
Expand Down
Loading