From bd917c6293ccfc263256f1f64e0ced4acb0c4093 Mon Sep 17 00:00:00 2001 From: Apostolof Date: Fri, 8 Mar 2019 21:11:49 +0200 Subject: [PATCH] Fixes for transactionsSaga --- app/src/orbit.js | 4 ++-- app/src/redux/sagas/transactionsSaga.js | 13 ++++++------- 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/app/src/orbit.js b/app/src/orbit.js index 41e81a3..78c75dc 100644 --- a/app/src/orbit.js +++ b/app/src/orbit.js @@ -59,8 +59,8 @@ async function loadDatabases(identityId, identityPublicKey, identityPrivateKey, topicsDB = await orbitdb.keyvalue('/orbitdb/' + topicsDB +'/topics'); postsDB = await orbitdb.keyvalue('/orbitdb/' + postsDB +'/posts'); - topicsDB.load(); - postsDB.load(); + await topicsDB.load(); + await postsDB.load(); store.dispatch({ type: "DATABASES_LOADED", diff --git a/app/src/redux/sagas/transactionsSaga.js b/app/src/redux/sagas/transactionsSaga.js index 499b55f..4f2e3c0 100644 --- a/app/src/redux/sagas/transactionsSaga.js +++ b/app/src/redux/sagas/transactionsSaga.js @@ -10,6 +10,7 @@ function* initTransaction(action) { .cacheSend(...[action.transactionDescriptor.params]); transactionsHistory[dataKey] = action; + transactionsHistory[dataKey].state = 'initialized'; } function* handleEvent(action) { @@ -23,13 +24,11 @@ function* handleEvent(action) { //Gets orbit const orbit = yield select((state) => state.orbit); //And saves the topic - /*yield call(orbit.topicsDB.put, ...[action.event.returnValues.topicID, { - subject: transactionsHistory[dataKey].userInputs.topicSubject - }]); - yield call(orbit.postsDB.put, ...[action.event.returnValues.postID, { - subject: transactionsHistory[dataKey].userInputs.topicSubject, - content: transactionsHistory[dataKey].userInputs.topicMessage - }]);*/ + yield call([orbit.topicsDB, 'put'], [action.event.returnValues.topicID, + { subject: transactionsHistory[dataKey].userInputs.topicSubject }]); + yield call([orbit.postsDB, 'put'], [action.event.returnValues.postID, + {subject: transactionsHistory[dataKey].userInputs.topicSubject, + content: transactionsHistory[dataKey].userInputs.topicMessage }]); transactionsHistory[dataKey].state = 'success'; }