This commit is contained in:
Sean Yesmunt 2019-10-16 19:28:02 -04:00
parent 6e1daf43d0
commit 0d32654e2e
3 changed files with 53 additions and 2 deletions

27
dist/bundle.es.js vendored
View file

@ -2472,7 +2472,9 @@ function doGetSync(passedPassword, callback) {
data
});
handleCallback();
}).catch(() => {
}).catch(err => {
console.log('error', err);
if (data.hasSyncedWallet) {
const error = 'Error getting synced wallet';
dispatch({
@ -2578,6 +2580,28 @@ function doResetSync() {
resolve();
});
}
function changeSyncPassword(oldPassword, newPassword) {
return dispatch => {
let data = {};
return lbryRedux.Lbry.sync_hash().then(hash => {
return Lbryio.call('sync', 'get', {
hash
}, 'post');
}).then(syncGetResponse => {
data.oldHash = syncGetResponse.hash;
return lbryRedux.Lbry.sync_apply({
password: oldPassword,
data: syncGetResponse.data
});
}).then(() => lbryRedux.Lbry.sync_apply({
password: newPassword
})).then(syncApplyResponse => {
if (syncApplyResponse.hash !== data.oldHash) {
return dispatch(doSetSync(data.oldHash, syncApplyResponse.hash, syncApplyResponse.data));
}
}).catch(console.error);
};
}
const reducers = {};
const defaultState$1 = {
@ -3245,6 +3269,7 @@ exports.Lbryio = Lbryio;
exports.YOUTUBE_STATUSES = youtube;
exports.authReducer = authReducer;
exports.blacklistReducer = blacklistReducer;
exports.changeSyncPassword = changeSyncPassword;
exports.costInfoReducer = costInfoReducer;
exports.doAuthenticate = doAuthenticate;
exports.doBlackListedOutpointsSubscribe = doBlackListedOutpointsSubscribe;

View file

@ -73,6 +73,7 @@ export {
doSetDefaultAccount,
doSyncApply,
doResetSync,
changeSyncPassword,
} from 'redux/actions/sync';
// reducers

View file

@ -123,6 +123,7 @@ export function doGetSync(passedPassword, callback) {
}
const { hash: walletHash, data: walletData } = response;
if (walletHash !== data.syncHash) {
// different local hash, need to synchronise
dispatch(doSetSync(data.syncHash, walletHash, walletData));
@ -131,7 +132,8 @@ export function doGetSync(passedPassword, callback) {
dispatch({ type: ACTIONS.GET_SYNC_COMPLETED, data });
handleCallback();
})
.catch(() => {
.catch(err => {
console.log('error', err);
if (data.hasSyncedWallet) {
const error = 'Error getting synced wallet';
dispatch({
@ -228,3 +230,26 @@ export function doResetSync() {
resolve();
});
}
export function changeSyncPassword(oldPassword, newPassword) {
return dispatch => {
let data = {};
return Lbry.sync_hash()
.then(hash => {
return Lbryio.call('sync', 'get', { hash }, 'post');
})
.then(syncGetResponse => {
data.oldHash = syncGetResponse.hash;
return Lbry.sync_apply({ password: oldPassword, data: syncGetResponse.data });
})
.then(() => Lbry.sync_apply({ password: newPassword }))
.then(syncApplyResponse => {
if (syncApplyResponse.hash !== data.oldHash) {
return dispatch(doSetSync(data.oldHash, syncApplyResponse.hash, syncApplyResponse.data));
}
})
.catch(console.error);
};
}