diff options
author | elijah <elijah@riseup.net> | 2017-04-24 00:53:41 -0700 |
---|---|---|
committer | Kali Kaneko (leap communications) <kali@leap.se> | 2017-04-24 11:12:26 +0200 |
commit | 9d301349ab434dc744546918fe026d50485a0797 (patch) | |
tree | 802bec24bb446c9ed3af11f7ccfcd9793250b070 /ui/app/models | |
parent | 2976cf11e451f1086d98eae20bdfb0fffa87abb0 (diff) |
[feat] usable vpn ui
Diffstat (limited to 'ui/app/models')
-rw-r--r-- | ui/app/models/account.js | 33 |
1 files changed, 32 insertions, 1 deletions
diff --git a/ui/app/models/account.js b/ui/app/models/account.js index 1477360..34104f6 100644 --- a/ui/app/models/account.js +++ b/ui/app/models/account.js @@ -98,7 +98,12 @@ export default class Account { }) // failing that, search by domain if (!account) { - let domain = '@' + address.split('@')[1] + let domain = null + if (address.indexOf('@') == -1) { + domain = '@' + address + } else { + domain = '@' + address.split('@')[1] + } account = Account.list.find(i => { return i.address == domain }) @@ -133,6 +138,32 @@ export default class Account { ) } + static vpnReady() { + return Provider.list(false).then(domains => { + let promises = domains.map(domain => { + return new Promise((resolve, reject) => { + bitmask.vpn.check(domain).then(status => { + if (status.vpn != 'disabled' && status.installed && status.vpn_ready) { + resolve(domain) + } else { + resolve("") + } + }, error => { + resolve("") + }) + }) + }) + return Promise.all(promises).then(domains => { + domains = domains.filter(i => { + return i != "" + }) + return domains.map(domain => { + return Account.find(domain) + }) + }) + }) + } + static add(account) { if (!Account.list.find(i => {return i.id == account.id})) { Account.list.push(account) |