More cache fixes
This commit is contained in:
parent
6a530b2ac3
commit
ebd77388b2
4 changed files with 21 additions and 20 deletions
|
@ -7,18 +7,21 @@ import { IoEnterOutline, IoTrashBinOutline } from "react-icons/io5";
|
||||||
import { env } from "@/env.mjs";
|
import { env } from "@/env.mjs";
|
||||||
import { trpc } from "../_trpc/client";
|
import { trpc } from "../_trpc/client";
|
||||||
import Loading from "./Loading";
|
import Loading from "./Loading";
|
||||||
|
import { useUser } from "@clerk/nextjs";
|
||||||
|
|
||||||
|
const RoomList = () => {
|
||||||
|
const { isSignedIn, user } = useUser();
|
||||||
|
|
||||||
const RoomList = ({ userId }: { userId: string }) => {
|
|
||||||
configureAbly({
|
configureAbly({
|
||||||
key: env.NEXT_PUBLIC_ABLY_PUBLIC_KEY,
|
key: env.NEXT_PUBLIC_ABLY_PUBLIC_KEY,
|
||||||
clientId: userId,
|
clientId: user?.id,
|
||||||
recover: (_, cb) => {
|
recover: (_, cb) => {
|
||||||
cb(true);
|
cb(true);
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
useChannel(
|
useChannel(
|
||||||
`${env.NEXT_PUBLIC_APP_ENV}-${userId}`,
|
`${env.NEXT_PUBLIC_APP_ENV}-${user?.id}`,
|
||||||
() => void refetchRoomsFromDb()
|
() => void refetchRoomsFromDb()
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
|
@ -26,10 +26,12 @@ import type { PresenceItem } from "@/utils/types";
|
||||||
import { trpc } from "@/app/_trpc/client";
|
import { trpc } from "@/app/_trpc/client";
|
||||||
import Loading from "@/app/_components/Loading";
|
import Loading from "@/app/_components/Loading";
|
||||||
import { User } from "@clerk/nextjs/dist/types/server";
|
import { User } from "@clerk/nextjs/dist/types/server";
|
||||||
|
import { useUser } from "@clerk/nextjs";
|
||||||
|
|
||||||
const VoteUI = ({ user }: { user: Partial<User> }) => {
|
const VoteUI = () => {
|
||||||
const params = useParams();
|
const params = useParams();
|
||||||
const roomId = params?.id as string;
|
const roomId = params?.id as string;
|
||||||
|
const { isSignedIn, user } = useUser();
|
||||||
|
|
||||||
const [storyNameText, setStoryNameText] = useState<string>("");
|
const [storyNameText, setStoryNameText] = useState<string>("");
|
||||||
const [roomScale, setRoomScale] = useState<string>("");
|
const [roomScale, setRoomScale] = useState<string>("");
|
||||||
|
@ -99,7 +101,9 @@ const VoteUI = ({ user }: { user: Partial<User> }) => {
|
||||||
// Helper functions
|
// Helper functions
|
||||||
const getVoteForCurrentUser = () => {
|
const getVoteForCurrentUser = () => {
|
||||||
if (roomFromDb) {
|
if (roomFromDb) {
|
||||||
return votesFromDb && votesFromDb.find((vote) => vote.userId === user.id);
|
return (
|
||||||
|
votesFromDb && votesFromDb.find((vote) => vote.userId === user?.id)
|
||||||
|
);
|
||||||
} else {
|
} else {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
@ -322,7 +326,7 @@ const VoteUI = ({ user }: { user: Partial<User> }) => {
|
||||||
)}
|
)}
|
||||||
|
|
||||||
{!!roomFromDb &&
|
{!!roomFromDb &&
|
||||||
(roomFromDb.userId === user.id || isAdmin(user?.publicMetadata)) && (
|
(roomFromDb.userId === user?.id || isAdmin(user?.publicMetadata)) && (
|
||||||
<>
|
<>
|
||||||
<div className="card card-compact bg-base-100 shadow-xl mx-auto m-4">
|
<div className="card card-compact bg-base-100 shadow-xl mx-auto m-4">
|
||||||
<div className="card-body flex flex-col flex-wrap">
|
<div className="card-body flex flex-col flex-wrap">
|
||||||
|
|
|
@ -3,6 +3,7 @@ import { FaShieldAlt } from "react-icons/fa";
|
||||||
import { GiStarFormation } from "react-icons/gi";
|
import { GiStarFormation } from "react-icons/gi";
|
||||||
import { isAdmin, isVIP } from "@/utils/helpers";
|
import { isAdmin, isVIP } from "@/utils/helpers";
|
||||||
import { currentUser } from "@clerk/nextjs";
|
import { currentUser } from "@clerk/nextjs";
|
||||||
|
import { Suspense } from "react";
|
||||||
|
|
||||||
export const runtime = "edge";
|
export const runtime = "edge";
|
||||||
export const preferredRegion = ["pdx1"];
|
export const preferredRegion = ["pdx1"];
|
||||||
|
@ -25,7 +26,9 @@ export default async function Dashboard() {
|
||||||
)}
|
)}
|
||||||
</h1>
|
</h1>
|
||||||
|
|
||||||
{user && <RoomList userId={user?.id} />}
|
<Suspense>
|
||||||
|
<RoomList />
|
||||||
|
</Suspense>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
import { currentUser } from "@clerk/nextjs";
|
|
||||||
import Loading from "@/app/_components/Loading";
|
|
||||||
import VoteUI from "@/app/_components/VoteUI";
|
import VoteUI from "@/app/_components/VoteUI";
|
||||||
|
import { Suspense } from "react";
|
||||||
|
|
||||||
export const runtime = "edge";
|
export const runtime = "edge";
|
||||||
export const preferredRegion = ["pdx1"];
|
export const preferredRegion = ["pdx1"];
|
||||||
|
@ -9,19 +8,11 @@ export const revalidate = 0;
|
||||||
export const fetchCache = "force-no-store";
|
export const fetchCache = "force-no-store";
|
||||||
|
|
||||||
export default async function Room() {
|
export default async function Room() {
|
||||||
const user = await currentUser();
|
|
||||||
|
|
||||||
const shapedUser = {
|
|
||||||
id: user?.id,
|
|
||||||
firstName: user?.firstName,
|
|
||||||
lastName: user?.lastName,
|
|
||||||
imageUrl: user?.imageUrl,
|
|
||||||
publicMetadata: user?.publicMetadata,
|
|
||||||
};
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="flex flex-col items-center justify-center text-center gap-2">
|
<div className="flex flex-col items-center justify-center text-center gap-2">
|
||||||
{user ? <VoteUI user={shapedUser} /> : <Loading />}
|
<Suspense>
|
||||||
|
<VoteUI />
|
||||||
|
</Suspense>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue