summaryrefslogtreecommitdiff
path: root/ui/app/models
diff options
context:
space:
mode:
authorelijah <elijah@riseup.net>2016-11-08 11:04:15 -0800
committerelijah <elijah@riseup.net>2016-11-08 11:04:15 -0800
commit395612dffea06b52153b7a6acf22ab33207c9346 (patch)
tree08015ec9fb98ecbfc0a61b593fb7484a9ba9601f /ui/app/models
parent5ba120030a7641a0404252fb7d8b05fced8ede30 (diff)
ui: allow removing accounts
Diffstat (limited to 'ui/app/models')
-rw-r--r--ui/app/models/account.js32
1 files changed, 26 insertions, 6 deletions
diff --git a/ui/app/models/account.js b/ui/app/models/account.js
index 412ee56..cb008cc 100644
--- a/ui/app/models/account.js
+++ b/ui/app/models/account.js
@@ -99,7 +99,7 @@ export default class Account {
return account
}
- static find_or_add(address) {
+ static findOrAdd(address) {
let account = Account.find(address)
if (!account) {
account = new Account(address)
@@ -129,10 +129,30 @@ export default class Account {
}
}
+ //
+ // For now, accounts are really just providers. Eventually,
+ // there will be a separate account and provider list.
+ //
+ // Returns the account in the list that is closest to the one
+ // We removed.
+ //
static remove(account) {
- Account.list = Account.list.filter(i => {
- return i.id != account.id
- })
+ return bitmask.bonafide.provider.delete(account.domain).then(
+ response => {
+ let index = Account.list.findIndex(i => {
+ return i.id == account.id
+ })
+ Account.list = Account.list.filter(i => {
+ return i.id != account.id
+ })
+ if (index >= Account.list.length) {
+ index = index - 1
+ } else if (index == -1) {
+ index = 0
+ }
+ return Account.list[index]
+ }
+ )
}
static create(address, password, invite=null) {
@@ -143,7 +163,7 @@ export default class Account {
)
}
- static initialize_list(domains) {
+ static initializeList(domains) {
for (let domain of domains) {
Account.add(new Account(domain))
}
@@ -156,7 +176,7 @@ export default class Account {
// this is a temporary hack to support the old behavior
// util the backend has a proper concept of an account list.
//
- static add_primary(account) {
+ static addPrimary(account) {
Account.list = Account.list.filter(i => {
return i.domain != account.domain
})