diff --git a/src/breezeStatus/breezeStatusReducer.js b/src/breezeStatus/breezeStatusReducer.js index 115c4c7..811504e 100644 --- a/src/breezeStatus/breezeStatusReducer.js +++ b/src/breezeStatus/breezeStatusReducer.js @@ -1,20 +1,33 @@ -import * as BreezeActions from './breezeActions' +import { STATUS_INITIALIZING, STATUS_INITIALIZED, STATUS_FAILED } from "../constants"; +import { BREEZE_INITIALIZING,BREEZE_INITIALIZED, BREEZE_FAILED } from "./breezeActions"; const initialState = { - initialized: false + status: STATUS_INITIALIZING } const breezeStatusReducer = (state = initialState, action) => { /* * Breeze Status */ - if (action.type === BreezeActions.BREEZE_INITIALIZED) { - return { - ...state, - initialized: true - } + switch (action.type) { + case BREEZE_INITIALIZING: + return { + ...state, + status: STATUS_INITIALIZING + }; + case BREEZE_INITIALIZED: + return { + ...state, + status: STATUS_INITIALIZED + }; + case BREEZE_FAILED: + return { + ...state, + status: STATUS_FAILED + }; + default: + return state; } - return state } export default breezeStatusReducer diff --git a/src/constants.js b/src/constants.js new file mode 100644 index 0000000..922ed3a --- /dev/null +++ b/src/constants.js @@ -0,0 +1,4 @@ +// Status +export const STATUS_INITIALIZING = 'initializing'; +export const STATUS_INITIALIZED = 'initialized'; +export const STATUS_FAILED = 'failed'; diff --git a/src/index.js b/src/index.js index ed25c60..e7ce926 100644 --- a/src/index.js +++ b/src/index.js @@ -9,7 +9,9 @@ import orbitSaga from "./orbit/orbitSaga"; import * as BreezeActions from './breezeStatus/breezeActions' import * as OrbitActions from './orbit/orbitActions' -import * as orbitTypes from './orbit/constants' +import * as breezeConstants from './constants' + +import * as orbitTypes from './orbit/orbitConstants' import orbitMiddleware from "./orbit/orbitMiddleware"; import orbitStatusSaga from "./orbit/orbitStatusSaga"; @@ -36,6 +38,7 @@ const breezeActions = { export { Breeze, + breezeConstants, breezeActions, breezeReducers, breezeMiddlewares, diff --git a/src/ipfs/ipfsReducer.js b/src/ipfs/ipfsReducer.js index fb60ef7..6357f02 100644 --- a/src/ipfs/ipfsReducer.js +++ b/src/ipfs/ipfsReducer.js @@ -1,20 +1,29 @@ -import {IPFS_FAILED, IPFS_INITIALIZED} from "./ipfsActions"; +import { IPFS_INITIALIZING , IPFS_INITIALIZED, IPFS_FAILED } from "./ipfsActions"; +import { STATUS_INITIALIZING, STATUS_INITIALIZED, STATUS_FAILED } from "../constants"; const initialState = { - initialized: false + status: STATUS_INITIALIZING }; const ipfsReducer = (state = initialState, action) => { + /* + * IPFS Status + */ switch (action.type) { + case IPFS_INITIALIZING: + return { + ...state, + status: STATUS_INITIALIZING + }; case IPFS_INITIALIZED: return { ...state, - initialized: true + status: STATUS_INITIALIZED }; case IPFS_FAILED: return { ...state, - failed: true + status: STATUS_FAILED }; default: return state; diff --git a/src/orbit/orbitActions.js b/src/orbit/orbitActions.js index 3670a2f..3253f44 100644 --- a/src/orbit/orbitActions.js +++ b/src/orbit/orbitActions.js @@ -1,9 +1,14 @@ +// OrbitDB Status export const ORBIT_INITIALIZING = 'ORBIT_INITIALIZING'; export const ORBIT_INITIALIZED = 'ORBIT_INITIALIZED'; export const ORBIT_INIT_FAILED = 'ORBIT_INIT_FAILED'; + +// Identity Provider Status export const ORBIT_IDENTITY_PROVIDER_ADD = 'ORBIT_IDENTITY_PROVIDER_ADD'; export const ORBIT_IDENTITY_PROVIDER_ADDED = 'ORBIT_IDENTITY_PROVIDER_ADDED'; export const ORBIT_IDENTITY_PROVIDER_FAILED = 'ORBIT_IDENTITY_PROVIDER_FAILED'; + +// Database Status export const ORBIT_DATABASE_CREATING = 'ORBIT_DATABASE_CREATING'; export const ORBIT_DATABASE_CREATED = 'ORBIT_DATABASE_CREATED'; export const ORBIT_DATABASE_FAILED = 'ORBIT_DATABASE_FAILED'; diff --git a/src/orbit/constants.js b/src/orbit/orbitConstants.js similarity index 93% rename from src/orbit/constants.js rename to src/orbit/orbitConstants.js index 491f122..ed4d027 100644 --- a/src/orbit/constants.js +++ b/src/orbit/orbitConstants.js @@ -5,7 +5,7 @@ export const ORBIT_TYPE_KEYVALUE = 'keyvalue'; export const ORBIT_TYPE_DOCS = 'docs'; export const ORBIT_TYPE_COUNTER = 'counter'; -// OrbitDB statuses +// OrbitDB Databases status export const DB_STATUS_INIT = 'init'; export const DB_STATUS_READY = 'ready'; export const DB_STATUS_REPLICATING = 'replicating'; diff --git a/src/orbit/orbitReducer.js b/src/orbit/orbitReducer.js index caef94d..61eb08f 100644 --- a/src/orbit/orbitReducer.js +++ b/src/orbit/orbitReducer.js @@ -3,32 +3,41 @@ import { ORBIT_DATABASE_READY, ORBIT_DATABASE_REPLICATED, ORBIT_DATABASE_REPLICATING, - ORBIT_INIT_FAILED, - ORBIT_INITIALIZED + ORBIT_INITIALIZING, + ORBIT_INITIALIZED, + ORBIT_INIT_FAILED } from "./orbitActions"; + import { DB_STATUS_INIT, DB_STATUS_READY, DB_STATUS_REPLICATED, - DB_STATUS_REPLICATING -} from "./constants"; + DB_STATUS_REPLICATING, +} from "./orbitConstants"; + +import {STATUS_INITIALIZING, STATUS_INITIALIZED, STATUS_FAILED } from "../constants"; const initialState = { - initialized: false, + status: STATUS_INITIALIZING, databases: {} }; const orbitReducer = (state = initialState, action) => { switch (action.type) { + case ORBIT_INITIALIZING: + return { + ...state, + status: STATUS_INITIALIZING + }; case ORBIT_INITIALIZED: return { ...state, - initialized: true, + status: STATUS_INITIALIZED }; case ORBIT_INIT_FAILED: return { ...state, - failed: true, + status: STATUS_FAILED }; case ORBIT_DATABASE_CREATED: return newDatabasesStatus(state, action, DB_STATUS_INIT); diff --git a/src/orbit/orbitUtils.js b/src/orbit/orbitUtils.js index a0fe2df..13cc9ef 100644 --- a/src/orbit/orbitUtils.js +++ b/src/orbit/orbitUtils.js @@ -1,4 +1,4 @@ -import * as orbitTypes from "./constants"; +import * as orbitTypes from "./orbitConstants"; export function resolveOrbitDBTypeFun(orbitdb, type){ let dbTypeFun;