fix(gh): properly handly pending requests

This commit is contained in:
Folke Lemaitre 2025-11-06 16:57:21 +01:00
parent cd0d6fe864
commit 7a15e16d01
No known key found for this signature in database
GPG key ID: 9B52594D560070AB
4 changed files with 5 additions and 5 deletions

View file

@ -464,6 +464,7 @@ function M.comments(item, cb)
state
commit { oid }
submittedAt
createdAt
reactionGroups {
content
users { totalCount }

View file

@ -126,7 +126,6 @@ function M:update(data, fields)
vim.tbl_map(fix, item.comments or {})
for _, review in ipairs(item.reviews or {}) do
fix(review)
review.created = review.submitted
vim.tbl_map(fix, review.comments or {})
end

View file

@ -302,13 +302,12 @@ function M.render(buf, item, opts)
for _, thread in ipairs(threads) do
local c = #lines
if thread.submitted then
ctx.is_review = thread.state ~= nil
if ctx.is_review then
---@cast thread snacks.gh.Review
ctx.is_review = true
vim.list_extend(lines, M.review(thread, ctx))
else
---@cast thread snacks.gh.Comment
ctx.is_review = false
vim.list_extend(lines, M.comment(thread, ctx))
end

View file

@ -100,6 +100,7 @@
---@field author snacks.gh.User
---@field authorAssociation string
---@field body string
---@field createdAt string
---@field submittedAt string
---@field submitted number
---@field created number
@ -108,7 +109,7 @@
---@field commit? {oid: string}
---@field comments? snacks.gh.Comment[]
---@alias snacks.gh.Thread snacks.gh.Comment|snacks.gh.Review|{created: number}
---@alias snacks.gh.Thread snacks.gh.Comment|snacks.gh.Review
---@class snacks.gh.Item
---@field number number