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 shouldHideAds = prefer.s.hideAds && $i != null && $i.policies.canHideAds;
const shouldHideAds = (!prefer.s.forceShowAds && $i && $i.policies.canHideAds) ?? false;
const children = renderChildrenImpl(shouldHideAds);
if (isDebuggerEnabled(6864)) {

View file

@ -107,7 +107,7 @@ const chosen = ref(choseAd());
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 {
if (chosen.value == null) return;

View file

@ -913,8 +913,8 @@ SPDX-License-Identifier: AGPL-3.0-only
</MkFolder>
</SearchMarker>
<SearchMarker :keywords="['ad', 'hide']">
<MkPreferenceContainer k="hideAds">
<SearchMarker :keywords="['ad', 'show', 'hide']">
<MkPreferenceContainer k="forceShowAds">
<MkSwitch v-model="hideAds" :disabled="$i.policies.canHideAds">
<template #label><SearchLabel>{{ i18n.ts.hideAds }}</SearchLabel></template>
</MkSwitch>
@ -1096,7 +1096,9 @@ const trustedDomains = prefer.model(
(domainsList) => domainsList.join('\n'),
(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([
hemisphere,

View file

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