Skip to content

Commit

Permalink
routine bug fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
ethayer committed Nov 11, 2015
1 parent 99713cd commit 7a02594
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions user-lock-manager.smartapp.groovy
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* User Lock Manager v4.0.7
* User Lock Manager v4.0.8
*
* Copyright 2015 Erik Thayer
*
Expand Down Expand Up @@ -392,12 +392,11 @@ def getConflicts(i) {
def ind = 0
state."lock${lock.id}".codes.each { code ->
ind++
if (currentSlot.toInteger() != ind.toInteger() && !isUnique(currentCode, state."lock${lock.id}".codes."slot${ind}")) {
if (currentSlot?.toInteger() != ind.toInteger() && !isUnique(currentCode, state."lock${lock.id}".codes."slot${ind}")) {
conflict.has_conflict = true
state."userState${i}".enabled = false
state."userState${i}".disabledReason = "Code Conflict Detected"
conflict."lock${lock.id}".conflicts << ind
log.debug conflict."lock${lock.id}".conflicts
}
}
}
Expand All @@ -413,21 +412,27 @@ def isUnique(newInt, oldInt) {
return true
}

if (!newInt.isInteger() || !newInt.isInteger()) {
// number is not an integer, can't check.
return true
}


def newArray = []
def oldArray = []
def result = true

def i = 0
// Get a normalized sequence, at the same length
newInt.toList().collect {
newInt.toString().toList().collect {
i++
if (i <= oldInt.length()) {
newArray << normalizeNumber(it.toInteger())
}
}

i = 0
oldInt.toList().collect {
oldInt.toString().toList().collect {
i++
if (i <= newInt.length()) {
oldArray << normalizeNumber(it.toInteger())
Expand Down

0 comments on commit 7a02594

Please sign in to comment.