This commit is contained in:
Sean Yesmunt 2020-02-25 15:54:56 -05:00
parent 6f9ee589a7
commit 495ba1e74b
2 changed files with 54 additions and 8 deletions

31
dist/bundle.es.js vendored
View file

@ -1614,7 +1614,14 @@ var _extends$2 = Object.assign || function (target) { for (var i = 1; i < argume
function extractUserState(rawObj) { function extractUserState(rawObj) {
if (rawObj && rawObj.version === '0.1' && rawObj.value) { if (rawObj && rawObj.version === '0.1' && rawObj.value) {
const { subscriptions, tags, blocked, settings, app_welcome_version, sharing_3P } = rawObj.value; const {
subscriptions,
tags,
blocked,
settings,
app_welcome_version,
sharing_3P
} = rawObj.value;
return _extends$2({}, subscriptions ? { subscriptions } : {}, tags ? { tags } : {}, blocked ? { blocked } : {}, settings ? { settings } : {}, app_welcome_version ? { app_welcome_version } : {}, sharing_3P ? { sharing_3P } : {}); return _extends$2({}, subscriptions ? { subscriptions } : {}, tags ? { tags } : {}, blocked ? { blocked } : {}, settings ? { settings } : {}, app_welcome_version ? { app_welcome_version } : {}, sharing_3P ? { sharing_3P } : {});
} }
@ -1624,10 +1631,24 @@ function extractUserState(rawObj) {
function doPopulateSharedUserState(sharedSettings) { function doPopulateSharedUserState(sharedSettings) {
return dispatch => { return dispatch => {
const { subscriptions, tags, blocked, settings, app_welcome_version, sharing_3P } = extractUserState(sharedSettings); const {
subscriptions,
tags,
blocked,
settings,
app_welcome_version,
sharing_3P
} = extractUserState(sharedSettings);
dispatch({ dispatch({
type: USER_STATE_POPULATE, type: USER_STATE_POPULATE,
data: { subscriptions, tags, blocked, settings, welcomeVersion: app_welcome_version, allowAnalytics: sharing_3P } data: {
subscriptions,
tags,
blocked,
settings,
welcomeVersion: app_welcome_version,
allowAnalytics: sharing_3P
}
}); });
}; };
} }
@ -1660,12 +1681,14 @@ function doPreferenceGet(key, success, fail) {
lbryProxy.preference_get(options).then(result => { lbryProxy.preference_get(options).then(result => {
if (result) { if (result) {
console.log('result', result);
const preference = result[key]; const preference = result[key];
return success(preference); return success(preference);
} }
return success(null); return success(null);
}).catch(err => { }).catch(err => {
console.log('error', err);
if (fail) { if (fail) {
fail(err); fail(err);
} }
@ -1687,7 +1710,7 @@ const buildSharedStateMiddleware = (actions, sharedStateFilters, sharedStateCb)
} }
const actionResult = next(action); const actionResult = next(action);
// Call `getState` after calling `next` tqo ensure the state has updated in response to the action // Call `getState` after calling `next` to ensure the state has updated in response to the action
const nextState = getState(); const nextState = getState();
const shared = {}; const shared = {};

View file

@ -16,7 +16,14 @@ type SharedData = {
function extractUserState(rawObj: SharedData) { function extractUserState(rawObj: SharedData) {
if (rawObj && rawObj.version === '0.1' && rawObj.value) { if (rawObj && rawObj.version === '0.1' && rawObj.value) {
const { subscriptions, tags, blocked, settings, app_welcome_version, sharing_3P } = rawObj.value; const {
subscriptions,
tags,
blocked,
settings,
app_welcome_version,
sharing_3P,
} = rawObj.value;
return { return {
...(subscriptions ? { subscriptions } : {}), ...(subscriptions ? { subscriptions } : {}),
@ -24,7 +31,7 @@ function extractUserState(rawObj: SharedData) {
...(blocked ? { blocked } : {}), ...(blocked ? { blocked } : {}),
...(settings ? { settings } : {}), ...(settings ? { settings } : {}),
...(app_welcome_version ? { app_welcome_version } : {}), ...(app_welcome_version ? { app_welcome_version } : {}),
...(sharing_3P ? { sharing_3P} : {}), ...(sharing_3P ? { sharing_3P } : {}),
}; };
} }
@ -33,10 +40,24 @@ function extractUserState(rawObj: SharedData) {
export function doPopulateSharedUserState(sharedSettings: any) { export function doPopulateSharedUserState(sharedSettings: any) {
return (dispatch: Dispatch) => { return (dispatch: Dispatch) => {
const { subscriptions, tags, blocked, settings, app_welcome_version, sharing_3P } = extractUserState(sharedSettings); const {
subscriptions,
tags,
blocked,
settings,
app_welcome_version,
sharing_3P,
} = extractUserState(sharedSettings);
dispatch({ dispatch({
type: ACTIONS.USER_STATE_POPULATE, type: ACTIONS.USER_STATE_POPULATE,
data: { subscriptions, tags, blocked, settings, welcomeVersion: app_welcome_version, allowAnalytics: sharing_3P }, data: {
subscriptions,
tags,
blocked,
settings,
welcomeVersion: app_welcome_version,
allowAnalytics: sharing_3P,
},
}); });
}; };
} }
@ -78,6 +99,7 @@ export function doPreferenceGet(key: string, success: Function, fail?: Function)
Lbry.preference_get(options) Lbry.preference_get(options)
.then(result => { .then(result => {
if (result) { if (result) {
console.log('result', result);
const preference = result[key]; const preference = result[key];
return success(preference); return success(preference);
} }
@ -85,6 +107,7 @@ export function doPreferenceGet(key: string, success: Function, fail?: Function)
return success(null); return success(null);
}) })
.catch(err => { .catch(err => {
console.log('error', err);
if (fail) { if (fail) {
fail(err); fail(err);
} }