File tree Expand file tree Collapse file tree 3 files changed +13
-4
lines changed
Expand file tree Collapse file tree 3 files changed +13
-4
lines changed Original file line number Diff line number Diff line change 11import localforage from 'localforage' ;
2+ import { processAPIData } from '../../utils' ;
23
34const ACCOUNT_NAMESPACE = 'ACCOUNT-' ;
45
56export const fetchAccounts = ( ) => {
67 return localforage . startsWith ( ACCOUNT_NAMESPACE ) . then ( ( res ) => {
7- return res ;
8+ return processAPIData ( res ) ;
89 } ) ;
910} ;
1011
Original file line number Diff line number Diff line change @@ -24,9 +24,7 @@ export const loadAccounts = (state) => {
2424 // loads accounts only if they are not already loaded
2525 if ( ! state . accounts || Object . keys ( state . accounts ) . length === 0 ) {
2626 return fetchAccounts ( ) . then ( ( res ) => {
27- let accounts = { } ;
28- Object . keys ( res ) . forEach ( ( key ) => { accounts [ res [ key ] . id ] = res [ key ] ; } ) ;
29- state . commit ( 'LOAD_ACCOUNTS' , accounts ) ;
27+ state . commit ( 'LOAD_ACCOUNTS' , res ) ;
3028 } ) ;
3129 }
3230} ;
Original file line number Diff line number Diff line change @@ -8,3 +8,13 @@ export const guid = function () {
88 return s4 ( ) + s4 ( ) + '-' + s4 ( ) + '-' + s4 ( ) + '-' +
99 s4 ( ) + '-' + s4 ( ) + s4 ( ) + s4 ( ) ;
1010} ;
11+
12+ export const processAPIData = function ( data ) {
13+ /*
14+ Converts the data formatted for IndexedDB / API into the format
15+ our application uses.
16+ */
17+ let res = { } ;
18+ Object . keys ( data ) . forEach ( ( key ) => { res [ data [ key ] . id ] = data [ key ] ; } ) ;
19+ return res ;
20+ } ;
You can’t perform that action at this time.
0 commit comments