thread-view: восстановить MessageListItem со свайпами, раскрытие тредов
- Однопись тред → MessageListItem напрямую (внешний вид и свайпы как раньше) - Многописьменный тред → ThreadListItem-заголовок + разворачиваемые MessageListItem - Восстановлены: selectMode, bulk-actions, select-all-row - ThreadListItem: prop expanded, шеврон с анимацией поворота - Раскрытые дочерние письма визуально примыкают к заголовку треда (border-radius, indent) Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
18d059571d
commit
dd04f1f6bd
2 changed files with 138 additions and 36 deletions
|
|
@ -4,6 +4,7 @@ import { useMessagesStore } from '../../stores/messages.store'
|
||||||
import { useFoldersStore } from '../../stores/folders.store'
|
import { useFoldersStore } from '../../stores/folders.store'
|
||||||
import { useAccountsStore } from '../../stores/accounts.store'
|
import { useAccountsStore } from '../../stores/accounts.store'
|
||||||
import { useSettingsStore, type SwipeAction } from '../../stores/settings.store'
|
import { useSettingsStore, type SwipeAction } from '../../stores/settings.store'
|
||||||
|
import MessageListItem from './MessageListItem.vue'
|
||||||
import ThreadListItem from './ThreadListItem.vue'
|
import ThreadListItem from './ThreadListItem.vue'
|
||||||
import AppIcon from '../AppIcon.vue'
|
import AppIcon from '../AppIcon.vue'
|
||||||
import { buildThreads, type Thread } from '../../utils/threading'
|
import { buildThreads, type Thread } from '../../utils/threading'
|
||||||
|
|
@ -29,12 +30,24 @@ const allVisibleSelected = computed(() =>
|
||||||
// ── Threads ───────────────────────────────────────────────
|
// ── Threads ───────────────────────────────────────────────
|
||||||
const threads = computed<Thread[]>(() => buildThreads(messagesStore.filteredMessages))
|
const threads = computed<Thread[]>(() => buildThreads(messagesStore.filteredMessages))
|
||||||
|
|
||||||
const selectedThreadId = ref<string | null>(null)
|
const expandedThreadIds = ref(new Set<string>())
|
||||||
|
|
||||||
function selectThread(thread: Thread): void {
|
function toggleThread(thread: Thread): void {
|
||||||
selectedThreadId.value = thread.id
|
if (thread.messages.length === 1) {
|
||||||
|
// Один элемент — открываем напрямую
|
||||||
|
messagesStore.selectMessage(thread.messages[0].id)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if (expandedThreadIds.value.has(thread.id)) {
|
||||||
|
expandedThreadIds.value.delete(thread.id)
|
||||||
|
} else {
|
||||||
|
expandedThreadIds.value.add(thread.id)
|
||||||
|
// Открываем последнее письмо треда
|
||||||
messagesStore.selectMessage(thread.latest.id)
|
messagesStore.selectMessage(thread.latest.id)
|
||||||
}
|
}
|
||||||
|
// trigger reactivity
|
||||||
|
expandedThreadIds.value = new Set(expandedThreadIds.value)
|
||||||
|
}
|
||||||
|
|
||||||
// ── Refresh ───────────────────────────────────────────────
|
// ── Refresh ───────────────────────────────────────────────
|
||||||
async function refresh(): Promise<void> {
|
async function refresh(): Promise<void> {
|
||||||
|
|
@ -186,29 +199,6 @@ async function handleSwipeAction(action: SwipeAction, messageId: string): Promis
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- Панель действий при мультивыборе -->
|
|
||||||
<div v-if="selectMode && hasSelected" class="bulk-actions">
|
|
||||||
<span class="bulk-count">
|
|
||||||
<span class="bulk-count-num">{{ messagesStore.selectedIds.size }}</span>
|
|
||||||
выбрано
|
|
||||||
</span>
|
|
||||||
<div class="bulk-btns">
|
|
||||||
<button class="bulk-btn" @click="messagesStore.markSelectedAsRead()">
|
|
||||||
<AppIcon name="envelope" :size="12" />
|
|
||||||
<span>Прочитать</span>
|
|
||||||
</button>
|
|
||||||
<button class="bulk-btn" @click="messagesStore.flagSelected()">
|
|
||||||
<AppIcon name="flag" :size="12" />
|
|
||||||
<span>Флажок</span>
|
|
||||||
</button>
|
|
||||||
<button class="bulk-btn danger" @click="messagesStore.deleteSelected()">
|
|
||||||
<AppIcon name="trash" :size="12" />
|
|
||||||
<span>Удалить</span>
|
|
||||||
</button>
|
|
||||||
</div>
|
|
||||||
<button class="bulk-cancel" @click="exitSelectMode">Отмена</button>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<!-- Pull-to-refresh индикатор (всегда в DOM, высота = 0 в обычном состоянии) -->
|
<!-- Pull-to-refresh индикатор (всегда в DOM, высота = 0 в обычном состоянии) -->
|
||||||
<div
|
<div
|
||||||
class="pull-indicator-wrap"
|
class="pull-indicator-wrap"
|
||||||
|
|
@ -250,16 +240,87 @@ async function handleSwipeAction(action: SwipeAction, messageId: string): Promis
|
||||||
<span>{{ messagesStore.unreadOnly ? 'Нет непрочитанных писем' : 'В папке нет писем' }}</span>
|
<span>{{ messagesStore.unreadOnly ? 'Нет непрочитанных писем' : 'В папке нет писем' }}</span>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<!-- Панель действий при мультивыборе -->
|
||||||
|
<div v-if="selectMode && hasSelected" class="bulk-actions">
|
||||||
|
<span class="bulk-count">
|
||||||
|
<span class="bulk-count-num">{{ messagesStore.selectedIds.size }}</span>
|
||||||
|
выбрано
|
||||||
|
</span>
|
||||||
|
<div class="bulk-btns">
|
||||||
|
<button class="bulk-btn" @click="messagesStore.markSelectedAsRead()">
|
||||||
|
<AppIcon name="envelope" :size="12" />
|
||||||
|
<span>Прочитать</span>
|
||||||
|
</button>
|
||||||
|
<button class="bulk-btn" @click="messagesStore.flagSelected()">
|
||||||
|
<AppIcon name="flag" :size="12" />
|
||||||
|
<span>Флажок</span>
|
||||||
|
</button>
|
||||||
|
<button class="bulk-btn danger" @click="messagesStore.deleteSelected()">
|
||||||
|
<AppIcon name="trash" :size="12" />
|
||||||
|
<span>Удалить</span>
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
<button class="bulk-cancel" @click="exitSelectMode">Отмена</button>
|
||||||
|
</div>
|
||||||
|
|
||||||
<!-- Список тредов -->
|
<!-- Список тредов -->
|
||||||
<div v-else class="message-list" @scroll="onScroll" @wheel="onWheel">
|
<div v-else class="message-list" @scroll="onScroll" @wheel="onWheel">
|
||||||
<ThreadListItem
|
<!-- Строка "выбрать все" — только в режиме выбора -->
|
||||||
v-for="thread in threads"
|
<div v-if="selectMode" class="select-all-row" @click="toggleSelectAll">
|
||||||
:key="thread.id"
|
<span
|
||||||
:thread="thread"
|
class="select-all-circle"
|
||||||
:selected="selectedThreadId === thread.id"
|
:class="{ checked: allVisibleSelected, indeterminate: hasSelected && !allVisibleSelected }"
|
||||||
@click="selectThread(thread)"
|
>
|
||||||
|
<svg v-if="allVisibleSelected" viewBox="0 0 16 16" width="10" height="10" fill="none">
|
||||||
|
<polyline points="3,8 6.5,12 13,4" stroke="#fff" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/>
|
||||||
|
</svg>
|
||||||
|
<span v-else-if="hasSelected && !allVisibleSelected" class="indeterminate-dash" />
|
||||||
|
</span>
|
||||||
|
<span class="select-all-text">Выбрать все</span>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<template v-for="thread in threads" :key="thread.id">
|
||||||
|
<!-- Одно письмо в треде — показываем MessageListItem напрямую -->
|
||||||
|
<MessageListItem
|
||||||
|
v-if="thread.messages.length === 1"
|
||||||
|
:message="thread.messages[0]"
|
||||||
|
:selected="messagesStore.selectedMessageId === thread.messages[0].id"
|
||||||
|
:checked="messagesStore.selectedIds.has(thread.messages[0].id)"
|
||||||
|
:select-mode="selectMode"
|
||||||
|
:swipe-left-action="settingsStore.swipeLeftAction"
|
||||||
|
:swipe-right-action="settingsStore.swipeRightAction"
|
||||||
|
@click="messagesStore.selectMessage(thread.messages[0].id)"
|
||||||
|
@toggle-select="messagesStore.toggleSelect(thread.messages[0].id)"
|
||||||
|
@swipe-action="(action) => handleSwipeAction(action, thread.messages[0].id)"
|
||||||
/>
|
/>
|
||||||
|
|
||||||
|
<!-- Несколько писем — заголовок треда + раскрываемые сообщения -->
|
||||||
|
<template v-else>
|
||||||
|
<ThreadListItem
|
||||||
|
:thread="thread"
|
||||||
|
:expanded="expandedThreadIds.has(thread.id)"
|
||||||
|
:selected="thread.messages.some(m => messagesStore.selectedMessageId === m.id)"
|
||||||
|
@click="toggleThread(thread)"
|
||||||
|
/>
|
||||||
|
<template v-if="expandedThreadIds.has(thread.id)">
|
||||||
|
<MessageListItem
|
||||||
|
v-for="msg in thread.messages"
|
||||||
|
:key="msg.id"
|
||||||
|
:message="msg"
|
||||||
|
:selected="messagesStore.selectedMessageId === msg.id"
|
||||||
|
:checked="messagesStore.selectedIds.has(msg.id)"
|
||||||
|
:select-mode="selectMode"
|
||||||
|
:swipe-left-action="settingsStore.swipeLeftAction"
|
||||||
|
:swipe-right-action="settingsStore.swipeRightAction"
|
||||||
|
class="thread-child-item"
|
||||||
|
@click="messagesStore.selectMessage(msg.id)"
|
||||||
|
@toggle-select="messagesStore.toggleSelect(msg.id)"
|
||||||
|
@swipe-action="(action) => handleSwipeAction(action, msg.id)"
|
||||||
|
/>
|
||||||
|
</template>
|
||||||
|
</template>
|
||||||
|
</template>
|
||||||
|
|
||||||
<div v-if="messagesStore.loading" class="loading-more">
|
<div v-if="messagesStore.loading" class="loading-more">
|
||||||
<div class="spinner-sm" /> Загрузка...
|
<div class="spinner-sm" /> Загрузка...
|
||||||
</div>
|
</div>
|
||||||
|
|
@ -686,4 +747,17 @@ async function handleSwipeAction(action: SwipeAction, messageId: string): Promis
|
||||||
@keyframes spin {
|
@keyframes spin {
|
||||||
to { transform: rotate(360deg); }
|
to { transform: rotate(360deg); }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Дочерние письма раскрытого треда */
|
||||||
|
:deep(.thread-child-item) {
|
||||||
|
margin-left: 12px;
|
||||||
|
margin-top: 0;
|
||||||
|
border-radius: 0;
|
||||||
|
border-top-color: transparent;
|
||||||
|
}
|
||||||
|
|
||||||
|
:deep(.thread-child-item:last-child) {
|
||||||
|
border-bottom-left-radius: 10px;
|
||||||
|
border-bottom-right-radius: 10px;
|
||||||
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|
|
||||||
|
|
@ -7,6 +7,7 @@ import AppIcon from '../AppIcon.vue'
|
||||||
const props = defineProps<{
|
const props = defineProps<{
|
||||||
thread: Thread
|
thread: Thread
|
||||||
selected: boolean
|
selected: boolean
|
||||||
|
expanded?: boolean
|
||||||
}>()
|
}>()
|
||||||
|
|
||||||
defineEmits<{ click: [] }>()
|
defineEmits<{ click: [] }>()
|
||||||
|
|
@ -32,7 +33,7 @@ const snippet = computed(() => props.thread.latest.snippet || '')
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<div class="thread-card" :class="{ selected, unread: isUnread }">
|
<div class="thread-card" :class="{ selected, unread: isUnread, expanded }">
|
||||||
<div
|
<div
|
||||||
class="thread-item"
|
class="thread-item"
|
||||||
:class="{ selected, unread: isUnread }"
|
:class="{ selected, unread: isUnread }"
|
||||||
|
|
@ -56,7 +57,7 @@ const snippet = computed(() => props.thread.latest.snippet || '')
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- Строка 2: тема + счётчик -->
|
<!-- Строка 2: тема + счётчик + шеврон раскрытия -->
|
||||||
<div class="thread-row2">
|
<div class="thread-row2">
|
||||||
<span class="thread-subject truncate" :class="{ bold: isUnread }">
|
<span class="thread-subject truncate" :class="{ bold: isUnread }">
|
||||||
{{ normalizedSubject }}
|
{{ normalizedSubject }}
|
||||||
|
|
@ -64,6 +65,15 @@ const snippet = computed(() => props.thread.latest.snippet || '')
|
||||||
<span v-if="thread.messages.length > 1" class="thread-count">
|
<span v-if="thread.messages.length > 1" class="thread-count">
|
||||||
{{ thread.messages.length }}
|
{{ thread.messages.length }}
|
||||||
</span>
|
</span>
|
||||||
|
<svg
|
||||||
|
class="thread-chevron"
|
||||||
|
:class="{ open: expanded }"
|
||||||
|
width="10" height="10" viewBox="0 0 24 24"
|
||||||
|
fill="none" stroke="currentColor" stroke-width="2.5"
|
||||||
|
stroke-linecap="round" stroke-linejoin="round"
|
||||||
|
>
|
||||||
|
<polyline points="6 9 12 15 18 9"/>
|
||||||
|
</svg>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- Строка 3: сниппет последнего письма -->
|
<!-- Строка 3: сниппет последнего письма -->
|
||||||
|
|
@ -254,4 +264,22 @@ const snippet = computed(() => props.thread.latest.snippet || '')
|
||||||
color: var(--text-muted);
|
color: var(--text-muted);
|
||||||
line-height: 1.4;
|
line-height: 1.4;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.thread-chevron {
|
||||||
|
flex-shrink: 0;
|
||||||
|
color: var(--text-muted);
|
||||||
|
transition: transform var(--transition-fast), color var(--transition-fast);
|
||||||
|
}
|
||||||
|
|
||||||
|
.thread-chevron.open {
|
||||||
|
transform: rotate(180deg);
|
||||||
|
color: var(--accent);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Раскрытый тред — убираем нижний border-radius чтобы слиться с дочерними письмами */
|
||||||
|
.thread-card.expanded {
|
||||||
|
border-bottom-left-radius: 0;
|
||||||
|
border-bottom-right-radius: 0;
|
||||||
|
border-bottom-color: transparent;
|
||||||
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue