Skip to content

Commit

Permalink
do item edge healing in the processing loops #11
Browse files Browse the repository at this point in the history
  • Loading branch information
sobri909 committed May 8, 2018
1 parent c547ee4 commit fb88001
Showing 1 changed file with 14 additions and 9 deletions.
23 changes: 14 additions & 9 deletions LocoKit/Base/Timelines/TimelineProcessor.swift
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ public class TimelineProcessor {

var merges: Set<Merge> = []
for workingItem in items {
healEdges(of: workingItem)
workingItem.sanitiseEdges()

// add in the merges for one step forward
Expand Down Expand Up @@ -132,6 +133,9 @@ public class TimelineProcessor {
public static func safeDelete(_ deadman: TimelineItem, completion: ((TimelineItem?) -> Void)? = nil) {
guard let store = deadman.store else { return }
store.process {
healEdges(of: deadman)
deadman.sanitiseEdges()

var merges: Set<Merge> = []

// merge next and previous
Expand Down Expand Up @@ -179,17 +183,16 @@ public class TimelineProcessor {
}
}

public static func healEdges(of brokenItem: TimelineItem) {
guard let store = brokenItem.store else { return }
store.process {
if brokenItem.isMergeLocked { return }
if !brokenItem.hasBrokenEdges { return }
// MARK: - Item edge healing

print("\(brokenItem.itemId)")
private static func healEdges(of brokenItem: TimelineItem) {
if brokenItem.isMergeLocked { return }
if !brokenItem.hasBrokenEdges { return }

self.healNextEdge(of: brokenItem)
self.healPreviousEdge(of: brokenItem)
}
print("\(brokenItem.itemId)")

self.healNextEdge(of: brokenItem)
self.healPreviousEdge(of: brokenItem)
}

private static func healNextEdge(of brokenItem: TimelineItem) {
Expand Down Expand Up @@ -263,6 +266,8 @@ public class TimelineProcessor {
print("COULDN'T HEAL PREVIOUSITEM EDGE")
}

// MARK: - Data gap insertion

public static func insertDataGapBetween(newer newerItem: TimelineItem, older olderItem: TimelineItem) {
guard let store = newerItem.store else { return }
store.process {
Expand Down

0 comments on commit fb88001

Please sign in to comment.