Preferences #56
3 changed files with 13 additions and 8 deletions
|
@ -29,7 +29,7 @@ import {
|
||||||
import { connect } from 'react-redux';
|
import { connect } from 'react-redux';
|
||||||
|
|||||||
import { AppState, BackHandler, Linking, NativeModules, TextInput, ToastAndroid } from 'react-native';
|
import { AppState, BackHandler, Linking, NativeModules, TextInput, ToastAndroid } from 'react-native';
|
||||||
import { selectDrawerStack } from 'redux/selectors/drawer';
|
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 {
|
import {
|
||||||
Lbryio,
|
Lbryio,
|
||||||
doGetSync,
|
doGetSync,
|
||||||
|
@ -308,8 +308,8 @@ class AppWithNavigationState extends React.Component {
|
||||||
|
|
||||||
getUserSettings = () => {
|
getUserSettings = () => {
|
||||||
const { dispatch } = this.props;
|
const { dispatch } = this.props;
|
||||||
Lbryio.call('user_settings', 'get').then(settings => {
|
doPreferenceGet('shared', null, null, preference => {
|
||||||
dispatch(doPopulateSharedUserState(settings));
|
dispatch(doPopulateSharedUserState(preference));
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -148,7 +148,11 @@ const persistor = persistStore(store, persistOptions, err => {
|
||||||
});
|
});
|
||||||
window.persistor = persistor;
|
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 = {
|
const sharedStateFilters = {
|
||||||
tags: { source: 'tags', property: 'followedTags' },
|
tags: { source: 'tags', property: 'followedTags' },
|
||||||
subscriptions: {
|
subscriptions: {
|
||||||
|
@ -163,7 +167,7 @@ const sharedStateFilters = {
|
||||||
store.subscribe(() => {
|
store.subscribe(() => {
|
||||||
try {
|
try {
|
||||||
const state = store.getState();
|
const state = store.getState();
|
||||||
sharedStateSubscriber(state, sharedStateFilters, sharedStateCache);
|
sharedStateSubscriber(state, sharedStateFilters, '0.1');
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
// handle gracefully?
|
// handle gracefully?
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
import { Lbry } from 'lbry-redux';
|
import { Lbry, doPreferenceGet } from 'lbry-redux';
|
||||||
import { Lbryio } from 'lbryinc';
|
import { Lbryio } from 'lbryinc';
|
||||||
import { ActivityIndicator, Linking, NativeModules, Platform, Text, View } from 'react-native';
|
import { ActivityIndicator, Linking, NativeModules, Platform, Text, View } from 'react-native';
|
||||||
import { NavigationActions, StackActions } from 'react-navigation';
|
import { NavigationActions, StackActions } from 'react-navigation';
|
||||||
|
@ -113,8 +113,9 @@ class SplashScreen extends React.PureComponent {
|
||||||
|
|
||||||
getUserSettings = () => {
|
getUserSettings = () => {
|
||||||
const { populateSharedUserState } = this.props;
|
const { populateSharedUserState } = this.props;
|
||||||
Lbryio.call('user_settings', 'get').then(settings => {
|
|
||||||
populateSharedUserState(settings);
|
doPreferenceGet('shared', null, null, preference => {
|
||||||
|
populateSharedUserState(preference);
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue
none of the logic in this file appears to affect the presentation or rendering of this component
is there a design that would separate this out more cleanly? maybe just make it it's own component?