feat(message): add pinned conversations sorting and unified timeline
Sort conversation list with pinned items first, then by updated_at timestamp. Also fixes timestamp text alignment by adding lineHeight, textAlignVertical, and includeFontPadding properties for consistent vertical centering.
This commit is contained in:
@@ -475,11 +475,16 @@ export const MessageListScreen: React.FC = () => {
|
||||
};
|
||||
};
|
||||
|
||||
// 合并列表数据
|
||||
// 合并列表数据:系统消息与普通会话一起按时间排序
|
||||
const listData: ConversationResponse[] = [
|
||||
createSystemMessageItem(),
|
||||
...conversationList,
|
||||
];
|
||||
].sort((a, b) => {
|
||||
const aPinned = a.is_pinned ? 1 : 0;
|
||||
const bPinned = b.is_pinned ? 1 : 0;
|
||||
if (aPinned !== bPinned) return bPinned - aPinned;
|
||||
return new Date(b.updated_at).getTime() - new Date(a.updated_at).getTime();
|
||||
});
|
||||
|
||||
const listConvRef = useRef(new Map<string, ConversationResponse>());
|
||||
listConvRef.current = new Map(listData.map((c) => [String(c.id), c]));
|
||||
@@ -981,6 +986,9 @@ function createMessageListStyles(colors: AppColors) {
|
||||
color: colors.primary.contrast,
|
||||
fontSize: 11,
|
||||
fontWeight: '600',
|
||||
lineHeight: 18,
|
||||
textAlignVertical: 'center',
|
||||
includeFontPadding: false,
|
||||
},
|
||||
headerRight: {
|
||||
width: 44,
|
||||
|
||||
@@ -265,6 +265,9 @@ function createConversationRowStyles(colors: AppColors) {
|
||||
color: '#FFFFFF',
|
||||
fontSize: 12,
|
||||
fontWeight: '700',
|
||||
lineHeight: 20,
|
||||
textAlignVertical: 'center',
|
||||
includeFontPadding: false,
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user