Skip to content

Enhance postcard management with loading UI, hiding feature, and stats#2

Merged
AlexWei2020 merged 3 commits into
mainfrom
feature
Jul 8, 2026
Merged

Enhance postcard management with loading UI, hiding feature, and stats#2
AlexWei2020 merged 3 commits into
mainfrom
feature

Conversation

@AlexWei2020

Copy link
Copy Markdown
Owner

No description provided.

1. 全站累计签收计数:新增单行表 site_stats(total_received),首次以当前
   received 数量为基线。签收 +1、取消签收 -1、取消认领(原已签收)时 -1,
   删除记录不减(保护隐私)。首页与登录页显示已累计签收 N 张明信片;
   登录页改为服务端组件 + 客户端 LoginButton,直读计数无闪烁。
2. 认领人隐藏记录(仅自己可见):postcards 加 hidden_by_claimer;新增
   /api/postcards/[id]/hide POST/DELETE(仅认领人、claimed/received)。
   广场列表与计数排除隐藏项,认领人仍能在「我的」看到并含已隐藏标记;
   详情弹窗加隐藏/取消隐藏按钮。
3. 加载体验:换页/换板块时列表变暗 + 视窗顶部居中显示醒目加载中指示,
   点击筛选立即高亮(乐观),加载完成平滑滚回列表顶部;移除原右下角文字。

init.sql 同步新增 hidden_by_claimer 列、site_stats 表与索引(幂等迁移)。
- /api/postcards 新增 scope=claimed|uploaded 分页查询(返回
  scopeCounts 供两个 tab 显示计数),替换之前未使用的 mine=1 参数。
- app/mine/page.tsx 首屏只拉"我认领的"第一页 + 两个 tab 的总数。
- app/mine/mine-client.tsx 重写为与广场 home-client 一致的交互:
  切 tab / 翻页 / 改每页数量时,tab 立即乐观高亮、列表变暗不可点、
  视窗顶部弹出"加载中…"提示,加载完成后平滑滚回列表顶部;操作
  (签收/取消认领/取消签收/删除)后重新拉取当前页而不是本地拼接。
- package.json 版本号 0.1.1 -> 0.1.2。
Copilot AI review requested due to automatic review settings July 8, 2026 06:36
@vercel

vercel Bot commented Jul 8, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
post-back Ready Ready Preview, Comment Jul 8, 2026 6:36am

@AlexWei2020
AlexWei2020 merged commit 59fb923 into main Jul 8, 2026
3 checks passed

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR enhances the PostBack postcard workflow by adding a claimer-driven “hide from plaza” feature, improving perceived responsiveness with loading UI during navigation/pagination, and introducing a site-wide “total received” statistic.

Changes:

  • Add hidden_by_claimer to postcards and exclude hidden items from the plaza list/counts, with hide/unhide actions available to the claimer.
  • Introduce a singleton site_stats table plus increment/decrement hooks to show total received counts on Home/Login.
  • Improve UX with optimistic tab/filter highlighting, pagination, and top-of-viewport loading indicators; add a public Help page and refactor Nav into a client NavBar.

Reviewed changes

Copilot reviewed 22 out of 22 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
scripts/init.sql Adds hidden_by_claimer, site_stats, and related indexes/migration statements.
proxy.ts Marks /help as a public route.
package.json Bumps version to 0.1.2.
lib/types.ts Extends Postcard with hidden_by_claimer.
lib/schema.ts Adds schema ensure helpers for hide column + site stats, and helper funcs for total received.
content/help.md Adds help content explaining hiding/cancel-claim workflows.
content/about.md Removes the location reference image from About.
components/postcard-detail.tsx Adds hide/unhide controls and hidden state badge in detail view.
components/postcard-card.tsx Displays hidden badge in card view when applicable.
components/nav.tsx Refactors to use new NavBar client component.
components/nav-bar.tsx New client nav with transition-based loading indicator and navigation handling.
components/login-button.tsx Extracts PKCE login logic into a dedicated client component.
app/page.tsx Shows total received and excludes hidden postcards from plaza queries.
app/mine/page.tsx Switches to paged loading model and passes initial counts/page size to client.
app/mine/mine-client.tsx Implements paging, optimistic tab highlight, hide/unhide integration, and loading UI.
app/login/page.tsx Converts login page to server component, shows total received, uses LoginButton.
app/home-client.tsx Adds optimistic filter highlight, scroll-to-top on page change, and loading UI changes.
app/help/page.tsx New help page rendering markdown from content/help.md.
app/api/postcards/route.ts Adds `scope=claimed
app/api/postcards/[id]/receive/route.ts Updates total received stats on receive/undo receive.
app/api/postcards/[id]/hide/route.ts New endpoint to hide/unhide a claimed/received postcard by the claimer.
app/api/postcards/[id]/claim/route.ts Resets hidden flag on cancel-claim and adjusts total received when canceling a received claim.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread components/nav-bar.tsx
Comment on lines +29 to +38
const navigate = (href: string) => (e: MouseEvent<HTMLAnchorElement>) => {
if (href === pathname) {
e.preventDefault();
return;
}
e.preventDefault();
startTransition(() => {
router.push(href);
});
};
Comment thread app/help/page.tsx
Comment on lines +8 to +11
export default async function HelpPage() {
const filePath = path.join(process.cwd(), "content", "help.md");
const markdown = await readFile(filePath, "utf8");

Comment on lines +33 to +39
const conditions = [`p.${scope === "claimed" ? "claimer_id" : "uploader_id"} = $1`];
const params: unknown[] = [user.id];
if (status && ["available", "claimed", "received"].includes(status)) {
params.push(status);
conditions.push(`p.status = $${params.length}`);
}
const where = `where ${conditions.join(" and ")}`;
Comment on lines +34 to +38
const user = await getCurrentUser();
if (!user) return NextResponse.json({ error: "未登录" }, { status: 401 });

const { id } = await params;
const { ok, postcard } = await setHidden(id, user.id, true);
Comment on lines +53 to +57
const user = await getCurrentUser();
if (!user) return NextResponse.json({ error: "未登录" }, { status: 401 });

const { id } = await params;
const { ok, postcard } = await setHidden(id, user.id, false);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants