Add persistent watch time setting. #7547

Merged
Ruk33 merged 8 commits from 7543-settings-option-to-persist-fully-watched-files-for-view-indicator into master 2022-04-22 05:00:57 +02:00
7 changed files with 39 additions and 5 deletions
Showing only changes of commit bdfe9ed998 - Show all commits

View file

@ -2324,5 +2324,8 @@
"%repost% %publish%": "%repost% %publish%",
"Failed to view lbry://@MicheL-PDF#7/LaDameAuPain#f, please try again. If this problem persists, visit https://lbry.com/faq/support for support.": "Failed to view lbry://@MicheL-PDF#7/LaDameAuPain#f, please try again. If this problem persists, visit https://lbry.com/faq/support for support.",
"Go to": "Go to",
"* Note that as\n peer-to-peer software, your IP address and potentially other system information can be sent to other\n users, though this information is not stored permanently.": "* Note that as\n peer-to-peer software, your IP address and potentially other system information can be sent to other\n users, though this information is not stored permanently.",
"Persist watch time": "Persist watch time",
"Persist the watch time of the videos you have watched.": "Persist the watch time of the videos you have watched.",
"--end--": "--end--"
}

View file

@ -1,12 +1,19 @@
import { connect } from 'react-redux';
import * as SETTINGS from 'constants/settings';
import { doResolveUri } from 'redux/actions/claims';
import { makeSelectClientSetting } from 'redux/selectors/settings';
import { makeSelectClaimForUri } from 'redux/selectors/claims';
import { makeSelectContentPositionForUri } from 'redux/selectors/content';
import { makeSelectContentPositionForUri, makeSelectContentPositionPersistedForUri } from 'redux/selectors/content';
import CardMedia from './view';
const select = (state, props) => ({
position: makeSelectContentPositionForUri(props.uri)(state),
const select = (state, props) => {
const persistWatchTime = makeSelectClientSetting(SETTINGS.PERSIST_WATCH_TIME)(state);
return {
position: persistWatchTime
? makeSelectContentPositionPersistedForUri(props.uri)(state)
: makeSelectContentPositionForUri(props.uri)(state),
claim: makeSelectClaimForUri(props.uri)(state),
});
};
};
export default connect(select, { doResolveUri })(CardMedia);

View file

@ -14,6 +14,7 @@ const select = (state) => ({
autoplayMedia: makeSelectClientSetting(SETTINGS.AUTOPLAY_MEDIA)(state),
autoplayNext: makeSelectClientSetting(SETTINGS.AUTOPLAY_NEXT)(state),
hideReposts: makeSelectClientSetting(SETTINGS.HIDE_REPOSTS)(state),
persistWatchTime: makeSelectClientSetting(SETTINGS.PERSIST_WATCH_TIME)(state),
showNsfw: selectShowMatureContent(state),
myChannelUrls: selectMyChannelUrls(state),
instantPurchaseEnabled: makeSelectClientSetting(SETTINGS.INSTANT_PURCHASE_ENABLED)(state),

View file

@ -24,6 +24,7 @@ type Props = {
autoplayNext: boolean,
hideReposts: ?boolean,
showNsfw: boolean,
persistWatchTime: boolean,
myChannelUrls: ?Array<string>,
instantPurchaseEnabled: boolean,
instantPurchaseMax: Price,
@ -40,6 +41,7 @@ export default function SettingContent(props: Props) {
autoplayMedia,
autoplayNext,
hideReposts,
persistWatchTime,
showNsfw,
myChannelUrls,
instantPurchaseEnabled,
@ -102,6 +104,14 @@ export default function SettingContent(props: Props) {
checked={hideReposts}
/>
</SettingsRow>
<SettingsRow title={__('Persist watch time')} subtitle={__(HELP.PERSIST_WATCH_TIME)}>
<FormField
type="checkbox"
name="persist_watch_time"
onChange={() => setClientSetting(SETTINGS.PERSIST_WATCH_TIME, !persistWatchTime)}
checked={persistWatchTime}
/>
</SettingsRow>
<SettingsRow title={__('Show mature content')} subtitle={__(HELP.SHOW_MATURE)}>
<FormField
type="checkbox"
@ -188,6 +198,7 @@ const HELP = {
AUTOPLAY_MEDIA: 'Autoplay video and audio files when navigating to a file.',
AUTOPLAY_NEXT: 'Autoplay the next related item when a file (video or audio) finishes playing.',
HIDE_REPOSTS: 'You will not see reposts by people you follow or receive email notifying about them.',
PERSIST_WATCH_TIME: 'Persist the watch time of the videos you have watched.',
SHOW_MATURE: 'Mature content may include nudity, intense sexuality, profanity, or other adult content. By displaying mature content, you are affirming you are of legal age to view mature content in your country or jurisdiction. ',
MAX_PURCHASE_PRICE: 'This will prevent you from purchasing any content over a certain cost, as a safety measure.',
ONLY_CONFIRM_OVER_AMOUNT: '', // [feel redundant. Disable for now] "When this option is chosen, LBRY won't ask you to confirm purchases or tips below your chosen amount.",

View file

@ -35,6 +35,7 @@ export const REWARDS_ACKNOWLEDGED = 'rewards_acknowledged';
export const SEARCH_IN_LANGUAGE = 'search_in_language';
export const HOMEPAGE = 'homepage';
export const HIDE_REPOSTS = 'hide_reposts';
export const PERSIST_WATCH_TIME = 'persist_watch_time';
export const SUPPORT_OPTION = 'support_option';
export const TILE_LAYOUT = 'tile_layout';
export const VIDEO_THEATER_MODE = 'video_theater_mode';

View file

@ -55,6 +55,7 @@ reducers[ACTIONS.SET_CONTENT_POSITION] = (state, action) => {
[claimId]: {
...state.positions[claimId],
[outpoint]: position,
[`${outpoint}:persisted`]: position,
},
},
};

View file

@ -63,6 +63,16 @@ export const makeSelectContentPositionForUri = (uri: string) =>
return state.positions[id] ? state.positions[id][outpoint] : null;
});
export const makeSelectContentPositionPersistedForUri = (uri: string) =>
createSelector(selectState, makeSelectClaimForUri(uri), (state, claim) => {
if (!claim) {
return null;
}
const outpoint = `${claim.txid}:${claim.nout}:persisted`;
const id = claim.claim_id;
return state.positions[id] ? state.positions[id][outpoint] : null;
});
export const selectHistory = createSelector(selectState, (state) => state.history || []);
export const selectHistoryPageCount = createSelector(selectHistory, (history) =>