Preferences #56
3 changed files with 21 additions and 21 deletions
4
package-lock.json
generated
4
package-lock.json
generated
|
@ -5640,8 +5640,8 @@
|
|||
}
|
||||
},
|
||||
"lbry-redux": {
|
||||
"version": "github:lbryio/lbry-redux#7ec72a737bcd336f000c5f5085891643110298c3",
|
||||
"from": "github:lbryio/lbry-redux#7ec72a737bcd336f000c5f5085891643110298c3",
|
||||
"version": "github:lbryio/lbry-redux#23bcde0539a27fb19bf3a7d87683279194e02046",
|
||||
"from": "github:lbryio/lbry-redux#23bcde0539a27fb19bf3a7d87683279194e02046",
|
||||
"requires": {
|
||||
"proxy-polyfill": "0.1.6",
|
||||
"reselect": "^3.0.0",
|
||||
|
|
|
@ -12,7 +12,7 @@
|
|||
"base-64": "^0.1.0",
|
||||
"@expo/vector-icons": "^8.1.0",
|
||||
"gfycat-style-urls": "^1.0.3",
|
||||
"lbry-redux": "lbryio/lbry-redux#7ec72a737bcd336f000c5f5085891643110298c3",
|
||||
"lbry-redux": "lbryio/lbry-redux#23bcde0539a27fb19bf3a7d87683279194e02046",
|
||||
"lbryinc": "lbryio/lbryinc#67bb3e215be3f13605c5e3f9f2b0e2fb880724cf",
|
||||
"lodash": ">=4.17.11",
|
||||
"merge": ">=1.2.1",
|
||||
|
|
36
src/index.js
36
src/index.js
|
@ -13,6 +13,7 @@ import {
|
|||
searchReducer,
|
||||
tagsReducer,
|
||||
walletReducer,
|
||||
sharedStateSubscriber,
|
||||
} from 'lbry-redux';
|
||||
import {
|
||||
Lbryio,
|
||||
|
@ -83,7 +84,7 @@ const compressor = createCompressor();
|
|||
const authFilter = createFilter('auth', ['authToken']);
|
||||
const contentFilter = createFilter('content', ['positions']);
|
||||
const saveClaimsFilter = createFilter('claims', ['claimsByUri']);
|
||||
const subscriptionsFilter = createFilter('subscriptions', ['enabledChannelNotifications', 'subscriptions']);
|
||||
const subscriptionsFilter = createFilter('subscriptions', ['enabledChannelNotifications', 'subscriptions', 'latest']);
|
||||
const settingsFilter = createFilter('settings', ['clientSettings']);
|
||||
const tagsFilter = createFilter('tags', ['followedTags']);
|
||||
const walletFilter = createFilter('wallet', ['receiveAddress']);
|
||||
|
@ -147,25 +148,24 @@ const persistor = persistStore(store, persistOptions, err => {
|
|||
});
|
||||
window.persistor = persistor;
|
||||
|
||||
let currentPayload;
|
||||
store.subscribe(() => {
|
||||
const state = store.getState();
|
||||
const subscriptions = state.subscriptions.subscriptions.map(({ uri }) => uri);
|
||||
const tags = state.tags.followedTags;
|
||||
|
||||
const newPayload = {
|
||||
version: '0.1',
|
||||
shared: {
|
||||
subscriptions,
|
||||
tags,
|
||||
const sharedStateCache = {};
|
||||
const sharedStateFilters = {
|
||||
tags: { source: 'tags', property: 'followedTags' },
|
||||
subscriptions: {
|
||||
source: 'subscriptions',
|
||||
property: 'subscriptions',
|
||||
transform: function(value) {
|
||||
return value.map(({ uri }) => uri);
|
||||
},
|
||||
};
|
||||
},
|
||||
};
|
||||
|
||||
if (!isEqual(newPayload, currentPayload)) {
|
||||
currentPayload = newPayload;
|
||||
if (Lbryio.authToken) {
|
||||
Lbryio.call('user_settings', 'set', { settings: JSON.stringify(newPayload) });
|
||||
}
|
||||
store.subscribe(() => {
|
||||
try {
|
||||
const state = store.getState();
|
||||
sharedStateSubscriber(state, sharedStateFilters, sharedStateCache);
|
||||
} catch (e) {
|
||||
// handle gracefully?
|
||||
}
|
||||
});
|
||||
|
||||
|
|
Loading…
Reference in a new issue