message: Fix bucket counts
diff: @@ -192,9 +192,9 @@ export function D2StoresService(
  itemInfoService,
  lastPlayedDate));
  - return $q.all([defs, newItems, itemInfoService, processVaultPromise, ...processStorePromises]);
  + return $q.all([defs, buckets, newItems, itemInfoService, processVaultPromise, ...processStorePromises]);
  })
  - .then(([defs, newItems, itemInfoService, ...stores]) => {
  + .then(([defs, buckets, newItems, itemInfoService, vault, ...characters]) => {
  // Save and notify about new items (but only if this wasn't the first load)
  if (!firstLoad) {
  // Save the list of new item IDs
  @@ -202,8 +202,12 @@ export function D2StoresService(
  NewItemsService.saveNewItems(newItems, account, 2);
  }
  + const stores = [...characters, vault];
  _stores = stores;
  + // TODO: update vault counts for character account-wide
  + updateVaultCounts(buckets, _.find(characters, 'current'), vault);
  +
  itemInfoService.cleanInfos(stores);
  stores.forEach((s) => updateBasePower(stores, s, defs));
  @@ -337,12 +341,15 @@ export function D2StoresService(
  // Fill in any missing buckets
  _.values(buckets.byType).forEach((bucket) => {
  if (store.buckets[bucket.id]) {
  - const vaultBucketId = bucket.accountWide ? bucket.id : bucket.vaultBucket.id;
  + // TODO: don't even update them for account-wide
  + if (!bucket.accountWide) {
  + const vaultBucketId = bucket.vaultBucket.id;
  store.d2VaultCounts[vaultBucketId] = store.d2VaultCounts[vaultBucketId] || {
  count: 0,
  bucket: bucket.accountWide ? bucket : bucket.vaultBucket
  };
  store.d2VaultCounts[vaultBucketId].count += store.buckets[bucket.id].length;
  + }
  } else {
  store.buckets[bucket.id] = [];
  }
  @@ -455,4 +462,20 @@ export function D2StoresService(
  return memo + (item.basePower * itemWeight[item.type === 'ClassItem' ? 'General' : item.location.sort]);
  }, 0)) / items.length).toFixed(1);
  }
  +
  + // TODO: vault counts are silly and convoluted. We really need an
  + // object to represent a Profile.
  + function updateVaultCounts(buckets, activeStore, vault) {
  + // Fill in any missing buckets
  + _.values(buckets.byType).forEach((bucket) => {
  + if (bucket.accountWide && bucket.vaultBucket) {
  + const vaultBucketId = bucket.id;
  + vault.d2VaultCounts[vaultBucketId] = vault.d2VaultCounts[vaultBucketId] || {
  + count: 0,
  + bucket
  + };
  + vault.d2VaultCounts[vaultBucketId].count += vault.buckets[bucket.id].length;
  + }
  + });
  + }
  }
  