Update bun packages and format
This commit is contained in:
@@ -9,26 +9,26 @@ import {
|
||||
import type { Doc, Id } from './_generated/dataModel';
|
||||
import { paginationOptsValidator } from 'convex/server';
|
||||
|
||||
type RWCtx = MutationCtx | QueryCtx
|
||||
type RWCtx = MutationCtx | QueryCtx;
|
||||
|
||||
type StatusRow = {
|
||||
user: {
|
||||
id: Id<'users'>;
|
||||
name: string | null;
|
||||
imageUrl: string | null;
|
||||
},
|
||||
};
|
||||
status: {
|
||||
id: Id<'statuses'>;
|
||||
message: string;
|
||||
updatedAt: number;
|
||||
updatedBy: StatusRow['user'] | null;
|
||||
} | null,
|
||||
} | null;
|
||||
};
|
||||
|
||||
type Paginated<T> = {
|
||||
page: T[],
|
||||
isDone: boolean,
|
||||
continueCursor: string | null,
|
||||
page: T[];
|
||||
isDone: boolean;
|
||||
continueCursor: string | null;
|
||||
};
|
||||
|
||||
// CHANGED: typed helpers
|
||||
@@ -240,9 +240,10 @@ export const listHistory = query({
|
||||
userId: v.optional(v.id('users')),
|
||||
paginationOpts: paginationOptsValidator,
|
||||
},
|
||||
handler: async (ctx, { userId, paginationOpts }): Promise<
|
||||
Paginated<StatusRow>
|
||||
> => {
|
||||
handler: async (
|
||||
ctx,
|
||||
{ userId, paginationOpts },
|
||||
): Promise<Paginated<StatusRow>> => {
|
||||
// Query statuses newest-first, optionally filtered by user
|
||||
const result = userId
|
||||
? await ctx.db
|
||||
@@ -250,17 +251,12 @@ export const listHistory = query({
|
||||
.withIndex('by_user_updatedAt', (q) => q.eq('userId', userId))
|
||||
.order('desc')
|
||||
.paginate(paginationOpts)
|
||||
: await ctx.db
|
||||
.query('statuses')
|
||||
.order('desc')
|
||||
.paginate(paginationOpts);
|
||||
: await ctx.db.query('statuses').order('desc').paginate(paginationOpts);
|
||||
|
||||
// Cache user display objects to avoid refetching repeatedly
|
||||
const displayCache = new Map<string, StatusRow['user']>();
|
||||
|
||||
const getDisplay = async (
|
||||
uid: Id<'users'>,
|
||||
): Promise<StatusRow['user']> => {
|
||||
const getDisplay = async (uid: Id<'users'>): Promise<StatusRow['user']> => {
|
||||
const key = uid as unknown as string;
|
||||
const cached = displayCache.get(key);
|
||||
if (cached) return cached;
|
||||
@@ -304,5 +300,3 @@ export const listHistory = query({
|
||||
};
|
||||
},
|
||||
});
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user