fix for lbrytv: only pass account_id/wallet_id if they are passed into prefGet/prefSet

This commit is contained in:
Sean Yesmunt 2019-10-11 13:28:05 -04:00
parent f06e1e64a8
commit e048b2aff3
2 changed files with 53 additions and 24 deletions

15
dist/bundle.es.js vendored
View file

@ -2563,7 +2563,7 @@ function doUpdateChannel(params) {
updateParams.tags = params.tags.map(tag => tag.name);
}
//we'll need to remove these once we add locations/channels to channel page edit/create options
// we'll need to remove these once we add locations/channels to channel page edit/create options
if (channelClaim && channelClaim.value && channelClaim.value.locations) {
updateParams.locations = channelClaim.value.locations;
@ -3834,7 +3834,12 @@ function doPreferenceSet(key, value, version, accountId, walletId, success, fail
value
};
lbryProxy.preference_set({ key, value: JSON.stringify(preference), account_id: accountId, wallet_id: walletId }).then(() => {
const options = _extends$5({
key,
value: JSON.stringify(preference)
}, accountId ? { account_id: accountId } : {}, walletId ? { wallet_id: walletId } : {});
lbryProxy.preference_set(options).then(() => {
success(preference);
}).catch(() => {
if (fail) {
@ -3844,7 +3849,11 @@ function doPreferenceSet(key, value, version, accountId, walletId, success, fail
}
function doPreferenceGet(key, accountId, walletId, success, fail) {
lbryProxy.preference_get({ key, account_id: accountId, wallet_id: walletId }).then(result => {
const options = _extends$5({
key
}, accountId ? { account_id: accountId } : {}, walletId ? { wallet_id: walletId } : {});
lbryProxy.preference_get(options).then(result => {
if (result) {
const preference = result[key];
return success(preference);

View file

@ -39,8 +39,8 @@ export function sharedStateSubscriber(
filters: any,
version: string,
accountId: string,
walletId: string)
{
walletId: string
) {
// the shared object that will be saved
const shared = {};
@ -55,7 +55,6 @@ export function sharedStateSubscriber(
shared[key] = value;
});
if (!isEqual(oldShared, shared)) {
// only update if the preference changed from last call in the same session
oldShared = shared;
@ -73,33 +72,54 @@ export function doPreferenceSet(
fail: Function
) {
const preference = {
type: (typeof value),
type: typeof value,
version,
value,
};
Lbry.preference_set({ key, value: JSON.stringify(preference), account_id: accountId, wallet_id: walletId }).then(() => {
success(preference);
}).catch(() => {
if (fail) { fail(); }
});
const options = {
key,
value: JSON.stringify(preference),
...(accountId ? { account_id: accountId } : {}),
...(walletId ? { wallet_id: walletId } : {}),
};
Lbry.preference_set(options)
.then(() => {
success(preference);
})
.catch(() => {
if (fail) {
fail();
}
});
}
export function doPreferenceGet(
key: string,
accountId: string,
walletId: string,
accountId?: string,
walletId?: string,
success: Function,
fail: Function
fail?: Function
) {
Lbry.preference_get({ key, account_id: accountId, wallet_id: walletId }).then(result => {
if (result) {
const preference = result[key];
return success(preference);
}
const options = {
key,
...(accountId ? { account_id: accountId } : {}),
...(walletId ? { wallet_id: walletId } : {}),
};
return success(null);
}).catch(err => {
if (fail) { fail(err); }
});
Lbry.preference_get(options)
.then(result => {
if (result) {
const preference = result[key];
return success(preference);
}
return success(null);
})
.catch(err => {
if (fail) {
fail(err);
}
});
}