prevent specific settings sync in config
This commit is contained in:
parent
42e989d0cc
commit
ab56633eed
3 changed files with 21 additions and 9 deletions
|
@ -29,6 +29,11 @@ SITE_CANONICAL_URL=https://lbry.tv
|
||||||
# LOCALE
|
# LOCALE
|
||||||
DEFAULT_LANGUAGE=en
|
DEFAULT_LANGUAGE=en
|
||||||
|
|
||||||
|
# Custom Settings
|
||||||
|
# Additional settings for below are found in ui/constants/settings and are for
|
||||||
|
# preventing user settings from applying to custom sites without overwriting them.
|
||||||
|
# UNSYNCED_SETTINGS='theme dark_mode_times automatic_dark_mode_enabled'
|
||||||
|
|
||||||
# Custom Content
|
# Custom Content
|
||||||
# If the following is true, copy custom/homepage.example.js to custom/homepage.js and modify
|
# If the following is true, copy custom/homepage.example.js to custom/homepage.js and modify
|
||||||
CUSTOM_HOMEPAGE=false
|
CUSTOM_HOMEPAGE=false
|
||||||
|
|
|
@ -22,6 +22,7 @@ const config = {
|
||||||
SITE_CANONICAL_URL: process.env.SITE_CANONICAL_URL,
|
SITE_CANONICAL_URL: process.env.SITE_CANONICAL_URL,
|
||||||
DEFAULT_LANGUAGE: process.env.DEFAULT_LANGUAGE,
|
DEFAULT_LANGUAGE: process.env.DEFAULT_LANGUAGE,
|
||||||
AUTO_FOLLOW_CHANNELS: process.env.AUTO_FOLLOW_CHANNELS,
|
AUTO_FOLLOW_CHANNELS: process.env.AUTO_FOLLOW_CHANNELS,
|
||||||
|
UNSYNCED_SETTINGS: process.env.UNSYNCED_SETTINGS,
|
||||||
SIMPLE_SITE: process.env.SIMPLE_SITE === 'true',
|
SIMPLE_SITE: process.env.SIMPLE_SITE === 'true',
|
||||||
SHOW_ADS: process.env.SHOW_ADS === 'true',
|
SHOW_ADS: process.env.SHOW_ADS === 'true',
|
||||||
PINNED_URI_1: process.env.PINNED_URI_1,
|
PINNED_URI_1: process.env.PINNED_URI_1,
|
||||||
|
|
|
@ -3,7 +3,12 @@ import moment from 'moment';
|
||||||
import SUPPORTED_LANGUAGES from 'constants/supported_languages';
|
import SUPPORTED_LANGUAGES from 'constants/supported_languages';
|
||||||
import { ACTIONS as LBRY_REDUX_ACTIONS, SETTINGS, SHARED_PREFERENCES } from 'lbry-redux';
|
import { ACTIONS as LBRY_REDUX_ACTIONS, SETTINGS, SHARED_PREFERENCES } from 'lbry-redux';
|
||||||
import { getSubsetFromKeysArray } from 'util/sync-settings';
|
import { getSubsetFromKeysArray } from 'util/sync-settings';
|
||||||
|
import { UNSYNCED_SETTINGS } from 'config';
|
||||||
const { CLIENT_SYNC_KEYS } = SHARED_PREFERENCES;
|
const { CLIENT_SYNC_KEYS } = SHARED_PREFERENCES;
|
||||||
|
const settingsToIgnore = (UNSYNCED_SETTINGS && UNSYNCED_SETTINGS.trim().split(' ')) || [];
|
||||||
|
const clientSyncKeys = settingsToIgnore.length
|
||||||
|
? CLIENT_SYNC_KEYS.filter(k => !settingsToIgnore.includes(k))
|
||||||
|
: CLIENT_SYNC_KEYS;
|
||||||
|
|
||||||
const reducers = {};
|
const reducers = {};
|
||||||
let settingLanguage = [];
|
let settingLanguage = [];
|
||||||
|
@ -72,14 +77,6 @@ reducers[ACTIONS.REHYDRATE] = (state, action) => {
|
||||||
return Object.assign({}, state, { clientSettings });
|
return Object.assign({}, state, { clientSettings });
|
||||||
};
|
};
|
||||||
|
|
||||||
reducers[ACTIONS.SYNC_CLIENT_SETTINGS] = state => {
|
|
||||||
const { clientSettings } = state;
|
|
||||||
const sharedPreferences = Object.assign({}, state.sharedPreferences);
|
|
||||||
const selectedClientSettings = getSubsetFromKeysArray(clientSettings, CLIENT_SYNC_KEYS);
|
|
||||||
const newSharedPreferences = { ...sharedPreferences, ...selectedClientSettings };
|
|
||||||
return Object.assign({}, state, { sharedPreferences: newSharedPreferences });
|
|
||||||
};
|
|
||||||
|
|
||||||
reducers[ACTIONS.FINDING_FFMPEG_STARTED] = state =>
|
reducers[ACTIONS.FINDING_FFMPEG_STARTED] = state =>
|
||||||
Object.assign({}, state, {
|
Object.assign({}, state, {
|
||||||
findingFFmpeg: true,
|
findingFFmpeg: true,
|
||||||
|
@ -157,11 +154,20 @@ reducers[ACTIONS.CLIENT_SETTING_CHANGED] = (state, action) => {
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
reducers[ACTIONS.SYNC_CLIENT_SETTINGS] = state => {
|
||||||
|
const { clientSettings } = state;
|
||||||
|
const sharedPreferences = Object.assign({}, state.sharedPreferences);
|
||||||
|
const selectedClientSettings = getSubsetFromKeysArray(clientSettings, clientSyncKeys);
|
||||||
|
const newSharedPreferences = { ...sharedPreferences, ...selectedClientSettings };
|
||||||
|
return Object.assign({}, state, { sharedPreferences: newSharedPreferences });
|
||||||
|
};
|
||||||
|
|
||||||
reducers[LBRY_REDUX_ACTIONS.USER_STATE_POPULATE] = (state, action) => {
|
reducers[LBRY_REDUX_ACTIONS.USER_STATE_POPULATE] = (state, action) => {
|
||||||
const { clientSettings: currentClientSettings } = state;
|
const { clientSettings: currentClientSettings } = state;
|
||||||
const { settings: sharedPreferences } = action.data;
|
const { settings: sharedPreferences } = action.data;
|
||||||
|
|
||||||
if (currentClientSettings[SETTINGS.ENABLE_SYNC]) {
|
if (currentClientSettings[SETTINGS.ENABLE_SYNC]) {
|
||||||
const selectedSettings = getSubsetFromKeysArray(sharedPreferences, CLIENT_SYNC_KEYS);
|
const selectedSettings = getSubsetFromKeysArray(sharedPreferences, clientSyncKeys);
|
||||||
const mergedClientSettings = { ...currentClientSettings, ...selectedSettings };
|
const mergedClientSettings = { ...currentClientSettings, ...selectedSettings };
|
||||||
return Object.assign({}, state, { sharedPreferences, clientSettings: mergedClientSettings });
|
return Object.assign({}, state, { sharedPreferences, clientSettings: mergedClientSettings });
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue