File tree Expand file tree Collapse file tree 2 files changed +27
-3
lines changed Expand file tree Collapse file tree 2 files changed +27
-3
lines changed Original file line number Diff line number Diff line change @@ -49,9 +49,16 @@ local function content()
4949 local resolvable_notes , resolved_notes = get_data (state .DISCUSSION_DATA .unlinked_discussions )
5050
5151 local draft_notes = require (" gitlab.actions.draft_notes" )
52- local inline_draft_notes = List .new (state .DRAFT_NOTES ):filter (draft_notes .has_position )
53- local unlinked_draft_notes = List .new (state .DRAFT_NOTES ):filter (function (note )
54- return not draft_notes .has_position (note )
52+ local inline_draft_notes , unlinked_draft_notes = List .new (state .DRAFT_NOTES ):partition (function (note )
53+ if note .discussion_id == " " then
54+ return draft_notes .has_position (note )
55+ end
56+ for _ , discussion in ipairs (state .DISCUSSION_DATA .unlinked_discussions ) do
57+ if discussion .id == note .discussion_id then
58+ return false
59+ end
60+ end
61+ return true
5562 end )
5663
5764 local t = {
Original file line number Diff line number Diff line change @@ -33,6 +33,23 @@ function List:filter(func)
3333 return result
3434end
3535
36+ --- Partitions a given list into two lists
37+ --- @generic T
38+ --- @param func fun ( v : T , i : integer ): boolean
39+ --- @return List<T> , List<T> @Returns two lists : the 1st with elements for which func returns true , the 2nd with elements for which it returns false
40+ function List :partition (func )
41+ local result_true = List .new ()
42+ local result_false = List .new ()
43+ for i , v in ipairs (self ) do
44+ if func (v , i ) == true then
45+ table.insert (result_true , v )
46+ else
47+ table.insert (result_false , v )
48+ end
49+ end
50+ return result_true , result_false
51+ end
52+
3653function List :reduce (func , agg )
3754 for i , v in ipairs (self ) do
3855 agg = func (agg , v , i )
You can’t perform that action at this time.
0 commit comments