Browse Source

fix dmenu selected accountName index not matching list of accounts

master
Andrew Kaiser 6 years ago
parent
commit
8804c65df9
2 changed files with 6 additions and 5 deletions
  1. +1
    -1
      package.json
  2. +5
    -4
      src/index.js

+ 1
- 1
package.json View File

@ -1,6 +1,6 @@
{ {
"name": "bitwarden-dmenu", "name": "bitwarden-dmenu",
"version": "1.2.3",
"version": "1.2.4",
"description": "dmenu for bitwarden password manager.", "description": "dmenu for bitwarden password manager.",
"keywords": [ "keywords": [
"bitwarden", "bitwarden",


+ 5
- 4
src/index.js View File

@ -56,13 +56,14 @@ const getAccounts = ({ session }) => {
// choose one account with dmenu // choose one account with dmenu
const chooseAccount = async ({ list }) => { const chooseAccount = async ({ list }) => {
const LOGIN_TYPE = 1 const LOGIN_TYPE = 1
const accountNames = list
.filter(a => a.type === LOGIN_TYPE)
.map(a => `${a.name}: ${a.login.username}`)
const loginList = list.filter(a => a.type === LOGIN_TYPE)
const accountNames = loginList.map(a => `${a.name}: ${a.login.username}`)
// -i allows case insensitive matching // -i allows case insensitive matching
const selected = await dmenuRun('-i')(accountNames.join('\n')) const selected = await dmenuRun('-i')(accountNames.join('\n'))
const index = accountNames.indexOf(selected) const index = accountNames.indexOf(selected)
const selectedAccount = list[index]
// accountNames indexes match loginList indexes
const selectedAccount = loginList[index]
console.debug('selected account:\n', obfuscate(selectedAccount)) console.debug('selected account:\n', obfuscate(selectedAccount))
return selectedAccount return selectedAccount
} }


Loading…
Cancel
Save