Skip to content

Commit

Permalink
fix issue with no maps showing when logged out and local storage filt…
Browse files Browse the repository at this point in the history
…er set
  • Loading branch information
webdevcody committed Oct 22, 2024
1 parent aeb5762 commit de21ec5
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 5 deletions.
3 changes: 3 additions & 0 deletions app/play/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { useEffect, useState } from "react";
import {
Authenticated,
Unauthenticated,
useConvexAuth,
useMutation,
useQuery,
} from "convex/react";
Expand All @@ -29,6 +30,7 @@ export default function PlayPage() {
const userMapResults = useQuery(api.playerresults.getUserMapStatus);
const mapCountResults = useQuery(api.playerresults.getMapsWins);
const adminDeleteMapMutation = useMutation(api.maps.deleteMap);
const { isAuthenticated } = useConvexAuth();

const [resMap, setResMap] = useState(new Map());
const [countMap, setCountMap] = useState(new Map());
Expand Down Expand Up @@ -68,6 +70,7 @@ export default function PlayPage() {
}, [userMapResults, mapCountResults]);

const filteredMaps = maps?.filter((map) => {
if (!isAuthenticated) return true;
if (filter === "all") return true;
if (filter === "beaten") return resMap.get(map._id);
if (filter === "unbeaten") return !resMap.get(map._id);
Expand Down
6 changes: 2 additions & 4 deletions convex/maps.ts
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,6 @@ export const seedMaps = internalMutation({
},
});


export const getUnreviewedMaps = adminQueryBuilder({
handler: async (ctx) => {
return await ctx.db
Expand All @@ -202,10 +201,9 @@ export const getUnreviewedMaps = adminQueryBuilder({
});

export const getMaps = query({
args: {
},
args: {},
handler: async (ctx, args) => {
return await ctx.db
return await ctx.db
.query("maps")
.withIndex("by_isReviewed_level", (q) => q.eq("isReviewed", true))
.collect();
Expand Down
3 changes: 2 additions & 1 deletion convex/schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ export default defineSchema({
grid: v.array(v.array(v.string())),
submittedBy: v.optional(v.id("users")),
isReviewed: v.boolean(),
}).index("by_level", ["level"])
})
.index("by_level", ["level"])
.index("by_isReviewed_level", ["isReviewed", "level"]),
scores: defineTable({
modelId: v.string(),
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
"openai": "^4.67.3",
"react": "^18",
"react-dom": "^18",
"sharp": "^0.33.5",
"tailwind-merge": "^2.4.0",
"tailwindcss-animate": "^1.0.7",
"zod": "^3.23.8"
Expand Down

0 comments on commit de21ec5

Please sign in to comment.