@bloks/wallet
Advanced tools
Comparing version 3.5.11 to 3.5.12-alpha.0
{ | ||
"name": "@bloks/wallet", | ||
"version": "3.5.11", | ||
"version": "3.5.12-alpha.0", | ||
"description": "", | ||
@@ -16,3 +16,3 @@ "publishConfig": { | ||
}, | ||
"gitHead": "c1a7de5d6c015dae3e71151b29b667f16057f5ae" | ||
"gitHead": "d440e24e25aff849f2d3dac8b423de037eed132c" | ||
} |
@@ -25,8 +25,12 @@ import store from 'store' | ||
findUserIndex ({ actor, permission, publicKey, wallet }) { | ||
isSame (user1, user2) { | ||
return user1.actor === user2.actor && | ||
user1.permission === user2.permission && | ||
user1.wallet === user2.wallet && | ||
user1.publicKey === user2.publicKey | ||
} | ||
findUserIndex (newUser) { | ||
return this.users.findIndex( | ||
user => user.actor === actor && | ||
user.permission === permission && | ||
user.wallet === wallet && | ||
user.publicKey === publicKey | ||
user => this.isSame(user, newUser) | ||
) | ||
@@ -45,3 +49,3 @@ } | ||
addUser (newUser) { | ||
addUser (newUser, save = true) { | ||
const userIndex = this.findUserIndex(newUser) | ||
@@ -57,2 +61,23 @@ newUser = Object.assign({}, defaultUser(), newUser) | ||
} | ||
addUsers (users) { | ||
let newUser | ||
for (const user of users) { | ||
const userIndex = this.findUserIndex(user) | ||
newUser = Object.assign({}, defaultUser(), user) | ||
if (userIndex === -1) { | ||
this.users.push(newUser) | ||
} | ||
} | ||
this.saveUsers() | ||
} | ||
searchUsers (query) { | ||
return this.users.filter( | ||
user => user.actor === query.toLowerCase() | ||
) | ||
} | ||
@@ -62,2 +87,7 @@ removeUser (newUser) { | ||
// If current user, remove | ||
if (this.isSame(this.users[userIndex], this.user)) { | ||
this.setUser({}) | ||
} | ||
if (userIndex !== -1) { | ||
@@ -64,0 +94,0 @@ this.users.splice(userIndex, 1) |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
15742
649
2