mirror of
https://github.com/defnull/fediwall.git
synced 2024-11-21 23:23:14 +01:00
Limit tags or accounts shown in infobar.
Also, do not sort tags or accounts, so users can decide which one are more important and shown first.
This commit is contained in:
parent
93316741f2
commit
b84f3e9efa
@ -1,31 +1,53 @@
|
||||
<script setup lang="ts">
|
||||
import { type Config } from '@/types';
|
||||
import { computed } from 'vue';
|
||||
|
||||
defineProps<{
|
||||
const props = defineProps<{
|
||||
config: Config
|
||||
}>()
|
||||
|
||||
const tagLimit = 5;
|
||||
const accountLimit = 2;
|
||||
|
||||
const tagsHidden = computed(()=> Math.max(0, props.config.tags.length - tagLimit))
|
||||
const accountsHidden = computed(()=> Math.max(0, props.config.accounts.length - accountLimit))
|
||||
|
||||
const tags = computed(()=>{
|
||||
const limited = props.config.tags.slice(0, tagLimit)
|
||||
return limited
|
||||
})
|
||||
|
||||
const accounts = computed(()=>{
|
||||
const limited = props.config.accounts.slice(0,accountLimit)
|
||||
return limited
|
||||
})
|
||||
|
||||
function sep(index: number, length: number, sep: string, lastsep: string) {
|
||||
if(index < length - 2)
|
||||
return sep
|
||||
else if(index == length - 2)
|
||||
return lastsep
|
||||
}
|
||||
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div>
|
||||
This Fediwall shows
|
||||
<template v-if="config.tags.length">
|
||||
posts tagged with
|
||||
<template v-for="(t, index) in config.tags" :key="t">
|
||||
<code>#{{ t }}</code>
|
||||
<template v-if="index < config.tags.length - 2">, </template>
|
||||
<template v-else-if="index == config.tags.length - 2"> or </template>
|
||||
This Fediwall shows posts
|
||||
<template v-if="tags.length">
|
||||
tagged with
|
||||
<template v-for="(t, index) in tags" :key="index">
|
||||
<code>#{{ t }}</code>{{ sep(index, tags.length, ", ", tagsHidden ? ", " : " or ") }}
|
||||
</template>
|
||||
<span v-if="tagsHidden"> and more</span>
|
||||
</template>
|
||||
<template v-if="config.accounts.length && config?.tags.length"> and </template>
|
||||
<template v-if="config.accounts.length">
|
||||
posts or boosts by
|
||||
<template v-for="(acc, index) in config.accounts" :key="acc">
|
||||
<code>@{{ acc }}</code>
|
||||
<template v-if="index < config.accounts.length - 2">, </template>
|
||||
<template v-else-if="index == config.accounts.length - 2"> or </template>
|
||||
<template v-if="accounts.length">
|
||||
<template v-if="tags.length"> as well as posts </template>
|
||||
by
|
||||
<template v-for="(acc, index) in accounts" :key="index">
|
||||
<code>@{{ acc }}</code>{{ sep(index, accounts.length, ", ", accountsHidden ? ", " : " or ") }}
|
||||
</template>
|
||||
<span v-if="accountsHidden"> and more</span>
|
||||
</template>
|
||||
</div>
|
||||
</template>
|
||||
|
@ -247,8 +247,8 @@ export function sanatizeConfig(config: any): Config {
|
||||
const result: Partial<Config> = {}
|
||||
|
||||
result.servers = arrayUnique((Array.isArray(config.servers) ? [...config.servers] : [...fallback.servers]).filter(isServer));
|
||||
result.tags = arrayUnique((Array.isArray(config.tags) ? [...config.tags] : [...fallback.tags]).map(stripTag).filter(isTag).sort() as string[]);
|
||||
result.accounts = arrayUnique((Array.isArray(config.accounts) ? [...config.accounts] : [...fallback.accounts]).filter(isAccount).sort());
|
||||
result.tags = arrayUnique((Array.isArray(config.tags) ? [...config.tags] : [...fallback.tags]).map(stripTag).filter(isTag) as string[]);
|
||||
result.accounts = arrayUnique((Array.isArray(config.accounts) ? [...config.accounts] : [...fallback.accounts]).filter(isAccount));
|
||||
|
||||
result.loadFederated = boolOr(config.loadFederated, fallback.loadFederated)
|
||||
result.loadPublic = boolOr(config.loadPublic, fallback.loadPublic)
|
||||
|
Loading…
Reference in New Issue
Block a user