Merge pull request #5 from atridadl/dev
1.0.5 🐛✨ New votes no longer reset the story name and scale fields! 🚧 Dependency Updates
This commit is contained in:
commit
b0b13223dc
5 changed files with 455 additions and 428 deletions
22
package.json
22
package.json
|
@ -1,54 +1,56 @@
|
||||||
{
|
{
|
||||||
"name": "sprintpadawan",
|
"name": "sprintpadawan",
|
||||||
"version": "1.0.4",
|
"version": "1.0.5",
|
||||||
"description": "Plan. Sprint. Repeat.",
|
"description": "Plan. Sprint. Repeat.",
|
||||||
"private": true,
|
"private": true,
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"build": "next build",
|
"build": "next build",
|
||||||
"dev": "NEXTAUTH_URL=http://localhost:3000 && next dev",
|
"serv": "NEXTAUTH_URL=http://localhost:3000 && next dev",
|
||||||
|
"dev": "railway run pnpm serv",
|
||||||
"postinstall": "prisma generate",
|
"postinstall": "prisma generate",
|
||||||
"lint": "next lint",
|
"lint": "next lint",
|
||||||
"start": "next start"
|
"start": "next start",
|
||||||
|
"connect": "railway link"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@ably-labs/react-hooks": "^2.1.1",
|
"@ably-labs/react-hooks": "^2.1.1",
|
||||||
"@next-auth/prisma-adapter": "^1.0.6",
|
"@next-auth/prisma-adapter": "^1.0.6",
|
||||||
"@prisma/client": "4.14.1",
|
"@prisma/client": "4.15.0",
|
||||||
"@tailwindcss/typography": "^0.5.9",
|
"@tailwindcss/typography": "^0.5.9",
|
||||||
"@tanstack/react-query": "^4.29.12",
|
"@tanstack/react-query": "^4.29.12",
|
||||||
"@trpc/client": "10.28.1",
|
"@trpc/client": "10.28.1",
|
||||||
"@trpc/next": "10.28.1",
|
"@trpc/next": "10.28.1",
|
||||||
"@trpc/react-query": "10.28.1",
|
"@trpc/react-query": "10.28.1",
|
||||||
"@trpc/server": "10.28.1",
|
"@trpc/server": "10.28.1",
|
||||||
"@types/json2csv": "^5.0.3",
|
|
||||||
"@types/next-pwa": "^5.6.4",
|
|
||||||
"ably": "^1.2.40",
|
"ably": "^1.2.40",
|
||||||
"autoprefixer": "^10.4.14",
|
"autoprefixer": "^10.4.14",
|
||||||
"daisyui": "^2.52.0",
|
|
||||||
"fms-ts": "^0.1.7",
|
"fms-ts": "^0.1.7",
|
||||||
"json2csv": "6.0.0-alpha.2",
|
"json2csv": "6.0.0-alpha.2",
|
||||||
"next": "^13.4.4",
|
"next": "^13.4.4",
|
||||||
"next-auth": "^4.22.1",
|
"next-auth": "^4.22.1",
|
||||||
"next-pwa": "^5.6.0",
|
|
||||||
"postcss": "^8.4.24",
|
"postcss": "^8.4.24",
|
||||||
"react": "18.2.0",
|
"react": "18.2.0",
|
||||||
"react-dom": "18.2.0",
|
"react-dom": "18.2.0",
|
||||||
"react-icons": "^4.9.0",
|
"react-icons": "^4.9.0",
|
||||||
"redicache-ts": "^0.1.1",
|
"redicache-ts": "^0.1.1",
|
||||||
"superjson": "1.12.3",
|
"superjson": "1.12.3",
|
||||||
"tailwindcss": "^3.3.2",
|
|
||||||
"zod": "^3.21.4"
|
"zod": "^3.21.4"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@types/eslint": "^8.40.0",
|
"@types/eslint": "^8.40.0",
|
||||||
|
"@types/json2csv": "^5.0.3",
|
||||||
|
"@types/next-pwa": "^5.6.4",
|
||||||
"@types/node": "^20.2.5",
|
"@types/node": "^20.2.5",
|
||||||
"@types/react": "^18.2.7",
|
"@types/react": "^18.2.7",
|
||||||
"@types/react-dom": "^18.2.4",
|
"@types/react-dom": "^18.2.4",
|
||||||
"@typescript-eslint/eslint-plugin": "^5.59.8",
|
"@typescript-eslint/eslint-plugin": "^5.59.8",
|
||||||
"@typescript-eslint/parser": "^5.59.8",
|
"@typescript-eslint/parser": "^5.59.8",
|
||||||
|
"daisyui": "^2.52.0",
|
||||||
"eslint": "^8.41.0",
|
"eslint": "^8.41.0",
|
||||||
"eslint-config-next": "^13.4.4",
|
"eslint-config-next": "^13.4.4",
|
||||||
"prisma": "4.14.1",
|
"next-pwa": "^5.6.0",
|
||||||
|
"prisma": "4.15.0",
|
||||||
|
"tailwindcss": "^3.3.2",
|
||||||
"typescript": "^5.0.4"
|
"typescript": "^5.0.4"
|
||||||
},
|
},
|
||||||
"ct3aMetadata": {
|
"ct3aMetadata": {
|
||||||
|
|
798
pnpm-lock.yaml
generated
798
pnpm-lock.yaml
generated
File diff suppressed because it is too large
Load diff
|
@ -27,7 +27,7 @@ const Navbar: React.FC<NavbarProps> = ({ title }) => {
|
||||||
priority
|
priority
|
||||||
/>
|
/>
|
||||||
{title}
|
{title}
|
||||||
{env.NEXT_PUBLIC_APP_ENV === "development" && " >> DEVELOPMENT"}
|
{env.NEXT_PUBLIC_APP_ENV === "development" && " >> DEV"}
|
||||||
</Link>
|
</Link>
|
||||||
</div>
|
</div>
|
||||||
{sessionData?.user.image && (
|
{sessionData?.user.image && (
|
||||||
|
|
|
@ -121,6 +121,8 @@ const RoomBody: React.FC = () => {
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
window.addEventListener("beforeunload", () => channel.presence.leave());
|
window.addEventListener("beforeunload", () => channel.presence.leave());
|
||||||
return () => {
|
return () => {
|
||||||
|
localStorage.removeItem(`${roomId}_story_name`);
|
||||||
|
localStorage.removeItem(`${roomId}_room_scale`);
|
||||||
window.removeEventListener("beforeunload", () =>
|
window.removeEventListener("beforeunload", () =>
|
||||||
channel.presence.leave()
|
channel.presence.leave()
|
||||||
);
|
);
|
||||||
|
@ -131,8 +133,16 @@ const RoomBody: React.FC = () => {
|
||||||
// Init story name
|
// Init story name
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (sessionData && roomFromDb) {
|
if (sessionData && roomFromDb) {
|
||||||
setStoryNameText(roomFromDb.storyName || "");
|
setStoryNameText(
|
||||||
setRoomScale(roomFromDb.scale || "ERROR");
|
localStorage.getItem(`${roomId}_story_name`) ||
|
||||||
|
roomFromDb.storyName ||
|
||||||
|
""
|
||||||
|
);
|
||||||
|
setRoomScale(
|
||||||
|
localStorage.getItem(`${roomId}_room_scale`) ||
|
||||||
|
roomFromDb.scale ||
|
||||||
|
"ERROR"
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}, [roomFromDb, sessionData]);
|
}, [roomFromDb, sessionData]);
|
||||||
|
|
||||||
|
@ -367,7 +377,13 @@ const RoomBody: React.FC = () => {
|
||||||
placeholder="Scale (Comma Separated)"
|
placeholder="Scale (Comma Separated)"
|
||||||
className="input input-bordered m-auto"
|
className="input input-bordered m-auto"
|
||||||
value={roomScale}
|
value={roomScale}
|
||||||
onChange={(event) => setRoomScale(event.target.value)}
|
onChange={(event) => {
|
||||||
|
setRoomScale(event.target.value);
|
||||||
|
localStorage.setItem(
|
||||||
|
`${roomId}_room_scale`,
|
||||||
|
event.target.value
|
||||||
|
);
|
||||||
|
}}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<label className="label mx-auto">{"Story Name:"} </label>
|
<label className="label mx-auto">{"Story Name:"} </label>
|
||||||
|
@ -377,7 +393,13 @@ const RoomBody: React.FC = () => {
|
||||||
placeholder="Story Name"
|
placeholder="Story Name"
|
||||||
className="input input-bordered m-auto"
|
className="input input-bordered m-auto"
|
||||||
value={storyNameText}
|
value={storyNameText}
|
||||||
onChange={(event) => setStoryNameText(event.target.value)}
|
onChange={(event) => {
|
||||||
|
setStoryNameText(event.target.value);
|
||||||
|
localStorage.setItem(
|
||||||
|
`${roomId}_story_name`,
|
||||||
|
event.target.value
|
||||||
|
);
|
||||||
|
}}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<div className="flex flex-row flex-wrap text-center items-center justify-center gap-2">
|
<div className="flex flex-row flex-wrap text-center items-center justify-center gap-2">
|
||||||
|
|
|
@ -9,6 +9,7 @@ import {
|
||||||
deleteFromCache,
|
deleteFromCache,
|
||||||
} from "redicache-ts";
|
} from "redicache-ts";
|
||||||
import { env } from "~/env.mjs";
|
import { env } from "~/env.mjs";
|
||||||
|
import { Vote } from "@prisma/client";
|
||||||
|
|
||||||
const client = cacheClient(env.REDIS_URL);
|
const client = cacheClient(env.REDIS_URL);
|
||||||
|
|
||||||
|
@ -36,6 +37,35 @@ export const voteRouter = createTRPCRouter({
|
||||||
return votesCount;
|
return votesCount;
|
||||||
}
|
}
|
||||||
}),
|
}),
|
||||||
|
getAllByRoomId: protectedProcedure
|
||||||
|
.input(z.object({ roomId: z.string() }))
|
||||||
|
.query(async ({ ctx, input }) => {
|
||||||
|
const cachedResult = await fetchFromCache<Vote[]>(
|
||||||
|
client,
|
||||||
|
env.APP_ENV,
|
||||||
|
`kv_votes_${input.roomId}`
|
||||||
|
);
|
||||||
|
|
||||||
|
if (cachedResult) {
|
||||||
|
return cachedResult;
|
||||||
|
} else {
|
||||||
|
const votesByRoomId = await ctx.prisma.vote.findMany({
|
||||||
|
where: {
|
||||||
|
roomId: input.roomId,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
await writeToCache(
|
||||||
|
client,
|
||||||
|
env.APP_ENV,
|
||||||
|
`kv_votes_${input.roomId}`,
|
||||||
|
JSON.stringify(votesByRoomId),
|
||||||
|
69
|
||||||
|
);
|
||||||
|
|
||||||
|
return votesByRoomId;
|
||||||
|
}
|
||||||
|
}),
|
||||||
set: protectedProcedure
|
set: protectedProcedure
|
||||||
.input(z.object({ value: z.string(), roomId: z.string() }))
|
.input(z.object({ value: z.string(), roomId: z.string() }))
|
||||||
.mutation(async ({ ctx, input }) => {
|
.mutation(async ({ ctx, input }) => {
|
||||||
|
@ -71,6 +101,7 @@ export const voteRouter = createTRPCRouter({
|
||||||
|
|
||||||
if (vote) {
|
if (vote) {
|
||||||
await deleteFromCache(client, env.APP_ENV, `kv_votecount_admin`);
|
await deleteFromCache(client, env.APP_ENV, `kv_votecount_admin`);
|
||||||
|
await deleteFromCache(client, env.APP_ENV, `kv_votes_${input.roomId}`);
|
||||||
|
|
||||||
await publishToChannel(`${vote.roomId}`, "VOTE_UPDATE", "UPDATE");
|
await publishToChannel(`${vote.roomId}`, "VOTE_UPDATE", "UPDATE");
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue