perf: implement Phase 1 homepage diet via Next.js Cache Components
P1-0: V8 heap cap (HOMARR_MAX_OLD_SPACE_SIZE, default 512MB)
P1-1: Module graph cuts
- Dynamic integration imports (55 static → lazy loaders)
- Conditional DB driver loading (only configured driver loaded)
- Replace jsdom with linkedom for SVG sanitization
- Delete eager widget barrel (55 import * as → 0)
- Extract createRetryableLoader to @homarr/common
P1-2: Enable cacheComponents + restructure root layout
- Suspense boundaries around session-dependent providers
- ColorSchemeScript replaces server-side cookie reads
- Board/manage/auth layouts wrapped in Suspense
P1-3: Cache read paths
- Cache tag registry + invalidation helpers
- Cache invalidation wired into all mutation routers
- Translation deep-merge memoized per locale
P1-4: Prerendered shells + loading.tsx files
P1-5: Shared integration data cache (60s TTL, stale-while-revalidate)
P1-6: Redis-backed Next.js cache handler (@homarr/next-cache-handler)
P1-7: Redis optional (memory channel fallback), TTL on pubSub:last:*,
Redis clients consolidated from 6 to 2
This commit is contained in:
86 files changed
+2219
-1232
No files matched your search
@@ -19,6 +19,7 @@ import {
|
||||
} from "@homarr/validation/group";
|
||||
|
||||
import { createTRPCRouter, onboardingProcedure, permissionRequiredProcedure, protectedProcedure } from "../trpc";
|
||||
import { invalidateUserCache } from "../cache-invalidation";
|
||||
import { nextOnboardingStepAsync } from "./onboard/onboard-queries";
|
||||
|
||||
export const groupRouter = createTRPCRouter({
|
||||
@@ -245,6 +246,14 @@ export const groupRouter = createTRPCRouter({
|
||||
mobileHomeBoardId: input.settings.mobileHomeBoardId,
|
||||
})
|
||||
.where(eq(groups.id, input.id));
|
||||
|
||||
const members = await ctx.db.query.groupMembers.findMany({
|
||||
columns: { userId: true },
|
||||
where: eq(groupMembers.groupId, input.id),
|
||||
});
|
||||
for (const member of members) {
|
||||
invalidateUserCache(member.userId);
|
||||
}
|
||||
}),
|
||||
savePositions: permissionRequiredProcedure
|
||||
.requiresPermission("admin")
|
||||
@@ -275,6 +284,11 @@ export const groupRouter = createTRPCRouter({
|
||||
.mutation(async ({ input, ctx }) => {
|
||||
await throwIfGroupNotFoundAsync(ctx.db, input.groupId);
|
||||
|
||||
const members = await ctx.db.query.groupMembers.findMany({
|
||||
columns: { userId: true },
|
||||
where: eq(groupMembers.groupId, input.groupId),
|
||||
});
|
||||
|
||||
await ctx.db.delete(groupPermissions).where(eq(groupPermissions.groupId, input.groupId));
|
||||
|
||||
if (input.permissions.length > 0) {
|
||||
@@ -285,6 +299,10 @@ export const groupRouter = createTRPCRouter({
|
||||
})),
|
||||
);
|
||||
}
|
||||
|
||||
for (const member of members) {
|
||||
invalidateUserCache(member.userId);
|
||||
}
|
||||
}),
|
||||
transferOwnership: permissionRequiredProcedure
|
||||
.requiresPermission("admin")
|
||||
@@ -307,7 +325,16 @@ export const groupRouter = createTRPCRouter({
|
||||
await throwIfGroupNotFoundAsync(ctx.db, input.id);
|
||||
await throwIfGroupNameIsReservedAsync(ctx.db, input.id);
|
||||
|
||||
const members = await ctx.db.query.groupMembers.findMany({
|
||||
columns: { userId: true },
|
||||
where: eq(groupMembers.groupId, input.id),
|
||||
});
|
||||
|
||||
await ctx.db.delete(groups).where(eq(groups.id, input.id));
|
||||
|
||||
for (const member of members) {
|
||||
invalidateUserCache(member.userId);
|
||||
}
|
||||
}),
|
||||
addMember: permissionRequiredProcedure
|
||||
.requiresPermission("admin")
|
||||
@@ -339,6 +366,8 @@ export const groupRouter = createTRPCRouter({
|
||||
groupId: input.groupId,
|
||||
userId: input.userId,
|
||||
});
|
||||
|
||||
invalidateUserCache(input.userId);
|
||||
}),
|
||||
removeMember: permissionRequiredProcedure
|
||||
.requiresPermission("admin")
|
||||
@@ -351,6 +380,8 @@ export const groupRouter = createTRPCRouter({
|
||||
await ctx.db
|
||||
.delete(groupMembers)
|
||||
.where(and(eq(groupMembers.groupId, input.groupId), eq(groupMembers.userId, input.userId)));
|
||||
|
||||
invalidateUserCache(input.userId);
|
||||
}),
|
||||
});
|
||||
|
||||
|
||||
Reference in new issue
Block a user