From 26168670dd619c5dbc7d0d6d3d5810c83614cad5 Mon Sep 17 00:00:00 2001 From: Lukewh Date: Thu, 20 Feb 2020 12:30:27 +0000 Subject: [PATCH] Repost settings --- CHANGELOG.md | 2 ++ ui/component/claimListDiscover/index.js | 1 + ui/component/claimListDiscover/view.jsx | 7 +++++-- ui/component/claimTilesDiscover/index.js | 1 + ui/component/claimTilesDiscover/view.jsx | 7 +++++++ ui/constants/settings.js | 1 + ui/page/settings/index.js | 1 + ui/page/settings/view.jsx | 13 +++++++++++++ ui/redux/reducers/settings.js | 1 + ui/redux/selectors/settings.js | 18 ++++++++++-------- 10 files changed, 42 insertions(+), 10 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e1bffce82..5219ea293 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). ## [0.4x.x] - [Unreleased] ### Added +- Show reposts setting ([#3712](https://github.com/lbryio/lbry-desktop/pull/3712)) + - Czech and Kannada language support ([#3759](https://github.com/lbryio/lbry-desktop/pull/3759)) diff --git a/ui/component/claimListDiscover/index.js b/ui/component/claimListDiscover/index.js index bcf0a521c..75b712038 100644 --- a/ui/component/claimListDiscover/index.js +++ b/ui/component/claimListDiscover/index.js @@ -14,6 +14,7 @@ const select = state => ({ claimSearchByQuery: selectClaimSearchByQuery(state), loading: selectFetchingClaimSearch(state), showNsfw: makeSelectClientSetting(SETTINGS.SHOW_MATURE)(state), + showReposts: makeSelectClientSetting(SETTINGS.SHOW_REPOSTS)(state), hiddenUris: selectBlockedChannels(state), }); diff --git a/ui/component/claimListDiscover/view.jsx b/ui/component/claimListDiscover/view.jsx index 7b70d11c8..d23190745 100644 --- a/ui/component/claimListDiscover/view.jsx +++ b/ui/component/claimListDiscover/view.jsx @@ -36,6 +36,7 @@ type Props = { doToggleTagFollow: string => void, meta?: Node, showNsfw: boolean, + showReposts: boolean, history: { action: string, push: string => void, replace: string => void }, location: { search: string, pathname: string }, claimSearchByQuery: { @@ -67,6 +68,7 @@ function ClaimListDiscover(props: Props) { meta, channelIds, showNsfw, + showReposts, history, location, hiddenUris, @@ -101,6 +103,7 @@ function ClaimListDiscover(props: Props) { not_tags: Array, order_by: Array, release_time?: string, + claim_type?: string, name?: string, claim_type?: string | Array, } = { @@ -162,8 +165,8 @@ function ClaimListDiscover(props: Props) { } } - if (claimType) { - options.claim_type = claimType; + if (!showReposts) { + options.claim_type = 'stream'; } const hasMatureTags = tags && tags.some(t => MATURE_TAGS.includes(t)); diff --git a/ui/component/claimTilesDiscover/index.js b/ui/component/claimTilesDiscover/index.js index bcf0a521c..75b712038 100644 --- a/ui/component/claimTilesDiscover/index.js +++ b/ui/component/claimTilesDiscover/index.js @@ -14,6 +14,7 @@ const select = state => ({ claimSearchByQuery: selectClaimSearchByQuery(state), loading: selectFetchingClaimSearch(state), showNsfw: makeSelectClientSetting(SETTINGS.SHOW_MATURE)(state), + showReposts: makeSelectClientSetting(SETTINGS.SHOW_REPOSTS)(state), hiddenUris: selectBlockedChannels(state), }); diff --git a/ui/component/claimTilesDiscover/view.jsx b/ui/component/claimTilesDiscover/view.jsx index 5757143ff..98e98634a 100644 --- a/ui/component/claimTilesDiscover/view.jsx +++ b/ui/component/claimTilesDiscover/view.jsx @@ -8,6 +8,7 @@ type Props = { doClaimSearch: ({}) => void, loading: boolean, showNsfw: boolean, + showReposts: boolean, history: { action: string, push: string => void, replace: string => void }, claimSearchByQuery: { [string]: Array, @@ -30,6 +31,7 @@ function ClaimTilesDiscover(props: Props) { claimSearchByQuery, loading, showNsfw, + showReposts, hiddenUris, // Below are options to pass that are forwarded to claim_search tags, @@ -73,9 +75,14 @@ function ClaimTilesDiscover(props: Props) { options.release_time = releaseTime; } + if (!showReposts) { + options.claim_type = 'stream'; + } + if (claimType) { options.claim_type = claimType; } + if (timestamp) { options.timestamp = timestamp; } diff --git a/ui/constants/settings.js b/ui/constants/settings.js index c3efa057f..029abc29a 100644 --- a/ui/constants/settings.js +++ b/ui/constants/settings.js @@ -23,3 +23,4 @@ export const HIDE_SPLASH_ANIMATION = 'hide_splash_animation'; export const FLOATING_PLAYER = 'floating_player'; export const DARK_MODE_TIMES = 'dark_mode_times'; export const ENABLE_SYNC = 'enable_sync'; +export const SHOW_REPOSTS = 'show_reposts'; diff --git a/ui/page/settings/index.js b/ui/page/settings/index.js index 689a8ec02..3f55dbcce 100644 --- a/ui/page/settings/index.js +++ b/ui/page/settings/index.js @@ -32,6 +32,7 @@ const select = state => ({ userBlockedChannelsCount: selectBlockedChannelsCount(state), hideBalance: makeSelectClientSetting(SETTINGS.HIDE_BALANCE)(state), floatingPlayer: makeSelectClientSetting(SETTINGS.FLOATING_PLAYER)(state), + showReposts: makeSelectClientSetting(SETTINGS.SHOW_REPOSTS)(state), darkModeTimes: makeSelectClientSetting(SETTINGS.DARK_MODE_TIMES)(state), }); diff --git a/ui/page/settings/view.jsx b/ui/page/settings/view.jsx index c5fb7a1e0..58bf6c164 100644 --- a/ui/page/settings/view.jsx +++ b/ui/page/settings/view.jsx @@ -74,6 +74,7 @@ type Props = { hideBalance: boolean, confirmForgetPassword: ({}) => void, floatingPlayer: boolean, + showReposts: boolean, clearPlayingUri: () => void, darkModeTimes: DarkModeTimes, setDarkTime: (string, {}) => void, @@ -208,6 +209,7 @@ class SettingsPage extends React.PureComponent { hideBalance, userBlockedChannelsCount, floatingPlayer, + showReposts, clearPlayingUri, darkModeTimes, clearCache, @@ -397,6 +399,17 @@ class SettingsPage extends React.PureComponent { )} /> + { + setClientSetting(SETTINGS.SHOW_REPOSTS, !showReposts); + }} + checked={showReposts} + label={__('Show reposts')} + helper={__('Show reposts from the creators you follow.')} + /> + {/* // refactor me export const selectShowMatureContent = makeSelectClientSetting(SETTINGS.SHOW_MATURE); +// and me +export const selectShowRepostedContent = makeSelectClientSetting(SETTINGS.SHOW_REPOSTS); + export const selectTheme = makeSelectClientSetting(SETTINGS.THEME); export const selectAutomaticDarkModeEnabled = makeSelectClientSetting(SETTINGS.AUTOMATIC_DARK_MODE_ENABLED); export const selectIsNight = createSelector( @@ -56,14 +59,13 @@ export const makeSelectSharedPreferencesForKey = key => prefs => (prefs ? prefs[key] : undefined) ); -export const selectHasWalletServerPrefs = - createSelector( - makeSelectSharedPreferencesForKey(SHARED_PREFERENCES.WALLET_SERVERS), - servers => { - if (servers && servers.length) return true; - return false; - } - ) +export const selectHasWalletServerPrefs = createSelector( + makeSelectSharedPreferencesForKey(SHARED_PREFERENCES.WALLET_SERVERS), + servers => { + if (servers && servers.length) return true; + return false; + } +); export const selectThemePath = createSelector( selectTheme,