Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions components/core/notification-item.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
"use client";

import { Dot } from "lucide-react";
import Link from "next/link";
import { UserAvatar } from "@/components/core/user-avatar";
import type { NotificationWithUser } from "@/drizzle/types";
import { toDateTimeString } from "@/lib/utils/date";
import { Dot } from "lucide-react";
import Link from "next/link";

export function NotificationItem({
notification,
Expand Down
5 changes: 2 additions & 3 deletions components/core/report-timezone.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
"use client";

import { useTRPC } from "@/trpc/client";
import { useMutation, useQueryClient } from "@tanstack/react-query";
import { useEffect } from "react";
import { memo } from "react";
import { memo, useEffect } from "react";
import { useTRPC } from "@/trpc/client";

export const ReportTimezone = memo(function ReportTimezone() {
const trpc = useTRPC();
Expand Down
25 changes: 20 additions & 5 deletions trpc/routers/settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { cookies } from "next/headers";
import { z } from "zod";
import { blob, user } from "@/drizzle/schema";
import type { User } from "@/drizzle/types";
import { opsUser } from "@/ops/drizzle/schema";
import { opsOrganization, opsUser } from "@/ops/drizzle/schema";
import { getOpsDatabase } from "@/ops/useOps";
import { createTRPCRouter, protectedProcedure } from "../init";

Expand Down Expand Up @@ -32,27 +32,42 @@ export const settingsRouter = createTRPCRouter({
maxAge: 60 * 60 * 24 * 365,
});

// Update main user database
await ctx.db
.update(user)
.set({ timeZone: input, lastActiveAt: new Date() })
.where(eq(user.id, ctx.userId))
.execute();

// Also update ops user database for email scheduling
try {
const opsDb = await getOpsDatabase();

await opsDb
.update(opsUser)
.set({ timeZone: input, lastActiveAt: new Date() })
.set({
timeZone: input,
lastActiveAt: new Date(),
markedForDeletionAt: null,
finalWarningAt: null,
})
.where(eq(opsUser.id, ctx.userId))
.execute();

if (ctx.orgId) {
await opsDb
.update(opsOrganization)
.set({
lastActiveAt: new Date(),
markedForDeletionAt: null,
finalWarningAt: null,
})
.where(eq(opsUser.id, ctx.orgId))
.execute();
}
} catch (error) {
console.error(
"[Settings] Error updating timezone in ops database:",
error,
);
// Don't throw error to avoid blocking the main update
}
}),
getTimezone: protectedProcedure.output(z.string()).query(async () => {
Expand Down