Allow to hide all posts from a domain

This commit is contained in:
Marcel Hellkamp 2024-02-09 17:58:34 +01:00
parent 41a95c2493
commit 93316741f2

View File

@ -16,7 +16,6 @@ const config = ref<Config>();
const allPosts = ref<Array<Post>>([]) const allPosts = ref<Array<Post>>([])
const pinned = ref<Array<string>>([]) const pinned = ref<Array<string>>([])
const hidden = ref<Array<string>>([]) const hidden = ref<Array<string>>([])
const banned = ref<Array<string>>([])
const updateInProgress = ref(false) const updateInProgress = ref(false)
var updateIntervalHandle: number; var updateIntervalHandle: number;
@ -148,11 +147,11 @@ const filteredPosts = computed(() => {
var posts: Array<Post> = JSON.parse(JSON.stringify(allPosts.value)) var posts: Array<Post> = JSON.parse(JSON.stringify(allPosts.value))
const pinnedLocal = [...pinned.value] const pinnedLocal = [...pinned.value]
const hiddenLocal = [...hidden.value] const hiddenLocal = [...hidden.value]
const bannedLocal = [...banned.value]
// Filter hidden posts or banned authors // Filter hidden posts, authors or domains
posts = posts.filter((p) => !hiddenLocal.includes(p.id)) posts = posts.filter((p) => !hiddenLocal.some(hide =>
posts = posts.filter((p) => !p.author?.url || !bannedLocal.includes(p.author.url)) p.id == hide || p.author?.profile.endsWith(hide)
))
// Mark pinned posts // Mark pinned posts
posts.forEach(p => { p.pinned = pinnedLocal.includes(p.id) }) posts.forEach(p => { p.pinned = pinnedLocal.includes(p.id) })
@ -182,8 +181,13 @@ const hide = (id: string) => {
toggle(hidden.value, id) toggle(hidden.value, id)
} }
const hideAuthor = (url: string) => { const hideAuthor = (profile: string) => {
toggle(banned.value, url) toggle(hidden.value, profile)
}
const hideDomain = (profile: string) => {
var domain = profile.split("@").pop()
toggle(hidden.value, "@" + domain)
} }
const toggleTheme = () => { const toggleTheme = () => {
@ -227,9 +231,12 @@ const privacyLink = computed(() => {
<li><a class="dropdown-item" href="#" @click.prevent="pin(post.id)">{{ post.pinned ? "Unpin" : "Pin" <li><a class="dropdown-item" href="#" @click.prevent="pin(post.id)">{{ post.pinned ? "Unpin" : "Pin"
}}</a></li> }}</a></li>
<li><a class="dropdown-item" href="#" @click.prevent="hide(post.id)">Hide Post</a></li> <li><a class="dropdown-item" href="#" @click.prevent="hide(post.id)">Hide Post</a></li>
<li v-if="post.author?.url"><a class="dropdown-item" href="#" <li v-if="post.author?.profile"><a class="dropdown-item" href="#"
@click.prevent="hideAuthor(post.author?.url)">Hide @click.prevent="hideAuthor(post.author?.profile)">Hide
Author</a></li> Author</a></li>
<li v-if="post.author?.profile"><a class="dropdown-item" href="#"
@click.prevent="hideDomain(post.author?.profile)">Hide
Domain</a></li>
</ul> </ul>
</div> </div>
</template> </template>