Checkpoint: Persistance "marquer comme lu" entre sessions :
- Ajout de veille.getReadIds et aap.getReadIds dans routers.ts (procédures protectedProcedure) - VeilleDashboard.tsx : chargement des IDs lus depuis la DB au montage (useEffect sur readIdsQuery), invalidation getReadIds dans markAsRead et markAllAsRead - AAPDashboard.tsx : même pattern - 0 erreur TypeScript
This commit is contained in:
@@ -226,6 +226,15 @@ export const appRouter = router({
|
||||
const read = readRows[0]?.cnt ?? 0;
|
||||
return { count: Math.max(0, total - read) };
|
||||
}),
|
||||
getReadIds: protectedProcedure.query(async ({ ctx }) => {
|
||||
const db = await getDb();
|
||||
if (!db) return { ids: [] as number[] };
|
||||
const rows = await db
|
||||
.select({ articleId: articleReads.articleId })
|
||||
.from(articleReads)
|
||||
.where(and(eqDrizzle(articleReads.userId, ctx.user.id), eqDrizzle(articleReads.articleType, "veille")));
|
||||
return { ids: rows.map((r: { articleId: number }) => r.articleId) };
|
||||
}),
|
||||
}),
|
||||
// ─── AAPP ────────────────────────────────────────────────────────────────────
|
||||
aap: router({
|
||||
@@ -353,8 +362,17 @@ export const appRouter = router({
|
||||
const read = readRows[0]?.cnt ?? 0;
|
||||
return { count: Math.max(0, total - read) };
|
||||
}),
|
||||
getReadIds: protectedProcedure.query(async ({ ctx }) => {
|
||||
const db = await getDb();
|
||||
if (!db) return { ids: [] as number[] };
|
||||
const rows = await db
|
||||
.select({ articleId: articleReads.articleId })
|
||||
.from(articleReads)
|
||||
.where(and(eqDrizzle(articleReads.userId, ctx.user.id), eqDrizzle(articleReads.articleType, "aap")));
|
||||
return { ids: rows.map((r: { articleId: number }) => r.articleId) };
|
||||
}),
|
||||
}),
|
||||
// ─── Importt ─────────────────────────────────────────────────────────────────
|
||||
// ─── Import ─────────────────────────────────────────────────────────────────
|
||||
import: router({
|
||||
run: adminProcedure
|
||||
.input(z.object({ type: z.enum(["veille", "aap", "all"]).default("all") }))
|
||||
|
||||
Reference in New Issue
Block a user