refactor: remove withDefaults
macro and clean up reactive props destructuring (#3217)
This commit is contained in:
parent
7d9712c209
commit
60b1d0224c
52 changed files with 177 additions and 232 deletions
|
@ -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>
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue