Revert "fix(chat): 增加已退出群聊隐藏开关"

This commit is contained in:
xuncha
2026-03-15 18:58:41 +08:00
committed by GitHub
parent e9bc303e0e
commit 845d6b2e2c
2 changed files with 11 additions and 71 deletions

View File

@@ -304,12 +304,11 @@
}
}
.refresh-btn,
.session-filter-btn {
.refresh-btn {
width: 32px;
height: 32px;
padding: 0;
border: 1px solid transparent;
border: none;
background: var(--bg-tertiary);
border-radius: 8px;
color: var(--text-secondary);
@@ -325,12 +324,6 @@
color: var(--text-primary);
}
&.active {
background: var(--primary-light);
border-color: var(--primary-light);
color: var(--primary);
}
&:disabled {
opacity: 0.4;
cursor: not-allowed;
@@ -819,7 +812,7 @@
.icon-btn {
width: 32px;
height: 32px;
border: 1px solid transparent;
border: none;
background: transparent;
border-radius: 6px;
cursor: pointer;
@@ -842,20 +835,6 @@
}
}
.session-filter-btn {
background: var(--bg-primary);
&:hover {
background: var(--bg-hover);
}
&.active {
background: var(--primary-light);
border-color: var(--primary-light);
color: var(--primary);
}
}
.search-row {
flex: 1;
display: flex;

View File

@@ -1,5 +1,5 @@
import React, { useState, useEffect, useRef, useCallback, useMemo } from 'react'
import { Search, MessageSquare, MessageSquareOff, AlertCircle, Loader2, RefreshCw, X, ChevronDown, ChevronLeft, Info, Calendar, Database, Hash, Play, Pause, Image as ImageIcon, Link, Mic, CheckCircle, Copy, Check, CheckSquare, Download, BarChart3, Edit2, Trash2, BellOff, Users, FolderClosed, UserCheck, Crown, Aperture } from 'lucide-react'
import { Search, MessageSquare, AlertCircle, Loader2, RefreshCw, X, ChevronDown, ChevronLeft, Info, Calendar, Database, Hash, Play, Pause, Image as ImageIcon, Link, Mic, CheckCircle, Copy, Check, CheckSquare, Download, BarChart3, Edit2, Trash2, BellOff, Users, FolderClosed, UserCheck, Crown, Aperture } from 'lucide-react'
import { useNavigate } from 'react-router-dom'
import { createPortal } from 'react-dom'
import { useChatStore } from '../stores/chatStore'
@@ -34,16 +34,6 @@ const SYSTEM_MESSAGE_TYPES = [
266287972401, // 拍一拍
]
const EXITED_GROUP_SUMMARY_EXACT = '你已退出该群聊'
function isExitedGroupSession(session: Pick<ChatSession, 'username' | 'lastMsgType' | 'summary'>): boolean {
return (
session.username.endsWith('@chatroom') &&
session.lastMsgType === 10000 &&
session.summary.trim() === EXITED_GROUP_SUMMARY_EXACT
)
}
interface XmlField {
key: string;
value: string;
@@ -522,7 +512,6 @@ function ChatPage(props: ChatPageProps) {
const [groupMembersLoadingHint, setGroupMembersLoadingHint] = useState('')
const [isRefreshingGroupMembers, setIsRefreshingGroupMembers] = useState(false)
const [groupMemberSearchKeyword, setGroupMemberSearchKeyword] = useState('')
const [hideExitedGroups, setHideExitedGroups] = useState(true)
const [copiedField, setCopiedField] = useState<string | null>(null)
const [highlightedMessageKeys, setHighlightedMessageKeys] = useState<string[]>([])
const [isRefreshingSessions, setIsRefreshingSessions] = useState(false)
@@ -592,25 +581,6 @@ function ChatPage(props: ChatPageProps) {
const highlightedMessageSet = useMemo(() => new Set(highlightedMessageKeys), [highlightedMessageKeys])
const exitedGroupCount = useMemo(() => {
if (!Array.isArray(sessions)) return 0
return sessions.filter(isExitedGroupSession).length
}, [sessions])
const sessionsAfterExitedGroupFilter = useMemo(() => {
if (!Array.isArray(sessions)) return []
if (!hideExitedGroups) return sessions
return sessions.filter((session) => !isExitedGroupSession(session))
}, [sessions, hideExitedGroups])
const exitedGroupFilterTitle = useMemo(() => {
if (hideExitedGroups) {
return exitedGroupCount > 0
? `已隐藏 ${exitedGroupCount} 个已退出群聊,点击显示`
: '已开启:隐藏已退出群聊'
}
return exitedGroupCount > 0
? `当前显示全部群聊(含 ${exitedGroupCount} 个已退出群聊),点击隐藏`
: '当前显示全部群聊,点击隐藏已退出群聊'
}, [exitedGroupCount, hideExitedGroups])
const messageKeySetRef = useRef<Set<string>>(new Set())
const lastMessageTimeRef = useRef(0)
const sessionMapRef = useRef<Map<string, ChatSession>>(new Map())
@@ -2993,16 +2963,16 @@ function ChatPage(props: ChatPageProps) {
// 普通视图:隐藏 isFolded 的群,保留 placeholder_foldgroup 入口
useEffect(() => {
if (!Array.isArray(sessionsAfterExitedGroupFilter)) {
if (!Array.isArray(sessions)) {
setFilteredSessions([])
return
}
// 检查是否有折叠的群聊
const foldedGroups = sessionsAfterExitedGroupFilter.filter(s => s.isFolded && !s.username.toLowerCase().includes('placeholder_foldgroup'))
const foldedGroups = sessions.filter(s => s.isFolded && !s.username.toLowerCase().includes('placeholder_foldgroup'))
const hasFoldedGroups = foldedGroups.length > 0
let visible = sessionsAfterExitedGroupFilter.filter(s => {
let visible = sessions.filter(s => {
if (s.isFolded && !s.username.toLowerCase().includes('placeholder_foldgroup')) return false
return true
})
@@ -3052,12 +3022,12 @@ function ChatPage(props: ChatPageProps) {
s.username.toLowerCase().includes(lower) ||
s.summary.toLowerCase().includes(lower)
))
}, [sessionsAfterExitedGroupFilter, searchKeyword, setFilteredSessions])
}, [sessions, searchKeyword, setFilteredSessions])
// 折叠群列表(独立计算,供折叠 panel 使用)
const foldedSessions = useMemo(() => {
if (!Array.isArray(sessionsAfterExitedGroupFilter)) return []
const folded = sessionsAfterExitedGroupFilter.filter(s => s.isFolded)
if (!Array.isArray(sessions)) return []
const folded = sessions.filter(s => s.isFolded)
if (!searchKeyword.trim() || !foldedView) return folded
const lower = searchKeyword.toLowerCase()
return folded.filter(s =>
@@ -3065,7 +3035,7 @@ function ChatPage(props: ChatPageProps) {
s.username.toLowerCase().includes(lower) ||
s.summary.toLowerCase().includes(lower)
)
}, [sessionsAfterExitedGroupFilter, searchKeyword, foldedView])
}, [sessions, searchKeyword, foldedView])
const hasSessionRecords = Array.isArray(sessions) && sessions.length > 0
const shouldShowSessionsSkeleton = isLoadingSessions && !hasSessionRecords
@@ -3908,15 +3878,6 @@ function ChatPage(props: ChatPageProps) {
{/* 普通 header */}
<div className="session-header-panel main-header">
<div className="search-row">
<button
className={`icon-btn session-filter-btn ${hideExitedGroups ? 'active' : ''}`}
onClick={() => setHideExitedGroups((prev) => !prev)}
title={exitedGroupFilterTitle}
aria-label={hideExitedGroups ? '显示已退出群聊' : '隐藏已退出群聊'}
aria-pressed={hideExitedGroups}
>
<MessageSquareOff size={15} />
</button>
<div className="search-box expanded">
<Search size={14} />
<input