diff --git a/src/component/AppNavigator.js b/src/component/AppNavigator.js index a5fb642..2d68083 100644 --- a/src/component/AppNavigator.js +++ b/src/component/AppNavigator.js @@ -29,7 +29,7 @@ import { import { connect } from 'react-redux'; import { AppState, BackHandler, Linking, NativeModules, TextInput, ToastAndroid } from 'react-native'; import { selectDrawerStack } from 'redux/selectors/drawer'; -import { SETTINGS, doDismissToast, doPopulateSharedUserState, doToast, selectToast } from 'lbry-redux'; +import { SETTINGS, doDismissToast, doPopulateSharedUserState, doPreferenceGet, doToast, selectToast } from 'lbry-redux'; import { Lbryio, doGetSync, @@ -308,8 +308,8 @@ class AppWithNavigationState extends React.Component { getUserSettings = () => { const { dispatch } = this.props; - Lbryio.call('user_settings', 'get').then(settings => { - dispatch(doPopulateSharedUserState(settings)); + doPreferenceGet('shared', null, null, preference => { + dispatch(doPopulateSharedUserState(preference)); }); }; diff --git a/src/index.js b/src/index.js index 252f85c..cea3631 100644 --- a/src/index.js +++ b/src/index.js @@ -148,7 +148,11 @@ const persistor = persistStore(store, persistOptions, err => { }); window.persistor = persistor; -const sharedStateCache = {}; +/** + * source: the reducer name + * property: the property in the reducer-specific state + * transform: optional method to modify the value to be stored + */ const sharedStateFilters = { tags: { source: 'tags', property: 'followedTags' }, subscriptions: { @@ -163,7 +167,7 @@ const sharedStateFilters = { store.subscribe(() => { try { const state = store.getState(); - sharedStateSubscriber(state, sharedStateFilters, sharedStateCache); + sharedStateSubscriber(state, sharedStateFilters, '0.1'); } catch (e) { // handle gracefully? } diff --git a/src/page/splash/view.js b/src/page/splash/view.js index 2a2a5c6..3eecfdc 100644 --- a/src/page/splash/view.js +++ b/src/page/splash/view.js @@ -1,5 +1,5 @@ import React from 'react'; -import { Lbry } from 'lbry-redux'; +import { Lbry, doPreferenceGet } from 'lbry-redux'; import { Lbryio } from 'lbryinc'; import { ActivityIndicator, Linking, NativeModules, Platform, Text, View } from 'react-native'; import { NavigationActions, StackActions } from 'react-navigation'; @@ -113,8 +113,9 @@ class SplashScreen extends React.PureComponent { getUserSettings = () => { const { populateSharedUserState } = this.props; - Lbryio.call('user_settings', 'get').then(settings => { - populateSharedUserState(settings); + + doPreferenceGet('shared', null, null, preference => { + populateSharedUserState(preference); }); };