refactor: remove withDefaults macro and clean up reactive props destructuring (#3217)

This commit is contained in:
TAKAHASHI Shuuji 2025-03-02 23:50:12 +09:00 committed by GitHub
parent 7d9712c209
commit 60b1d0224c
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
52 changed files with 177 additions and 232 deletions

View file

@ -1,5 +1,5 @@
<script setup lang="ts">
const props = defineProps<{
const { enabled, filter, sensitiveNonSpoiler } = defineProps<{
enabled?: boolean
filter?: boolean
isDM?: boolean
@ -10,12 +10,12 @@ const expandSpoilers = computed(() => {
const expandCW = currentUser.value ? getExpandSpoilersByDefault(currentUser.value.account) : false
const expandMedia = currentUser.value ? getExpandMediaByDefault(currentUser.value.account) : false
return !props.filter // always prevent expansion if filtered
&& ((props.sensitiveNonSpoiler && expandMedia)
|| (!props.sensitiveNonSpoiler && expandCW))
return !filter // always prevent expansion if filtered
&& ((sensitiveNonSpoiler && expandMedia)
|| (!sensitiveNonSpoiler && expandCW))
})
const hideContent = props.enabled || props.sensitiveNonSpoiler
const hideContent = enabled || sensitiveNonSpoiler
const showContent = ref(expandSpoilers.value ? true : !hideContent)
const toggleContent = useToggle(showContent)
@ -23,9 +23,9 @@ watchEffect(() => {
showContent.value = expandSpoilers.value ? true : !hideContent
})
function getToggleText() {
if (props.sensitiveNonSpoiler)
if (sensitiveNonSpoiler)
return 'status.spoiler_media_hidden'
return props.filter ? 'status.filter_show_anyway' : 'status.spoiler_show_more'
return filter ? 'status.filter_show_anyway' : 'status.spoiler_show_more'
}
</script>