mirror of
https://github.com/usebruno/bruno.git
synced 2024-12-25 08:09:17 +01:00
20 lines
522 B
JavaScript
20 lines
522 B
JavaScript
import { useEffect } from 'react';
|
|
import { getCollectionsFromIdb } from './idb';
|
|
import actions from './actions';
|
|
|
|
const useLoadCollectionsFromIdb = (idbConnection, dispatch) => {
|
|
useEffect(() => {
|
|
if(idbConnection) {
|
|
getCollectionsFromIdb(idbConnection)
|
|
.then((collections) => {
|
|
dispatch({
|
|
type: actions.LOAD_COLLECTIONS_FROM_IDB,
|
|
collections: collections
|
|
});
|
|
})
|
|
.catch((err) => console.log(err));
|
|
}
|
|
}, [idbConnection, dispatch]);
|
|
};
|
|
|
|
export default useLoadCollectionsFromIdb; |