mirror of
https://github.com/hicccc77/WeFlow.git
synced 2026-03-24 23:06:51 +00:00
Revert "fix: 修复朋友圈仅看自己和导出自己"
This commit is contained in:
@@ -8,7 +8,6 @@ interface Contact {
|
|||||||
avatarUrl?: string
|
avatarUrl?: string
|
||||||
postCount?: number
|
postCount?: number
|
||||||
postCountStatus?: 'idle' | 'loading' | 'ready'
|
postCountStatus?: 'idle' | 'loading' | 'ready'
|
||||||
isCurrentUser?: boolean
|
|
||||||
}
|
}
|
||||||
|
|
||||||
interface ContactsCountProgress {
|
interface ContactsCountProgress {
|
||||||
@@ -69,7 +68,7 @@ export const SnsFilterPanel: React.FC<SnsFilterPanelProps> = ({
|
|||||||
return '正在加载联系人...'
|
return '正在加载联系人...'
|
||||||
}
|
}
|
||||||
if (contacts.length === 0) {
|
if (contacts.length === 0) {
|
||||||
return '暂无可筛选联系人'
|
return '暂无好友或曾经的好友'
|
||||||
}
|
}
|
||||||
return '没有找到联系人'
|
return '没有找到联系人'
|
||||||
}
|
}
|
||||||
@@ -119,7 +118,7 @@ export const SnsFilterPanel: React.FC<SnsFilterPanelProps> = ({
|
|||||||
<div className="contact-search-bar">
|
<div className="contact-search-bar">
|
||||||
<input
|
<input
|
||||||
type="text"
|
type="text"
|
||||||
placeholder="查找联系人..."
|
placeholder="查找好友..."
|
||||||
value={contactSearch}
|
value={contactSearch}
|
||||||
onChange={e => setContactSearch(e.target.value)}
|
onChange={e => setContactSearch(e.target.value)}
|
||||||
/>
|
/>
|
||||||
@@ -144,26 +143,18 @@ export const SnsFilterPanel: React.FC<SnsFilterPanelProps> = ({
|
|||||||
<div className="contact-list-scroll">
|
<div className="contact-list-scroll">
|
||||||
{filteredContacts.map(contact => {
|
{filteredContacts.map(contact => {
|
||||||
const isPostCountReady = contact.postCountStatus === 'ready'
|
const isPostCountReady = contact.postCountStatus === 'ready'
|
||||||
const isPostCountLoading = contact.postCountStatus === 'loading'
|
|
||||||
const isSelected = selectedContactLookup.has(contact.username)
|
const isSelected = selectedContactLookup.has(contact.username)
|
||||||
const isActive = activeContactUsername === contact.username
|
const isActive = activeContactUsername === contact.username
|
||||||
const displayName = contact.displayName || (contact.isCurrentUser ? '我' : contact.username)
|
|
||||||
const selectTitle = contact.isCurrentUser
|
|
||||||
? (isSelected ? '取消选择当前账号的朋友圈' : '选择当前账号的朋友圈')
|
|
||||||
: (isSelected ? `取消选择 ${displayName}` : `选择 ${displayName}`)
|
|
||||||
const openTitle = contact.isCurrentUser
|
|
||||||
? '查看我发的朋友圈'
|
|
||||||
: `查看 ${displayName} 的朋友圈`
|
|
||||||
return (
|
return (
|
||||||
<div
|
<div
|
||||||
key={contact.username}
|
key={contact.username}
|
||||||
className={`contact-row${isSelected ? ' is-selected' : ''}${isActive ? ' is-active' : ''}${contact.isCurrentUser ? ' is-current-user' : ''}`}
|
className={`contact-row${isSelected ? ' is-selected' : ''}${isActive ? ' is-active' : ''}`}
|
||||||
>
|
>
|
||||||
<button
|
<button
|
||||||
type="button"
|
type="button"
|
||||||
className={`contact-select-btn${isSelected ? ' checked' : ''}`}
|
className={`contact-select-btn${isSelected ? ' checked' : ''}`}
|
||||||
onClick={() => onToggleContactSelected(contact)}
|
onClick={() => onToggleContactSelected(contact)}
|
||||||
title={selectTitle}
|
title={isSelected ? `取消选择 ${contact.displayName}` : `选择 ${contact.displayName}`}
|
||||||
aria-pressed={isSelected}
|
aria-pressed={isSelected}
|
||||||
>
|
>
|
||||||
{isSelected ? <CheckSquare size={16} /> : <Square size={16} />}
|
{isSelected ? <CheckSquare size={16} /> : <Square size={16} />}
|
||||||
@@ -172,29 +163,19 @@ export const SnsFilterPanel: React.FC<SnsFilterPanelProps> = ({
|
|||||||
type="button"
|
type="button"
|
||||||
className="contact-main-btn"
|
className="contact-main-btn"
|
||||||
onClick={() => onOpenContactTimeline(contact)}
|
onClick={() => onOpenContactTimeline(contact)}
|
||||||
title={openTitle}
|
title={`查看 ${contact.displayName} 的朋友圈`}
|
||||||
>
|
>
|
||||||
<Avatar src={contact.avatarUrl} name={displayName} size={36} shape="rounded" />
|
<Avatar src={contact.avatarUrl} name={contact.displayName} size={36} shape="rounded" />
|
||||||
<div className="contact-meta">
|
<div className="contact-meta">
|
||||||
<span className="contact-name-row">
|
<span className="contact-name">{contact.displayName}</span>
|
||||||
<span className="contact-name">{displayName}</span>
|
|
||||||
{contact.isCurrentUser && <span className="contact-self-badge">当前账号</span>}
|
|
||||||
</span>
|
|
||||||
{contact.isCurrentUser && (
|
|
||||||
<span className="contact-subtitle">{contact.username}</span>
|
|
||||||
)}
|
|
||||||
</div>
|
</div>
|
||||||
<div className="contact-post-count-wrap">
|
<div className="contact-post-count-wrap">
|
||||||
{isPostCountReady ? (
|
{isPostCountReady ? (
|
||||||
<span className="contact-post-count">{Math.max(0, Math.floor(Number(contact.postCount || 0)))}条</span>
|
<span className="contact-post-count">{Math.max(0, Math.floor(Number(contact.postCount || 0)))}条</span>
|
||||||
) : isPostCountLoading ? (
|
) : (
|
||||||
<span className="contact-post-count-loading" title="统计中">
|
<span className="contact-post-count-loading" title="统计中">
|
||||||
<Loader2 size={13} className="spinning" />
|
<Loader2 size={13} className="spinning" />
|
||||||
</span>
|
</span>
|
||||||
) : (
|
|
||||||
<span className="contact-post-count is-empty" title="暂无统计">
|
|
||||||
--
|
|
||||||
</span>
|
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
</button>
|
</button>
|
||||||
|
|||||||
@@ -1295,26 +1295,6 @@
|
|||||||
color: var(--text-primary);
|
color: var(--text-primary);
|
||||||
}
|
}
|
||||||
|
|
||||||
&.is-current-user .contact-main-btn {
|
|
||||||
background: color-mix(in srgb, var(--primary) 6%, var(--bg-primary));
|
|
||||||
border-color: color-mix(in srgb, var(--primary) 18%, var(--border-color));
|
|
||||||
}
|
|
||||||
|
|
||||||
&.is-current-user.is-selected .contact-main-btn {
|
|
||||||
background: rgba(var(--primary-rgb), 0.1);
|
|
||||||
border-color: color-mix(in srgb, var(--primary) 30%, var(--border-color));
|
|
||||||
}
|
|
||||||
|
|
||||||
&.is-current-user.is-active .contact-main-btn {
|
|
||||||
background: rgba(var(--primary-rgb), 0.15);
|
|
||||||
border-color: color-mix(in srgb, var(--primary) 54%, var(--border-color));
|
|
||||||
}
|
|
||||||
|
|
||||||
&.is-current-user .contact-name {
|
|
||||||
color: var(--text-primary);
|
|
||||||
font-weight: 600;
|
|
||||||
}
|
|
||||||
|
|
||||||
.contact-select-btn {
|
.contact-select-btn {
|
||||||
width: 32px;
|
width: 32px;
|
||||||
height: 32px;
|
height: 32px;
|
||||||
@@ -1334,11 +1314,6 @@
|
|||||||
color: var(--primary);
|
color: var(--primary);
|
||||||
}
|
}
|
||||||
|
|
||||||
&:focus-visible {
|
|
||||||
outline: 2px solid color-mix(in srgb, var(--primary) 72%, transparent);
|
|
||||||
outline-offset: 2px;
|
|
||||||
}
|
|
||||||
|
|
||||||
&.checked {
|
&.checked {
|
||||||
color: var(--primary);
|
color: var(--primary);
|
||||||
}
|
}
|
||||||
@@ -1361,11 +1336,6 @@
|
|||||||
&:hover {
|
&:hover {
|
||||||
background: var(--hover-bg);
|
background: var(--hover-bg);
|
||||||
}
|
}
|
||||||
|
|
||||||
&:focus-visible {
|
|
||||||
outline: 2px solid color-mix(in srgb, var(--primary) 72%, transparent);
|
|
||||||
outline-offset: 2px;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.contact-meta {
|
.contact-meta {
|
||||||
@@ -1373,49 +1343,15 @@
|
|||||||
min-width: 0;
|
min-width: 0;
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
gap: 4px;
|
gap: 2px;
|
||||||
|
|
||||||
.contact-name-row {
|
|
||||||
display: flex;
|
|
||||||
align-items: center;
|
|
||||||
gap: 6px;
|
|
||||||
min-width: 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
.contact-name {
|
.contact-name {
|
||||||
display: block;
|
|
||||||
flex: 1 1 auto;
|
|
||||||
min-width: 0;
|
|
||||||
font-size: 14px;
|
font-size: 14px;
|
||||||
color: var(--text-secondary);
|
color: var(--text-secondary);
|
||||||
white-space: nowrap;
|
white-space: nowrap;
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
text-overflow: ellipsis;
|
text-overflow: ellipsis;
|
||||||
}
|
}
|
||||||
|
|
||||||
.contact-self-badge {
|
|
||||||
flex-shrink: 0;
|
|
||||||
display: inline-flex;
|
|
||||||
align-items: center;
|
|
||||||
justify-content: center;
|
|
||||||
min-height: 18px;
|
|
||||||
padding: 0 8px;
|
|
||||||
border-radius: 999px;
|
|
||||||
font-size: 10px;
|
|
||||||
font-weight: 700;
|
|
||||||
letter-spacing: 0.02em;
|
|
||||||
color: var(--primary);
|
|
||||||
background: rgba(var(--primary-rgb), 0.12);
|
|
||||||
border: 1px solid rgba(var(--primary-rgb), 0.18);
|
|
||||||
}
|
|
||||||
|
|
||||||
.contact-subtitle {
|
|
||||||
font-size: 11px;
|
|
||||||
color: var(--text-tertiary);
|
|
||||||
white-space: nowrap;
|
|
||||||
overflow: hidden;
|
|
||||||
text-overflow: ellipsis;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.contact-post-count-wrap {
|
.contact-post-count-wrap {
|
||||||
@@ -1432,10 +1368,6 @@
|
|||||||
color: var(--text-tertiary);
|
color: var(--text-tertiary);
|
||||||
font-variant-numeric: tabular-nums;
|
font-variant-numeric: tabular-nums;
|
||||||
white-space: nowrap;
|
white-space: nowrap;
|
||||||
|
|
||||||
&.is-empty {
|
|
||||||
letter-spacing: 0.08em;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.contact-post-count-loading {
|
.contact-post-count-loading {
|
||||||
@@ -1819,9 +1751,8 @@
|
|||||||
background: var(--bg-secondary);
|
background: var(--bg-secondary);
|
||||||
border-radius: var(--sns-border-radius-lg);
|
border-radius: var(--sns-border-radius-lg);
|
||||||
box-shadow: 0 12px 40px rgba(0, 0, 0, 0.18);
|
box-shadow: 0 12px 40px rgba(0, 0, 0, 0.18);
|
||||||
width: 460px;
|
width: 480px;
|
||||||
max-width: 92vw;
|
max-width: 92vw;
|
||||||
max-height: calc(100vh - 48px);
|
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
border: 1px solid var(--border-color);
|
border: 1px solid var(--border-color);
|
||||||
@@ -1829,7 +1760,7 @@
|
|||||||
animation: slide-up-fade 0.3s cubic-bezier(0.16, 1, 0.3, 1);
|
animation: slide-up-fade 0.3s cubic-bezier(0.16, 1, 0.3, 1);
|
||||||
|
|
||||||
.export-dialog-header {
|
.export-dialog-header {
|
||||||
padding: 14px 18px;
|
padding: 16px 20px;
|
||||||
border-bottom: 1px solid var(--border-color);
|
border-bottom: 1px solid var(--border-color);
|
||||||
background: var(--bg-tertiary);
|
background: var(--bg-tertiary);
|
||||||
display: flex;
|
display: flex;
|
||||||
@@ -1865,13 +1796,10 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
.export-dialog-body {
|
.export-dialog-body {
|
||||||
padding: 16px 18px 18px;
|
padding: 20px;
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
gap: 14px;
|
gap: 18px;
|
||||||
min-height: 0;
|
|
||||||
overflow-y: auto;
|
|
||||||
overscroll-behavior: contain;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1880,7 +1808,7 @@
|
|||||||
align-items: center;
|
align-items: center;
|
||||||
gap: 8px;
|
gap: 8px;
|
||||||
flex-wrap: wrap;
|
flex-wrap: wrap;
|
||||||
padding: 8px 12px;
|
padding: 10px 14px;
|
||||||
background: var(--bg-tertiary);
|
background: var(--bg-tertiary);
|
||||||
border-radius: 8px;
|
border-radius: 8px;
|
||||||
border: 1px solid var(--border-color);
|
border: 1px solid var(--border-color);
|
||||||
@@ -1895,10 +1823,10 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
.filter-tag {
|
.filter-tag {
|
||||||
font-size: 12px;
|
font-size: 13px;
|
||||||
color: var(--text-secondary);
|
color: var(--text-secondary);
|
||||||
background: var(--bg-primary);
|
background: var(--bg-primary);
|
||||||
padding: 2px 8px;
|
padding: 2px 10px;
|
||||||
border-radius: 6px;
|
border-radius: 6px;
|
||||||
border: 1px solid var(--border-color);
|
border: 1px solid var(--border-color);
|
||||||
display: flex;
|
display: flex;
|
||||||
@@ -1920,7 +1848,7 @@
|
|||||||
.export-section {
|
.export-section {
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
gap: 6px;
|
gap: 8px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.export-section-header {
|
.export-section-header {
|
||||||
@@ -1965,14 +1893,14 @@
|
|||||||
.export-format-options {
|
.export-format-options {
|
||||||
display: grid;
|
display: grid;
|
||||||
grid-template-columns: 1fr 1fr;
|
grid-template-columns: 1fr 1fr;
|
||||||
gap: 8px;
|
gap: 10px;
|
||||||
|
|
||||||
.format-option {
|
.format-option {
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
gap: 4px;
|
gap: 4px;
|
||||||
padding: 12px 8px;
|
padding: 14px 10px;
|
||||||
border-radius: 10px;
|
border-radius: 10px;
|
||||||
border: 2px solid var(--border-color);
|
border: 2px solid var(--border-color);
|
||||||
background: var(--bg-primary);
|
background: var(--bg-primary);
|
||||||
@@ -2496,7 +2424,7 @@
|
|||||||
.export-media-check-grid {
|
.export-media-check-grid {
|
||||||
display: grid;
|
display: grid;
|
||||||
grid-template-columns: repeat(auto-fit, minmax(110px, 1fr));
|
grid-template-columns: repeat(auto-fit, minmax(110px, 1fr));
|
||||||
gap: 6px;
|
gap: 8px;
|
||||||
|
|
||||||
label {
|
label {
|
||||||
display: inline-flex;
|
display: inline-flex;
|
||||||
@@ -2504,7 +2432,7 @@
|
|||||||
gap: 6px;
|
gap: 6px;
|
||||||
font-size: 13px;
|
font-size: 13px;
|
||||||
color: var(--text-primary);
|
color: var(--text-primary);
|
||||||
padding: 7px 9px;
|
padding: 8px 10px;
|
||||||
border: 1px solid var(--border-color);
|
border: 1px solid var(--border-color);
|
||||||
border-radius: 8px;
|
border-radius: 8px;
|
||||||
background: var(--bg-secondary);
|
background: var(--bg-secondary);
|
||||||
@@ -2622,10 +2550,10 @@
|
|||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
gap: 8px;
|
gap: 8px;
|
||||||
padding: 8px 10px;
|
padding: 10px 12px;
|
||||||
background: var(--bg-secondary);
|
background: var(--bg-secondary);
|
||||||
border-radius: 8px;
|
border-radius: 8px;
|
||||||
margin: 4px 0;
|
margin: 8px 0;
|
||||||
color: var(--text-tertiary);
|
color: var(--text-tertiary);
|
||||||
font-size: 12px;
|
font-size: 12px;
|
||||||
border: 1px dashed var(--border-color);
|
border: 1px dashed var(--border-color);
|
||||||
@@ -2638,8 +2566,8 @@
|
|||||||
|
|
||||||
.export-actions {
|
.export-actions {
|
||||||
display: flex;
|
display: flex;
|
||||||
gap: 10px;
|
gap: 12px;
|
||||||
margin-top: 14px;
|
margin-top: 24px;
|
||||||
|
|
||||||
button {
|
button {
|
||||||
flex: 1;
|
flex: 1;
|
||||||
|
|||||||
@@ -39,7 +39,6 @@ interface Contact {
|
|||||||
lastSessionTimestamp?: number
|
lastSessionTimestamp?: number
|
||||||
postCount?: number
|
postCount?: number
|
||||||
postCountStatus?: ContactPostCountStatus
|
postCountStatus?: ContactPostCountStatus
|
||||||
isCurrentUser?: boolean
|
|
||||||
}
|
}
|
||||||
|
|
||||||
interface SidebarUserProfile {
|
interface SidebarUserProfile {
|
||||||
@@ -194,15 +193,11 @@ export default function SnsPage() {
|
|||||||
}, [contacts])
|
}, [contacts])
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const contactLookup = new Set(contacts.map((contact) => contact.username))
|
const contactLookup = new Set(contacts.map((contact) => contact.username))
|
||||||
const currentUserUsername = normalizeAccountId(currentUserProfile.wxid)
|
|
||||||
if (currentUserUsername) {
|
|
||||||
contactLookup.add(currentUserUsername)
|
|
||||||
}
|
|
||||||
setSelectedContactUsernames((prev) => {
|
setSelectedContactUsernames((prev) => {
|
||||||
const next = prev.filter((username) => contactLookup.has(username))
|
const next = prev.filter((username) => contactLookup.has(username))
|
||||||
return next.length === prev.length ? prev : next
|
return next.length === prev.length ? prev : next
|
||||||
})
|
})
|
||||||
}, [contacts, currentUserProfile.wxid])
|
}, [contacts])
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
overviewStatsRef.current = overviewStats
|
overviewStatsRef.current = overviewStats
|
||||||
}, [overviewStats])
|
}, [overviewStats])
|
||||||
@@ -390,88 +385,27 @@ export default function SnsPage() {
|
|||||||
}) || null
|
}) || null
|
||||||
}, [contacts, currentUserProfile.alias, currentUserProfile.displayName, currentUserProfile.wxid])
|
}, [contacts, currentUserProfile.alias, currentUserProfile.displayName, currentUserProfile.wxid])
|
||||||
|
|
||||||
const currentUserFilterContact = useMemo<Contact | null>(() => {
|
|
||||||
const normalizedWxid = normalizeAccountId(currentUserProfile.wxid)
|
|
||||||
const fallbackDisplayName = String(
|
|
||||||
resolvedCurrentUserContact?.displayName
|
|
||||||
|| currentUserProfile.displayName
|
|
||||||
|| '我'
|
|
||||||
).trim()
|
|
||||||
const fallbackAvatarUrl = resolvedCurrentUserContact?.avatarUrl || currentUserProfile.avatarUrl
|
|
||||||
const fallbackPostCount = typeof resolvedCurrentUserContact?.postCount === 'number'
|
|
||||||
? normalizePostCount(resolvedCurrentUserContact.postCount)
|
|
||||||
: (typeof overviewStats.myPosts === 'number' && Number.isFinite(overviewStats.myPosts)
|
|
||||||
? Math.max(0, Math.floor(overviewStats.myPosts))
|
|
||||||
: undefined)
|
|
||||||
const fallbackPostStatus: ContactPostCountStatus = resolvedCurrentUserContact
|
|
||||||
? (resolvedCurrentUserContact.postCountStatus || (fallbackPostCount !== undefined ? 'ready' : 'idle'))
|
|
||||||
: (fallbackPostCount !== undefined
|
|
||||||
? 'ready'
|
|
||||||
: (contactsLoading || overviewStatsStatus === 'loading' ? 'loading' : 'idle'))
|
|
||||||
|
|
||||||
if (resolvedCurrentUserContact) {
|
|
||||||
return {
|
|
||||||
...resolvedCurrentUserContact,
|
|
||||||
displayName: resolvedCurrentUserContact.displayName || fallbackDisplayName,
|
|
||||||
avatarUrl: resolvedCurrentUserContact.avatarUrl || fallbackAvatarUrl,
|
|
||||||
postCount: typeof resolvedCurrentUserContact.postCount === 'number'
|
|
||||||
? normalizePostCount(resolvedCurrentUserContact.postCount)
|
|
||||||
: fallbackPostCount,
|
|
||||||
postCountStatus: resolvedCurrentUserContact.postCountStatus || fallbackPostStatus,
|
|
||||||
isCurrentUser: true
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!normalizedWxid) return null
|
|
||||||
|
|
||||||
return {
|
|
||||||
username: normalizedWxid,
|
|
||||||
displayName: fallbackDisplayName || normalizedWxid,
|
|
||||||
avatarUrl: fallbackAvatarUrl,
|
|
||||||
type: 'sns_only',
|
|
||||||
postCount: fallbackPostCount,
|
|
||||||
postCountStatus: fallbackPostStatus,
|
|
||||||
isCurrentUser: true
|
|
||||||
}
|
|
||||||
}, [
|
|
||||||
contactsLoading,
|
|
||||||
currentUserProfile.avatarUrl,
|
|
||||||
currentUserProfile.displayName,
|
|
||||||
currentUserProfile.wxid,
|
|
||||||
normalizePostCount,
|
|
||||||
overviewStats.myPosts,
|
|
||||||
overviewStatsStatus,
|
|
||||||
resolvedCurrentUserContact
|
|
||||||
])
|
|
||||||
|
|
||||||
const filterableContacts = useMemo(() => {
|
|
||||||
if (!currentUserFilterContact) return contacts
|
|
||||||
const currentUserKey = normalizeAccountId(currentUserFilterContact.username)
|
|
||||||
const otherContacts = contacts.filter((contact) => normalizeAccountId(contact.username) !== currentUserKey)
|
|
||||||
return [currentUserFilterContact, ...otherContacts]
|
|
||||||
}, [contacts, currentUserFilterContact])
|
|
||||||
|
|
||||||
const currentTimelineTargetContact = useMemo(() => {
|
const currentTimelineTargetContact = useMemo(() => {
|
||||||
const normalizedTargetUsername = String(authorTimelineTarget?.username || '').trim()
|
const normalizedTargetUsername = String(authorTimelineTarget?.username || '').trim()
|
||||||
if (!normalizedTargetUsername) return null
|
if (!normalizedTargetUsername) return null
|
||||||
return filterableContacts.find((contact) => contact.username === normalizedTargetUsername) || null
|
return contacts.find((contact) => contact.username === normalizedTargetUsername) || null
|
||||||
}, [authorTimelineTarget, filterableContacts])
|
}, [authorTimelineTarget, contacts])
|
||||||
|
|
||||||
const exportSelectedContactsSummary = useMemo(() => {
|
const exportSelectedContactsSummary = useMemo(() => {
|
||||||
if (exportScope.kind !== 'selected' || exportScope.usernames.length === 0) return ''
|
if (exportScope.kind !== 'selected' || exportScope.usernames.length === 0) return ''
|
||||||
const contactMap = new Map(filterableContacts.map((contact) => [contact.username, contact]))
|
const contactMap = new Map(contacts.map((contact) => [contact.username, contact]))
|
||||||
const names = exportScope.usernames.map((username) => contactMap.get(username)?.displayName || username)
|
const names = exportScope.usernames.map((username) => contactMap.get(username)?.displayName || username)
|
||||||
if (names.length <= 2) return names.join('、')
|
if (names.length <= 2) return names.join('、')
|
||||||
return `${names.slice(0, 2).join('、')} 等 ${names.length} 位联系人`
|
return `${names.slice(0, 2).join('、')} 等 ${names.length} 位联系人`
|
||||||
}, [exportScope, filterableContacts])
|
}, [contacts, exportScope])
|
||||||
|
|
||||||
const selectedFeedContactsSummary = useMemo(() => {
|
const selectedFeedContactsSummary = useMemo(() => {
|
||||||
if (selectedContactUsernames.length === 0) return ''
|
if (selectedContactUsernames.length === 0) return ''
|
||||||
const contactMap = new Map(filterableContacts.map((contact) => [contact.username, contact]))
|
const contactMap = new Map(contacts.map((contact) => [contact.username, contact]))
|
||||||
const names = selectedContactUsernames.map((username) => contactMap.get(username)?.displayName || username)
|
const names = selectedContactUsernames.map((username) => contactMap.get(username)?.displayName || username)
|
||||||
if (names.length <= 2) return names.join('、')
|
if (names.length <= 2) return names.join('、')
|
||||||
return `${names.slice(0, 2).join('、')} 等 ${names.length} 人`
|
return `${names.slice(0, 2).join('、')} 等 ${names.length} 人`
|
||||||
}, [filterableContacts, selectedContactUsernames])
|
}, [contacts, selectedContactUsernames])
|
||||||
|
|
||||||
const selectedContactUsernameSet = useMemo(() => (
|
const selectedContactUsernameSet = useMemo(() => (
|
||||||
new Set(selectedContactUsernames.map((username) => normalizeAccountId(username)))
|
new Set(selectedContactUsernames.map((username) => normalizeAccountId(username)))
|
||||||
@@ -483,31 +417,30 @@ export default function SnsPage() {
|
|||||||
}, [posts, selectedContactUsernameSet])
|
}, [posts, selectedContactUsernameSet])
|
||||||
|
|
||||||
const myTimelineCount = useMemo(() => {
|
const myTimelineCount = useMemo(() => {
|
||||||
if (typeof currentUserFilterContact?.postCount === 'number') {
|
if (resolvedCurrentUserContact?.postCountStatus === 'ready' && typeof resolvedCurrentUserContact.postCount === 'number') {
|
||||||
return normalizePostCount(currentUserFilterContact.postCount)
|
return normalizePostCount(resolvedCurrentUserContact.postCount)
|
||||||
}
|
}
|
||||||
return null
|
return null
|
||||||
}, [currentUserFilterContact, normalizePostCount])
|
}, [normalizePostCount, resolvedCurrentUserContact])
|
||||||
|
|
||||||
const myTimelineCountLoading = Boolean(
|
const myTimelineCountLoading = Boolean(
|
||||||
currentUserFilterContact
|
resolvedCurrentUserContact
|
||||||
? currentUserFilterContact.postCountStatus === 'loading'
|
? resolvedCurrentUserContact.postCountStatus !== 'ready'
|
||||||
: overviewStatsStatus === 'loading' || contactsLoading
|
: overviewStatsStatus === 'loading' || contactsLoading
|
||||||
)
|
)
|
||||||
const currentUserTimelineUsername = String(currentUserFilterContact?.username || '').trim()
|
|
||||||
|
|
||||||
const canStartExport = Boolean(exportFolder) && !isExporting && (
|
const canStartExport = Boolean(exportFolder) && !isExporting && (
|
||||||
exportScope.kind === 'all' || exportScope.usernames.length > 0
|
exportScope.kind === 'all' || exportScope.usernames.length > 0
|
||||||
)
|
)
|
||||||
|
|
||||||
const openCurrentUserTimeline = useCallback(() => {
|
const openCurrentUserTimeline = useCallback(() => {
|
||||||
if (!currentUserFilterContact) return
|
if (!resolvedCurrentUserContact) return
|
||||||
setAuthorTimelineTarget({
|
setAuthorTimelineTarget({
|
||||||
username: currentUserFilterContact.username,
|
username: resolvedCurrentUserContact.username,
|
||||||
displayName: currentUserFilterContact.displayName || currentUserProfile.displayName || currentUserFilterContact.username,
|
displayName: resolvedCurrentUserContact.displayName || currentUserProfile.displayName || resolvedCurrentUserContact.username,
|
||||||
avatarUrl: currentUserFilterContact.avatarUrl || currentUserProfile.avatarUrl
|
avatarUrl: resolvedCurrentUserContact.avatarUrl || currentUserProfile.avatarUrl
|
||||||
})
|
})
|
||||||
}, [currentUserFilterContact, currentUserProfile.avatarUrl, currentUserProfile.displayName])
|
}, [currentUserProfile.avatarUrl, currentUserProfile.displayName, resolvedCurrentUserContact])
|
||||||
|
|
||||||
const isDefaultViewNow = useCallback(() => {
|
const isDefaultViewNow = useCallback(() => {
|
||||||
return (
|
return (
|
||||||
@@ -1330,12 +1263,12 @@ export default function SnsPage() {
|
|||||||
<span className="feed-stats-divider" aria-hidden="true">|</span>
|
<span className="feed-stats-divider" aria-hidden="true">|</span>
|
||||||
<button
|
<button
|
||||||
type="button"
|
type="button"
|
||||||
className={`feed-my-timeline-entry ${currentUserFilterContact ? 'ready' : ''} ${myTimelineCountLoading ? 'loading' : ''}`}
|
className={`feed-my-timeline-entry ${resolvedCurrentUserContact ? 'ready' : ''} ${myTimelineCountLoading ? 'loading' : ''}`}
|
||||||
onClick={openCurrentUserTimeline}
|
onClick={openCurrentUserTimeline}
|
||||||
disabled={!currentUserFilterContact}
|
disabled={!resolvedCurrentUserContact}
|
||||||
title={currentUserFilterContact
|
title={resolvedCurrentUserContact
|
||||||
? `打开${currentUserFilterContact.displayName || '我'}的朋友圈详情`
|
? `打开${resolvedCurrentUserContact.displayName || '我'}的朋友圈详情`
|
||||||
: '当前账号尚未识别,暂时无法单独筛选'}
|
: '未在右侧联系人列表中匹配到当前账号'}
|
||||||
>
|
>
|
||||||
<span className="feed-my-timeline-label">我的朋友圈</span>
|
<span className="feed-my-timeline-label">我的朋友圈</span>
|
||||||
<span className="feed-my-timeline-count">
|
<span className="feed-my-timeline-count">
|
||||||
@@ -1554,7 +1487,7 @@ export default function SnsPage() {
|
|||||||
? `${overviewStats.totalFriends} 位好友`
|
? `${overviewStats.totalFriends} 位好友`
|
||||||
: undefined
|
: undefined
|
||||||
}
|
}
|
||||||
contacts={filterableContacts}
|
contacts={contacts}
|
||||||
contactSearch={contactSearch}
|
contactSearch={contactSearch}
|
||||||
setContactSearch={setContactSearch}
|
setContactSearch={setContactSearch}
|
||||||
loading={contactsLoading}
|
loading={contactsLoading}
|
||||||
@@ -1571,12 +1504,12 @@ export default function SnsPage() {
|
|||||||
<ContactSnsTimelineDialog
|
<ContactSnsTimelineDialog
|
||||||
target={authorTimelineTarget}
|
target={authorTimelineTarget}
|
||||||
onClose={closeAuthorTimeline}
|
onClose={closeAuthorTimeline}
|
||||||
initialTotalPosts={authorTimelineTarget?.username === currentUserTimelineUsername
|
initialTotalPosts={authorTimelineTarget?.username === resolvedCurrentUserContact?.username
|
||||||
? myTimelineCount
|
? myTimelineCount
|
||||||
: currentTimelineTargetContact?.postCountStatus === 'ready'
|
: currentTimelineTargetContact?.postCountStatus === 'ready'
|
||||||
? normalizePostCount(currentTimelineTargetContact.postCount)
|
? normalizePostCount(currentTimelineTargetContact.postCount)
|
||||||
: null}
|
: null}
|
||||||
initialTotalPostsLoading={Boolean(authorTimelineTarget?.username === currentUserTimelineUsername
|
initialTotalPostsLoading={Boolean(authorTimelineTarget?.username === resolvedCurrentUserContact?.username
|
||||||
? myTimelineCount === null && myTimelineCountLoading
|
? myTimelineCount === null && myTimelineCountLoading
|
||||||
: currentTimelineTargetContact?.postCountStatus === 'loading')}
|
: currentTimelineTargetContact?.postCountStatus === 'loading')}
|
||||||
isProtected={triggerInstalled === true}
|
isProtected={triggerInstalled === true}
|
||||||
|
|||||||
Reference in New Issue
Block a user