Skip to content

Commit 4e8b5d0

Browse files
committed
Fix missing last active update and deletion reset
1 parent d4fcc71 commit 4e8b5d0

File tree

3 files changed

+24
-10
lines changed

3 files changed

+24
-10
lines changed

components/core/notification-item.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
"use client";
22

3+
import { Dot } from "lucide-react";
4+
import Link from "next/link";
35
import { UserAvatar } from "@/components/core/user-avatar";
46
import type { NotificationWithUser } from "@/drizzle/types";
57
import { toDateTimeString } from "@/lib/utils/date";
6-
import { Dot } from "lucide-react";
7-
import Link from "next/link";
88

99
export function NotificationItem({
1010
notification,

components/core/report-timezone.tsx

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
"use client";
22

3-
import { useTRPC } from "@/trpc/client";
43
import { useMutation, useQueryClient } from "@tanstack/react-query";
5-
import { useEffect } from "react";
6-
import { memo } from "react";
4+
import { memo, useEffect } from "react";
5+
import { useTRPC } from "@/trpc/client";
76

87
export const ReportTimezone = memo(function ReportTimezone() {
98
const trpc = useTRPC();

trpc/routers/settings.ts

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { cookies } from "next/headers";
33
import { z } from "zod";
44
import { blob, user } from "@/drizzle/schema";
55
import type { User } from "@/drizzle/types";
6-
import { opsUser } from "@/ops/drizzle/schema";
6+
import { opsOrganization, opsUser } from "@/ops/drizzle/schema";
77
import { getOpsDatabase } from "@/ops/useOps";
88
import { createTRPCRouter, protectedProcedure } from "../init";
99

@@ -32,27 +32,42 @@ export const settingsRouter = createTRPCRouter({
3232
maxAge: 60 * 60 * 24 * 365,
3333
});
3434

35-
// Update main user database
3635
await ctx.db
3736
.update(user)
3837
.set({ timeZone: input, lastActiveAt: new Date() })
3938
.where(eq(user.id, ctx.userId))
4039
.execute();
4140

42-
// Also update ops user database for email scheduling
4341
try {
4442
const opsDb = await getOpsDatabase();
43+
4544
await opsDb
4645
.update(opsUser)
47-
.set({ timeZone: input, lastActiveAt: new Date() })
46+
.set({
47+
timeZone: input,
48+
lastActiveAt: new Date(),
49+
markedForDeletionAt: null,
50+
finalWarningAt: null,
51+
})
4852
.where(eq(opsUser.id, ctx.userId))
4953
.execute();
54+
55+
if (ctx.orgId) {
56+
await opsDb
57+
.update(opsOrganization)
58+
.set({
59+
lastActiveAt: new Date(),
60+
markedForDeletionAt: null,
61+
finalWarningAt: null,
62+
})
63+
.where(eq(opsUser.id, ctx.orgId))
64+
.execute();
65+
}
5066
} catch (error) {
5167
console.error(
5268
"[Settings] Error updating timezone in ops database:",
5369
error,
5470
);
55-
// Don't throw error to avoid blocking the main update
5671
}
5772
}),
5873
getTimezone: protectedProcedure.output(z.string()).query(async () => {

0 commit comments

Comments
 (0)