Preferences #56

Closed
akinwale wants to merge 4 commits from preferences into master
3 changed files with 21 additions and 21 deletions
Showing only changes of commit 5eba4ab2ec - Show all commits

4
package-lock.json generated
View file

@ -5640,8 +5640,8 @@
} }
}, },
"lbry-redux": { "lbry-redux": {
"version": "github:lbryio/lbry-redux#7ec72a737bcd336f000c5f5085891643110298c3", "version": "github:lbryio/lbry-redux#23bcde0539a27fb19bf3a7d87683279194e02046",
"from": "github:lbryio/lbry-redux#7ec72a737bcd336f000c5f5085891643110298c3", "from": "github:lbryio/lbry-redux#23bcde0539a27fb19bf3a7d87683279194e02046",
"requires": { "requires": {
"proxy-polyfill": "0.1.6", "proxy-polyfill": "0.1.6",
"reselect": "^3.0.0", "reselect": "^3.0.0",

View file

@ -12,7 +12,7 @@
"base-64": "^0.1.0", "base-64": "^0.1.0",
"@expo/vector-icons": "^8.1.0", "@expo/vector-icons": "^8.1.0",
"gfycat-style-urls": "^1.0.3", "gfycat-style-urls": "^1.0.3",
"lbry-redux": "lbryio/lbry-redux#7ec72a737bcd336f000c5f5085891643110298c3", "lbry-redux": "lbryio/lbry-redux#23bcde0539a27fb19bf3a7d87683279194e02046",
"lbryinc": "lbryio/lbryinc#67bb3e215be3f13605c5e3f9f2b0e2fb880724cf", "lbryinc": "lbryio/lbryinc#67bb3e215be3f13605c5e3f9f2b0e2fb880724cf",
"lodash": ">=4.17.11", "lodash": ">=4.17.11",
"merge": ">=1.2.1", "merge": ">=1.2.1",

View file

@ -13,6 +13,7 @@ import {
searchReducer, searchReducer,
tagsReducer, tagsReducer,
walletReducer, walletReducer,
sharedStateSubscriber,
} from 'lbry-redux'; } from 'lbry-redux';
import { import {
Lbryio, Lbryio,
@ -83,7 +84,7 @@ const compressor = createCompressor();
const authFilter = createFilter('auth', ['authToken']); const authFilter = createFilter('auth', ['authToken']);
const contentFilter = createFilter('content', ['positions']); const contentFilter = createFilter('content', ['positions']);
const saveClaimsFilter = createFilter('claims', ['claimsByUri']); const saveClaimsFilter = createFilter('claims', ['claimsByUri']);
const subscriptionsFilter = createFilter('subscriptions', ['enabledChannelNotifications', 'subscriptions']); const subscriptionsFilter = createFilter('subscriptions', ['enabledChannelNotifications', 'subscriptions', 'latest']);
const settingsFilter = createFilter('settings', ['clientSettings']); const settingsFilter = createFilter('settings', ['clientSettings']);
const tagsFilter = createFilter('tags', ['followedTags']); const tagsFilter = createFilter('tags', ['followedTags']);
const walletFilter = createFilter('wallet', ['receiveAddress']); const walletFilter = createFilter('wallet', ['receiveAddress']);
@ -147,25 +148,24 @@ const persistor = persistStore(store, persistOptions, err => {
}); });
window.persistor = persistor; window.persistor = persistor;
let currentPayload; const sharedStateCache = {};
store.subscribe(() => { const sharedStateFilters = {
const state = store.getState(); tags: { source: 'tags', property: 'followedTags' },
const subscriptions = state.subscriptions.subscriptions.map(({ uri }) => uri); subscriptions: {
const tags = state.tags.followedTags; source: 'subscriptions',
property: 'subscriptions',
const newPayload = { transform: function(value) {
version: '0.1', return value.map(({ uri }) => uri);
shared: { },
subscriptions,
tags,
}, },
}; };
if (!isEqual(newPayload, currentPayload)) { store.subscribe(() => {
currentPayload = newPayload; try {
if (Lbryio.authToken) { const state = store.getState();
Lbryio.call('user_settings', 'set', { settings: JSON.stringify(newPayload) }); sharedStateSubscriber(state, sharedStateFilters, sharedStateCache);
} } catch (e) {
// handle gracefully?
} }
}); });