Skip to content
This repository has been archived by the owner on May 6, 2024. It is now read-only.

Commit

Permalink
refactor: refactor child block completion
Browse files Browse the repository at this point in the history
  • Loading branch information
Muhammad Umer committed Jul 26, 2023
1 parent 0404094 commit bea2f85
Showing 1 changed file with 13 additions and 10 deletions.
23 changes: 13 additions & 10 deletions Source/CourseOutlineTableSource.swift
Original file line number Diff line number Diff line change
Expand Up @@ -769,19 +769,22 @@ extension CourseOutlineTableController: BlockCompletionDelegate {

if let index = groups.firstIndex(where: { $0.block.blockID == blockGroup.block.blockID }) {
groups[index] = blockGroup
collapsedSections.removeAll()
hasAddedToCollapsedSections = false
setGroups(groups)
} else {
if let index = groups.firstIndex(where: { $0.block.blockID == blockGroup.block.blockID }),
let child = courseQuerier.childrenOfBlockWithID(blockID: groups[index].block.blockID, forMode: .full).value,
let indexOfBlock = child.children.firstIndex(where: { $0.blockID == blockGroup.block.blockID }) {
var updatedChild = child
updatedChild.children[indexOfBlock] = blockGroup.block
groups[index] = updatedChild
for (index, group) in groups.enumerated() {
guard var child = courseQuerier.childrenOfBlockWithID(blockID: group.block.blockID, forMode: .full).value else { continue }
if let indexOfBlock = child.children.firstIndex(where: { $0.blockID == blockGroup.block.blockID }) {
child.children[indexOfBlock] = blockGroup.block
groups[index] = child
collapsedSections.removeAll()
hasAddedToCollapsedSections = false
setGroups(groups)
break
}
}
}

collapsedSections.removeAll()
hasAddedToCollapsedSections = false
setGroups(groups)
}
}

Expand Down

0 comments on commit bea2f85

Please sign in to comment.