From 65c2c18653feb5f6485710e9656b19e368bb2826 Mon Sep 17 00:00:00 2001 From: elijah Date: Mon, 5 Sep 2016 17:34:11 -0700 Subject: [feature] webkit support: get the js and css working in older webkit engines --- www/app/models/account.js | 67 ++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 61 insertions(+), 6 deletions(-) (limited to 'www/app/models/account.js') diff --git a/www/app/models/account.js b/www/app/models/account.js index 367961bf..fa3b9813 100644 --- a/www/app/models/account.js +++ b/www/app/models/account.js @@ -8,11 +8,7 @@ import bitmask from 'lib/bitmask' export default class Account { constructor(address, props={}) { - if (!address.match('@')) { - this._address = '@' + address - } else { - this._address = address - } + this.address = address this._authenticated = props.authenticated } @@ -34,6 +30,14 @@ export default class Account { return this._address } + set address(address) { + if (!address.match('@')) { + this._address = '@' + address + } else { + this._address = address + } + } + get userpart() { return this._address.split('@')[0] } @@ -42,6 +46,10 @@ export default class Account { return this._authenticated } + get hasEmail() { + return true + } + // // returns a promise, fulfill is passed account object // @@ -70,6 +78,33 @@ export default class Account { ) } + // + // returns the matching account in the list of accounts, or adds it + // if it is not already present. + // + static find(address) { + // search by full address + let account = Account.list.find(i => { + return i.address == address + }) + // failing that, search by domain + if (!account) { + let domain = '@' + address.split('@')[1] + account = Account.list.find(i => { + return i.address == domain + }) + if (account) { + account.address = address + } + } + // failing that, create new account + if (!account) { + account = new Account(address) + Account.list.push(account) + } + return account + } + // // returns a promise, fullfill is passed account object // @@ -85,4 +120,24 @@ export default class Account { ) } -} \ No newline at end of file + static add(account) { + if (!Account.list.find(i => {return i.id == account.id})) { + Account.list.push(account) + } + } + + static remove(account) { + Account.list = Account.list.filter(i => { + return i.id != account.id + }) + } + // return Account.list + // return new Promise(function(resolve, reject) { + // window.setTimeout(function() { + // resolve(['@blah', '@lala']) + // }, 1000) + // }) + // } +} + +Account.list = [] \ No newline at end of file -- cgit v1.2.3