Changes needed for additional youtube transfer UI #62

Merged
neb-b merged 4 commits from onboarding into master 2019-10-07 04:40:02 +02:00
3 changed files with 63 additions and 67 deletions
Showing only changes of commit d1dba98bb6 - Show all commits

44
dist/bundle.es.js vendored
View file

@ -2375,34 +2375,18 @@ function doSetDefaultAccount(success, failure) {
}); });
}; };
} }
function doSetSync(oldHash, newHash, data, password) { function doSetSync(oldHash, newHash, data) {
return dispatch => { return dispatch => {
dispatch({ dispatch({
type: SET_SYNC_STARTED type: SET_SYNC_STARTED
}); });
Lbryio.call('sync', 'set', { return Lbryio.call('sync', 'set', {
old_hash: oldHash, old_hash: oldHash,
new_hash: newHash, new_hash: newHash,
data data
}, 'post').then(response => { }, 'post').then(response => {
if (!response.hash) { if (!response.hash) {
return dispatch({ throw Error('No hash returned for sync/set.');
type: SET_SYNC_FAILED,
data: {
error: 'No hash returned for sync/set.'
}
});
}
if (oldHash && newHash !== oldHash) {
dispatch(doSetDefaultAccount(() => {
if (password !== undefined) {
lbryRedux.Lbry.account_unlock({
password
});
dispatch(lbryRedux.doFetchChannelListMine());
}
}));
} }
return dispatch({ return dispatch({
@ -2421,7 +2405,7 @@ function doSetSync(oldHash, newHash, data, password) {
}); });
}; };
} }
function doGetSync(password = '') { function doGetSync(password = '', shouldSetDefaultAccount) {
return dispatch => { return dispatch => {
dispatch({ dispatch({
type: GET_SYNC_STARTED type: GET_SYNC_STARTED
@ -2436,7 +2420,7 @@ function doGetSync(password = '') {
data.syncData = response.data; data.syncData = response.data;
data.hasSyncedWallet = true; data.hasSyncedWallet = true;
if (response.changed) { if (response.changed || shouldSetDefaultAccount) {
return lbryRedux.Lbry.sync_apply({ return lbryRedux.Lbry.sync_apply({
password, password,
data: response.data data: response.data
@ -2449,9 +2433,23 @@ function doGetSync(password = '') {
data data
}); });
if (walletHash !== syncHash) { if (walletHash !== syncHash || shouldSetDefaultAccount) {
// different local hash, need to synchronise // different local hash, need to synchronise
dispatch(doSetSync(syncHash, walletHash, walletData, password)); dispatch(doSetSync(syncHash, walletHash, walletData));
if (shouldSetDefaultAccount) {
dispatch(doSetDefaultAccount(() => {
lbryRedux.Lbry.status().then(status => {
if (status.wallet.is_locked) {
lbryRedux.Lbry.account_unlock({
password
});
}
dispatch(lbryRedux.doFetchChannelListMine());
});
}));
}
} }
}); });
} }

43
dist/bundle.js vendored
View file

@ -3938,34 +3938,18 @@ function doSetDefaultAccount(success, failure) {
}); });
}; };
} }
function doSetSync(oldHash, newHash, data, password) { function doSetSync(oldHash, newHash, data) {
return function (dispatch) { return function (dispatch) {
dispatch({ dispatch({
type: constants_action_types__WEBPACK_IMPORTED_MODULE_0__["SET_SYNC_STARTED"] type: constants_action_types__WEBPACK_IMPORTED_MODULE_0__["SET_SYNC_STARTED"]
}); });
lbryio__WEBPACK_IMPORTED_MODULE_1__["default"].call('sync', 'set', { return lbryio__WEBPACK_IMPORTED_MODULE_1__["default"].call('sync', 'set', {
old_hash: oldHash, old_hash: oldHash,
new_hash: newHash, new_hash: newHash,
data: data data: data
}, 'post').then(function (response) { }, 'post').then(function (response) {
if (!response.hash) { if (!response.hash) {
return dispatch({ throw Error('No hash returned for sync/set.');
type: constants_action_types__WEBPACK_IMPORTED_MODULE_0__["SET_SYNC_FAILED"],
data: {
error: 'No hash returned for sync/set.'
}
});
}
if (oldHash && newHash !== oldHash) {
dispatch(doSetDefaultAccount(function () {
if (password !== undefined) {
lbry_redux__WEBPACK_IMPORTED_MODULE_2__["Lbry"].account_unlock({
password: password
});
dispatch(Object(lbry_redux__WEBPACK_IMPORTED_MODULE_2__["doFetchChannelListMine"])());
}
}));
} }
return dispatch({ return dispatch({
@ -3986,6 +3970,7 @@ function doSetSync(oldHash, newHash, data, password) {
} }
function doGetSync() { function doGetSync() {
var password = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : ''; var password = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
var shouldSetDefaultAccount = arguments.length > 1 ? arguments[1] : undefined;
return function (dispatch) { return function (dispatch) {
dispatch({ dispatch({
type: constants_action_types__WEBPACK_IMPORTED_MODULE_0__["GET_SYNC_STARTED"] type: constants_action_types__WEBPACK_IMPORTED_MODULE_0__["GET_SYNC_STARTED"]
@ -4000,7 +3985,7 @@ function doGetSync() {
data.syncData = response.data; data.syncData = response.data;
data.hasSyncedWallet = true; data.hasSyncedWallet = true;
if (response.changed) { if (response.changed || shouldSetDefaultAccount) {
return lbry_redux__WEBPACK_IMPORTED_MODULE_2__["Lbry"].sync_apply({ return lbry_redux__WEBPACK_IMPORTED_MODULE_2__["Lbry"].sync_apply({
password: password, password: password,
data: response.data data: response.data
@ -4012,9 +3997,23 @@ function doGetSync() {
data: data data: data
}); });
if (walletHash !== syncHash) { if (walletHash !== syncHash || shouldSetDefaultAccount) {
// different local hash, need to synchronise // different local hash, need to synchronise
dispatch(doSetSync(syncHash, walletHash, walletData, password)); dispatch(doSetSync(syncHash, walletHash, walletData));
if (shouldSetDefaultAccount) {
dispatch(doSetDefaultAccount(function () {
lbry_redux__WEBPACK_IMPORTED_MODULE_2__["Lbry"].status().then(function (status) {
if (status.wallet.is_locked) {
lbry_redux__WEBPACK_IMPORTED_MODULE_2__["Lbry"].account_unlock({
password: password
});
}
dispatch(Object(lbry_redux__WEBPACK_IMPORTED_MODULE_2__["doFetchChannelListMine"])());
});
}));
}
} }
}); });
} }

View file

@ -51,30 +51,16 @@ export function doSetDefaultAccount(success, failure) {
}; };
} }
export function doSetSync(oldHash, newHash, data, password) { export function doSetSync(oldHash, newHash, data) {
return dispatch => { return dispatch => {
dispatch({ dispatch({
type: ACTIONS.SET_SYNC_STARTED, type: ACTIONS.SET_SYNC_STARTED,
}); });
Lbryio.call('sync', 'set', { old_hash: oldHash, new_hash: newHash, data }, 'post') return Lbryio.call('sync', 'set', { old_hash: oldHash, new_hash: newHash, data }, 'post')
.then(response => { .then(response => {
if (!response.hash) { if (!response.hash) {
return dispatch({ throw Error('No hash returned for sync/set.');
type: ACTIONS.SET_SYNC_FAILED,
data: { error: 'No hash returned for sync/set.' },
});
}
if (oldHash && newHash !== oldHash) {
dispatch(
doSetDefaultAccount(() => {
if (password !== undefined) {
Lbry.account_unlock({ password });
dispatch(doFetchChannelListMine());
}
})
);
} }
return dispatch({ return dispatch({
@ -91,7 +77,7 @@ export function doSetSync(oldHash, newHash, data, password) {
}; };
} }
export function doGetSync(password = '') { export function doGetSync(password = '', shouldSetDefaultAccount) {
return dispatch => { return dispatch => {
dispatch({ dispatch({
type: ACTIONS.GET_SYNC_STARTED, type: ACTIONS.GET_SYNC_STARTED,
@ -105,19 +91,32 @@ export function doGetSync(password = '') {
data.syncHash = syncHash; data.syncHash = syncHash;
data.syncData = response.data; data.syncData = response.data;
data.hasSyncedWallet = true; data.hasSyncedWallet = true;
if (response.changed || shouldSetDefaultAccount) {
if (response.changed) {
return Lbry.sync_apply({ password, data: response.data }).then( return Lbry.sync_apply({ password, data: response.data }).then(
({ hash: walletHash, data: walletData }) => { ({ hash: walletHash, data: walletData }) => {
dispatch({ type: ACTIONS.GET_SYNC_COMPLETED, data }); dispatch({ type: ACTIONS.GET_SYNC_COMPLETED, data });
if (walletHash !== syncHash) { if (walletHash !== syncHash || shouldSetDefaultAccount) {
// different local hash, need to synchronise // different local hash, need to synchronise
dispatch(doSetSync(syncHash, walletHash, walletData, password)); dispatch(doSetSync(syncHash, walletHash, walletData));
if (shouldSetDefaultAccount) {
dispatch(
doSetDefaultAccount(() => {
Lbry.status().then(status => {
if (status.wallet.is_locked) {
Lbry.account_unlock({ password });
}
dispatch(doFetchChannelListMine());
});
})
);
}
} }
} }
); );
} }
dispatch({ type: ACTIONS.GET_SYNC_COMPLETED, data }); dispatch({ type: ACTIONS.GET_SYNC_COMPLETED, data });
}) })
.catch(() => { .catch(() => {