From e9e2a5dd77dc44220d37900100879f94283cced9 Mon Sep 17 00:00:00 2001 From: dakkar Date: Wed, 18 Dec 2024 15:56:46 +0000 Subject: [PATCH] avoid empty blocks when hiding ads 2024.10 or 2024.11 added a `
` around ``, but while `MkAd` checks if ads should be shown, and generates an empty `
` if not, the wrapper `div` was always shown. This commit takes the same logic from `MkAd` and applies it to the wrapper as well. thanks to @puppygirlhornypost for noticing --- packages/frontend/src/components/MkDateSeparatedList.vue | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/packages/frontend/src/components/MkDateSeparatedList.vue b/packages/frontend/src/components/MkDateSeparatedList.vue index 4b9666c55c..eeeabb476e 100644 --- a/packages/frontend/src/components/MkDateSeparatedList.vue +++ b/packages/frontend/src/components/MkDateSeparatedList.vue @@ -12,6 +12,7 @@ import * as os from '@/os.js'; import { instance } from '@/instance.js'; import { defaultStore } from '@/store.js'; import { MisskeyEntity } from '@/types/date-separated-list.js'; +import { $i } from '@/account.js'; export default defineComponent({ props: { @@ -55,7 +56,7 @@ export default defineComponent({ if (props.items.length === 0) return; - const renderChildrenImpl = () => props.items.map((item, i) => { + const renderChildrenImpl = (shouldHideAds: boolean) => props.items.map((item, i) => { if (!slots || !slots.default) return; const el = slots.default({ @@ -100,7 +101,7 @@ export default defineComponent({ return [el, separator]; } else { - if (props.ad && instance.ads.length > 0 && item._shouldInsertAd_) { + if (props.ad && instance.ads.length > 0 && item._shouldInsertAd_ && !shouldHideAds) { return [h('div', { key: item.id + ':ad', class: $style['ad-wrapper'], @@ -114,7 +115,9 @@ export default defineComponent({ }); const renderChildren = () => { - const children = renderChildrenImpl(); + const shouldHideAds = !defaultStore.state.forceShowAds && $i && $i.policies.canHideAds; + + const children = renderChildrenImpl(shouldHideAds); if (isDebuggerEnabled(6864)) { const nodes = children.flatMap((node) => node ?? []); const keys = new Set(nodes.map((node) => node.key));