From 9d301349ab434dc744546918fe026d50485a0797 Mon Sep 17 00:00:00 2001 From: elijah Date: Mon, 24 Apr 2017 00:53:41 -0700 Subject: [feat] usable vpn ui --- ui/app/models/account.js | 33 ++++++++++++++++++++++++++++++++- 1 file changed, 32 insertions(+), 1 deletion(-) (limited to 'ui/app/models/account.js') 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) -- cgit v1.2.3