This commit is contained in:
Akinwale Ariwodola 2019-04-11 09:00:43 -04:00
parent db463188a8
commit 79b42d6a9b
3 changed files with 20 additions and 8 deletions

10
dist/bundle.js vendored
View file

@ -9632,7 +9632,9 @@ function doSetSync(oldHash, newHash, data) {
type: ACTIONS.SET_SYNC_STARTED type: ACTIONS.SET_SYNC_STARTED
}); });
console.log('/sync/set with old_hash: ' + oldHash + ', new_hash: ' + newHash + ', data: ' + data);
_lbryio2.default.call('sync', 'set', { old_hash: oldHash, new_hash: newHash, data: data }, 'post').then(function (response) { _lbryio2.default.call('sync', 'set', { old_hash: oldHash, new_hash: newHash, data: data }, 'post').then(function (response) {
console.log(response);
if (!response.success) { if (!response.success) {
return dispatch({ return dispatch({
type: ACTIONS.SET_SYNC_FAILED, type: ACTIONS.SET_SYNC_FAILED,
@ -9645,7 +9647,8 @@ function doSetSync(oldHash, newHash, data) {
data: { syncHash: response.hash } data: { syncHash: response.hash }
}); });
}).catch(function (error) { }).catch(function (error) {
return dispatch({ console.log(error);
dispatch({
type: ACTIONS.SET_SYNC_FAILED, type: ACTIONS.SET_SYNC_FAILED,
data: { error: error } data: { error: error }
}); });
@ -9660,7 +9663,9 @@ function doGetSync(password) {
}); });
_lbryRedux.Lbry.sync_hash().then(function (hash) { _lbryRedux.Lbry.sync_hash().then(function (hash) {
console.log('/sync/get with hash: ' + hash + ', password: ' + password);
_lbryio2.default.call('sync', 'get', { hash: hash }, 'post').then(function (response) { _lbryio2.default.call('sync', 'get', { hash: hash }, 'post').then(function (response) {
console.log(response);
var data = { hasWallet: true }; var data = { hasWallet: true };
if (response.changed) { if (response.changed) {
var syncHash = response.hash; var syncHash = response.hash;
@ -9677,7 +9682,8 @@ function doGetSync(password) {
} }
dispatch({ type: ACTIONS.GET_SYNC_COMPLETED, data: data }); dispatch({ type: ACTIONS.GET_SYNC_COMPLETED, data: data });
}).catch(function () { }).catch(function (err) {
console.log(err);
// user doesn't have a synced wallet // user doesn't have a synced wallet
dispatch({ dispatch({
type: ACTIONS.GET_SYNC_COMPLETED, type: ACTIONS.GET_SYNC_COMPLETED,

View file

@ -32,7 +32,7 @@
"reselect": "^3.0.0" "reselect": "^3.0.0"
}, },
"peerDependencies": { "peerDependencies": {
"lbry-redux": "lbryio/lbry-redux" "lbry-redux": "lbryio/lbry-redux#sync"
}, },
"devDependencies": { "devDependencies": {
"babel-core": "^6.26.0", "babel-core": "^6.26.0",

View file

@ -8,8 +8,10 @@ export function doSetSync(oldHash, newHash, data) {
type: ACTIONS.SET_SYNC_STARTED, type: ACTIONS.SET_SYNC_STARTED,
}); });
console.log(`/sync/set with old_hash: ${oldHash}, new_hash: ${newHash}, data: ${data}`);
Lbryio.call('sync', 'set', { old_hash: oldHash, new_hash: newHash, data }, 'post') Lbryio.call('sync', 'set', { old_hash: oldHash, new_hash: newHash, data }, 'post')
.then(response => { .then(response => {
console.log(response);
if (!response.success) { if (!response.success) {
return dispatch({ return dispatch({
type: ACTIONS.SET_SYNC_FAILED, type: ACTIONS.SET_SYNC_FAILED,
@ -22,12 +24,13 @@ export function doSetSync(oldHash, newHash, data) {
data: { syncHash: response.hash }, data: { syncHash: response.hash },
}); });
}) })
.catch(error => .catch(error => {
console.log(error);
dispatch({ dispatch({
type: ACTIONS.SET_SYNC_FAILED, type: ACTIONS.SET_SYNC_FAILED,
data: { error }, data: { error },
}) });
); });
}; };
} }
@ -38,8 +41,10 @@ export function doGetSync(password) {
}); });
Lbry.sync_hash().then(hash => { Lbry.sync_hash().then(hash => {
console.log(`/sync/get with hash: ${hash}, password: ${password}`);
Lbryio.call('sync', 'get', { hash }, 'post') Lbryio.call('sync', 'get', { hash }, 'post')
.then(response => { .then(response => {
console.log(response);
const data = { hasWallet: true }; const data = { hasWallet: true };
if (response.changed) { if (response.changed) {
const syncHash = response.hash; const syncHash = response.hash;
@ -56,7 +61,8 @@ export function doGetSync(password) {
dispatch({ type: ACTIONS.GET_SYNC_COMPLETED, data }); dispatch({ type: ACTIONS.GET_SYNC_COMPLETED, data });
}) })
.catch(() => { .catch(err => {
console.log(err);
// user doesn't have a synced wallet // user doesn't have a synced wallet
dispatch({ dispatch({
type: ACTIONS.GET_SYNC_COMPLETED, type: ACTIONS.GET_SYNC_COMPLETED,
@ -66,7 +72,7 @@ export function doGetSync(password) {
// call sync_apply to get data to sync // call sync_apply to get data to sync
// first time sync. use any string for old hash // first time sync. use any string for old hash
Lbry.sync_apply({ password }).then(({ hash: walletHash, data }) => Lbry.sync_apply({ password }).then(({ hash: walletHash, data }) =>
dispatch(doSetSync('null', walletHash, data)) dispatch(doSetSync(null, walletHash, data))
); );
}); });
}); });