Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 | 27x 2x 10x 2x 14x 14x 2x 2x 7x 7x 7x 7x 7x 7x 7x 7x 8x 7x 7x 8x 8x 8x 7x 8x 8x 8x 1x 1x 8x 1x 2x 2x 2x 2x 1x 1x 2x 7x | <template>
<div class="blocked-users-list">
<p class="text-muted small mb-3">{{ t('messages.blockedListHint') }}</p>
<LoadingSpinner v-if="loading && users.length === 0" :grid="false" :padding="3" />
<EmptyState v-else-if="users.length === 0" variant="info" :grid="false">
{{ t('messages.noBlockedUsers') }}
</EmptyState>
<template v-else>
<ul class="list-unstyled mb-3">
<li v-for="user in users" :key="user.id" class="blocked-row">
<router-link
class="blocked-row-link"
:to="{ name: 'user-profile', params: { userId: user.id } }"
>
<UserAvatar :picture-key="user.profilePicture" class="blocked-row-avatar" />
<span class="blocked-row-name">{{ user.name }}</span>
<span v-if="user.nickname" class="blocked-row-nickname text-muted">
@{{ user.nickname }}
</span>
</router-link>
<button
type="button"
class="btn btn-outline-secondary btn-sm"
:disabled="unblockingId === user.id"
@click="unblock(user)"
>
<font-awesome-icon icon="fa-solid fa-user-check" class="me-1" />
{{ t('messages.unblock') }}
</button>
</li>
</ul>
<button
v-if="hasMore"
class="btn btn-outline-secondary btn-sm"
:disabled="loading"
@click="loadMore"
>
{{ t('common.loadMore') }}
</button>
</template>
</div>
</template>
<script setup lang="ts">
// @implements UC-DM-009.1
import { ref, onMounted } from 'vue'
import LoadingSpinner from '@/components/LoadingSpinner.vue'
import EmptyState from '@/components/EmptyState.vue'
import UserAvatar from '@/components/UserAvatar.vue'
import { useUILanguage } from '@/composables/useUILanguage'
import { useMessagesStore } from '@/stores/messages'
import { useToastStore } from '@/stores/toast'
import type { User } from '@/stores/users'
const { t } = useUILanguage()
const messagesStore = useMessagesStore()
const toastStore = useToastStore()
const users = ref<User[]>([])
const loading = ref(false)
const hasMore = ref(false)
const nextToken = ref<string | null>(null)
const unblockingId = ref<string | null>(null)
async function load(reset = true) {
if (reset) {
users.value = []
nextToken.value = null
}
loading.value = true
try {
const page = await messagesStore.fetchBlockedUsers({
...(nextToken.value ? { nextToken: nextToken.value } : {})
})
const items = page.items ?? []
users.value = reset ? items : [...users.value, ...items]
hasMore.value = page.hasMore ?? false
nextToken.value = page.nextToken ?? null
} catch (error) {
console.error('Failed to load blocked users:', error)
toastStore.error(t('messages.loadBlockedError'))
} finally {
loading.value = false
}
}
function loadMore() {
load(false)
}
// The row just goes away: the cursor is a user id, not an offset, so the
// next page is unaffected by removing one already shown.
async function unblock(user: User) {
unblockingId.value = user.id
try {
await messagesStore.unblockUser(user.id)
users.value = users.value.filter((u) => u.id !== user.id)
} catch (error) {
console.error('Failed to unblock user:', error)
toastStore.error(t('messages.blockError'))
} finally {
unblockingId.value = null
}
}
onMounted(() => load(true))
</script>
<style scoped>
.blocked-row {
display: flex;
align-items: center;
justify-content: space-between;
gap: 0.75rem;
border-bottom: 1px solid var(--bw-border);
}
.blocked-row-link {
display: flex;
align-items: center;
gap: 0.75rem;
min-width: 0;
padding: 0.5rem 0;
color: inherit;
text-decoration: none;
}
.blocked-row-nickname {
font-size: 0.875rem;
}
</style>
|