[socialmon] inbox: make all tab the first

This commit is contained in:
Yangshun 2025-07-22 10:03:49 +08:00
parent c1d92e2d3b
commit c032312027
6 changed files with 25 additions and 27 deletions

View File

@ -22,7 +22,7 @@ import { trpc } from '~/hooks/trpc';
import type { PostExtended } from '~/types';
import PostCommentsList from '../comments/PostCommentsList';
import { parseMarkdown } from '../markdownParser';
import { parseMarkdown } from '../../common/ParseMarkdown';
import PostRelevanceActionButton from '../PostRelevanceActionButton';
import PostReplyStatusActionButton from '../PostReplyStatusActionButton';
import PostMetadata from './PostMetadata';

View File

@ -69,6 +69,13 @@ export default function PostList() {
variant="outline"
onChange={(value) => setActiveTab(value as PostListTab)}>
<Tabs.List>
<Tooltip
label={<ShortcutDisplay action={ShortcutAction.GO_TO_ALL} />}
withArrow={true}>
<Tabs.Tab fw={500} value="ALL">
All
</Tabs.Tab>
</Tooltip>
<Tooltip
label={<ShortcutDisplay action={ShortcutAction.GO_TO_PENDING} />}
withArrow={true}>
@ -84,19 +91,14 @@ export default function PostList() {
</Tabs.Tab>
</Tooltip>
<Tooltip
label={<ShortcutDisplay action={ShortcutAction.GO_TO_IRRELEVANT} />}
label={
<ShortcutDisplay action={ShortcutAction.GO_TO_IRRELEVANT} />
}
withArrow={true}>
<Tabs.Tab fw={500} value="IRRELEVANT">
Irrelevant
</Tabs.Tab>
</Tooltip>
<Tooltip
label={<ShortcutDisplay action={ShortcutAction.GO_TO_ALL} />}
withArrow={true}>
<Tabs.Tab fw={500} value="ALL">
All
</Tabs.Tab>
</Tooltip>
</Tabs.List>
</Tabs>
<div className="absolute right-2 top-2 flex items-center gap-2">

View File

@ -46,13 +46,12 @@ export function PostsProvider({
children: React.ReactNode;
projectSlug: string;
}) {
const [activeTab, setActiveTab] = useState<PostListTab>('PENDING');
const [activeTab, setActiveTab] = useState<PostListTab>('ALL');
const [selectedPostId, setSelectedPostId] = useState<string | null>(null);
const router = useRouter();
const params = useParams();
const utils = trpc.useUtils();
// Single TRPC query - this replaces PostList's query
const { data, fetchNextPage, hasNextPage, isFetchingNextPage, isLoading } =
trpc.socialPosts.getPosts.useInfiniteQuery(
{
@ -99,22 +98,22 @@ export function PostsProvider({
}, [posts, selectedPostId]);
// Navigation handlers
const handlePostClick = (postId: string) => {
function handlePostClick(postId: string) {
setSelectedPostId(postId);
router.push(`/projects/${projectSlug}/posts/${postId}`);
};
}
const handlePrevPost = () => {
function handlePrevPost() {
if (adjacentPosts.prev) {
handlePostClick(adjacentPosts.prev.id);
}
};
}
const handleNextPost = () => {
function handleNextPost() {
if (adjacentPosts.next) {
handlePostClick(adjacentPosts.next.id);
}
};
}
// Mutations for toggling relevant/replied status
const projectSlugForMutation = projectSlug;
@ -123,7 +122,7 @@ export function PostsProvider({
const markPostReplyStatusMutation =
trpc.socialPosts.markPostReplyStatus.useMutation();
const markPostRelevancy = (postId: string, relevancy: PostRelevancy) => {
function markPostRelevancy(postId: string, relevancy: PostRelevancy) {
markPostRelevancyMutation.mutate(
{
postId,
@ -137,12 +136,9 @@ export function PostsProvider({
},
},
);
};
}
const markPostReplyStatus = (
postId: string,
replyStatus: ManualReplyStatus,
) => {
function markPostReplyStatus(postId: string, replyStatus: ManualReplyStatus) {
markPostReplyStatusMutation.mutate(
{
postId,
@ -156,7 +152,7 @@ export function PostsProvider({
},
},
);
};
}
const contextValue: PostsContextType = {
activeTab,

View File

@ -8,7 +8,7 @@ import RelativeTimestamp from '~/components/common/datetime/RelativeTimestamp';
import type { Comment } from '~/types';
import { parseMarkdown } from '../markdownParser';
import { parseMarkdown } from '../../common/ParseMarkdown';
import { isRedditComments } from '../utils';
import CommentRepliesThreadLines from './CommentRepliesThreadLines';
import PostCommentReplies from './PostCommentReplies';

View File

@ -30,7 +30,7 @@ export type ShortcutConfig = {
export const SHORTCUTS: Record<ShortcutAction, ShortcutConfig> = {
[ShortcutAction.GO_TO_ALL]: {
description: 'Go to all posts',
keys: ['g', '4'],
keys: ['g', '1'],
},
[ShortcutAction.GO_TO_IRRELEVANT]: {
description: 'Go to irrelevant posts',
@ -38,7 +38,7 @@ export const SHORTCUTS: Record<ShortcutAction, ShortcutConfig> = {
},
[ShortcutAction.GO_TO_PENDING]: {
description: 'Go to pending posts',
keys: ['g', '1'],
keys: ['g', '4'],
},
[ShortcutAction.GO_TO_REPLIED]: {
description: 'Go to replied posts',