function getStateList()

in src/components/History/HistoryView/StateListContainer.tsx [18:49]


function getStateList(
  historyGraph,
  commitPath,
  bookmarks,
  highlightSuccessorsOf,
  getSourceFromState
) {
  const {
    currentBranch,
    currentStateId,
  } = historyGraph;
  const activeBranchStartsAt = historyGraph.branchStartDepth(currentBranch);
  const isBookmarked = (id) => bookmarks.map(b => b.stateId).includes(id);
  return commitPath.map((id, index) => {
    const branchType = index < activeBranchStartsAt ? 'legacy' : 'current';
    const pinned = highlightSuccessorsOf === id;
    const active = currentStateId === id;
    const successor = isNumber(highlightSuccessorsOf) &&
      historyGraph.parentOf(id) === highlightSuccessorsOf;

    return {
      id,
      isBookmarked,
      pinned,
      active,
      successor,
      branchType,
      historyGraph,
      getSourceFromState,
    };
  }).reverse();
}