re-use existing "forceShowAds" preference model

This commit is contained in:
Hazelnoot 2025-06-22 13:09:12 -04:00
parent dc9c6a34b6
commit f95ed0faa7
4 changed files with 7 additions and 8 deletions

View file

@ -110,7 +110,7 @@ export default defineComponent({
}); });
const renderChildren = () => { const renderChildren = () => {
const shouldHideAds = prefer.s.hideAds && $i != null && $i.policies.canHideAds; const shouldHideAds = (!prefer.s.forceShowAds && $i && $i.policies.canHideAds) ?? false;
const children = renderChildrenImpl(shouldHideAds); const children = renderChildrenImpl(shouldHideAds);
if (isDebuggerEnabled(6864)) { if (isDebuggerEnabled(6864)) {

View file

@ -107,7 +107,7 @@ const chosen = ref(choseAd());
const self = computed(() => chosen.value?.url.startsWith(local)); const self = computed(() => chosen.value?.url.startsWith(local));
const shouldHide = computed(() => prefer.s.hideAds && $i != null && $i.policies.canHideAds && (props.specify == null)); const shouldHide = ref(!prefer.s.forceShowAds && $i && $i.policies.canHideAds && (props.specify == null));
function reduceFrequency(): void { function reduceFrequency(): void {
if (chosen.value == null) return; if (chosen.value == null) return;

View file

@ -913,8 +913,8 @@ SPDX-License-Identifier: AGPL-3.0-only
</MkFolder> </MkFolder>
</SearchMarker> </SearchMarker>
<SearchMarker :keywords="['ad', 'hide']"> <SearchMarker :keywords="['ad', 'show', 'hide']">
<MkPreferenceContainer k="hideAds"> <MkPreferenceContainer k="forceShowAds">
<MkSwitch v-model="hideAds" :disabled="$i.policies.canHideAds"> <MkSwitch v-model="hideAds" :disabled="$i.policies.canHideAds">
<template #label><SearchLabel>{{ i18n.ts.hideAds }}</SearchLabel></template> <template #label><SearchLabel>{{ i18n.ts.hideAds }}</SearchLabel></template>
</MkSwitch> </MkSwitch>
@ -1096,7 +1096,9 @@ const trustedDomains = prefer.model(
(domainsList) => domainsList.join('\n'), (domainsList) => domainsList.join('\n'),
(domainsString) => domainsString.split('\n').map( d => d.trim() ).filter( x => x.length > 0), (domainsString) => domainsString.split('\n').map( d => d.trim() ).filter( x => x.length > 0),
); );
const hideAds = prefer.model('hideAds');
// Inverted to map between "hide ads" and "force show ads"
const hideAds = prefer.model('forceShowAds', x => !x, x => !x);
watch([ watch([
hemisphere, hemisphere,

View file

@ -480,9 +480,6 @@ export const PREF_DEF = {
warnMissingAltText: { warnMissingAltText: {
default: true, default: true,
}, },
hideAds: {
default: false,
},
//#endregion //#endregion
//#region hybrid options //#region hybrid options