Skip to content

Instantly share code, notes, and snippets.

@IlyaHalsky
Created June 29, 2018 13:55
Show Gist options
  • Save IlyaHalsky/39fdf494463335dba6787c33ae9ef089 to your computer and use it in GitHub Desktop.
Save IlyaHalsky/39fdf494463335dba6787c33ae9ef089 to your computer and use it in GitHub Desktop.
def resetAction: State ⇒ State = {
if (errorMap.nonEmpty) PrintColored("r")(s"Warning: This list $listUniqueName contains columns with same srcIds: $errorMap")
val columns: List[Access[ReactColumnSetting]] = getColumns.map(col ⇒ columnSettingsMap(col.columnSrcId + listUniqueName))
val resetColumnsAction: List[State ⇒ State] =
for {
col ← columns
} yield {
val init = col.initialValue
col.updatingLens.get.set(init.copy(
displayOrder = None,
priority = columnMap.get(init.columnIdPlusListId).flatten,
sortOrder = None,
sortAscending = None,
newOrder = false,
priorityOpen = false,
orderOpen = false
))
}
val consensusReset = consensusInitValue.updatingLens.get.set(consensusInitValue.initialValue.copy(
pendingChange = false,
activeOrders = Nil,
totalOrdered = 0
))
resetColumnsAction.fold(consensusReset)((a, b) ⇒ a andThen b)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment