Skip to content

Commit d0e5949

Browse files
committed
🚡🏼🦯 ↝ [efmz96]: Cleaning up dev tools and an urgent bug fix
1 parent 46f5f5a commit d0e5949

File tree

31 files changed

+178
-278
lines changed

31 files changed

+178
-278
lines changed

β€Ž.DS_Storeβ€Ž

0 Bytes
Binary file not shown.

β€Žapp/game/page.tsxβ€Ž

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,7 @@ export default function GamePage() {
126126
profile,
127127
classifications,
128128
otherClassifications,
129+
loading,
129130
} = usePageData();
130131

131132
const { showNpsModal, handleCloseNps } = useNPSManagement();
@@ -281,7 +282,9 @@ export default function GamePage() {
281282
}
282283

283284
// Lightweight skeleton while data loads to avoid blocking on dynamic chunk hydration.
284-
if (!classifications.length && activityFeed.length === 0) {
285+
// Important: do not gate the entire page on having data, or new users will see the
286+
// skeleton forever.
287+
if (loading) {
285288
return (
286289
<div className="min-h-screen w-full relative flex justify-center">
287290
<div className="fixed inset-0 -z-10 bg-gradient-to-b from-background via-background to-background" />

β€Žhooks/usePageData.tsβ€Ž

Lines changed: 43 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -207,20 +207,21 @@ export function usePageData() {
207207
}
208208

209209
setLoading(true);
210-
const userId = session.user.id;
211-
212-
// Fetch profile data
213-
const { data: profileData } = await supabase
214-
.from("profiles")
215-
.select("id, username, full_name, classificationPoints")
216-
.eq("id", userId)
217-
.maybeSingle();
218-
setProfile(profileData);
219-
220-
// Fetch user's classifications
221-
const { data: myClassifications } = await supabase
222-
.from("classifications")
223-
.select(`
210+
try {
211+
const userId = session.user.id;
212+
213+
// Fetch profile data
214+
const { data: profileData } = await supabase
215+
.from("profiles")
216+
.select("id, username, full_name, classificationPoints")
217+
.eq("id", userId)
218+
.maybeSingle();
219+
setProfile(profileData);
220+
221+
// Fetch user's classifications
222+
const { data: myClassifications } = await supabase
223+
.from("classifications")
224+
.select(`
224225
id,
225226
classificationtype,
226227
content,
@@ -229,28 +230,28 @@ export function usePageData() {
229230
anomaly:anomaly(content),
230231
classificationConfiguration
231232
`)
232-
.eq("author", userId)
233-
.order("created_at", { ascending: false })
234-
.limit(10);
235-
236-
// Transform the data to match our interface
237-
const transformedClassifications = (myClassifications ?? []).map(c => ({
238-
...c,
239-
anomaly: Array.isArray(c.anomaly) ? c.anomaly[0] : c.anomaly
240-
}));
241-
setClassifications(transformedClassifications);
242-
243-
// Get all anomaly IDs that have been classified by this user
244-
const { data: userClassifications } = await supabase
245-
.from("classifications")
246-
.select("anomaly")
247-
.eq("author", userId);
233+
.eq("author", userId)
234+
.order("created_at", { ascending: false })
235+
.limit(10);
236+
237+
// Transform the data to match our interface
238+
const transformedClassifications = (myClassifications ?? []).map(c => ({
239+
...c,
240+
anomaly: Array.isArray(c.anomaly) ? c.anomaly[0] : c.anomaly
241+
}));
242+
setClassifications(transformedClassifications);
248243

249-
const classifiedAnomalyIds = new Set(
250-
(userClassifications ?? [])
251-
.map(c => c.anomaly)
252-
.filter((id): id is number => !!id)
253-
);
244+
// Get all anomaly IDs that have been classified by this user
245+
const { data: userClassifications } = await supabase
246+
.from("classifications")
247+
.select("anomaly")
248+
.eq("author", userId);
249+
250+
const classifiedAnomalyIds = new Set(
251+
(userClassifications ?? [])
252+
.map(c => c.anomaly)
253+
.filter((id): id is number => !!id)
254+
);
254255

255256
// Fetch all linked anomalies for the user
256257
// Note: The unlocked column may not exist in all environments, so we handle it gracefully
@@ -422,7 +423,7 @@ export function usePageData() {
422423
balloons: transformedClassifications.length >= 10 // Show after 10 total classifications
423424
});
424425

425-
setCachedData({
426+
setCachedData({
426427
linkedAnomalies: filteredLinked,
427428
activityFeed: allActivity.sort((a, b) => new Date(b.created_at).getTime() - new Date(a.created_at).getTime()),
428429
profile: profileData,
@@ -437,9 +438,12 @@ export function usePageData() {
437438
balloons: transformedClassifications.length >= 10
438439
},
439440
hasRoverMineralDeposits: (roverDeposits ?? []).length > 0,
440-
});
441-
442-
setLoading(false);
441+
});
442+
} catch (e) {
443+
console.error("usePageData fetchData failed", e);
444+
} finally {
445+
setLoading(false);
446+
}
443447
};
444448

445449
useEffect(() => {

β€Žpublic/sw.jsβ€Ž

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

β€Žsrc/components/deployment/missions/structures/Astronomers/PlanetHunters/PHVote.tsxβ€Ž

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -69,9 +69,6 @@ export default function VotePlanetClassifications({ classificationId }: VotePlan
6969

7070
const handleVote = async (classificationId: number, currentConfig: any) => {
7171
try {
72-
console.log("PHVote: Starting vote submission...");
73-
console.log("PHVote: Classification ID:", classificationId);
74-
console.log("PHVote: Current config:", currentConfig);
7572

7673
const currentVotes = currentConfig?.votes || 0;
7774

@@ -80,43 +77,32 @@ export default function VotePlanetClassifications({ classificationId }: VotePlan
8077
votes: currentVotes + 1,
8178
};
8279

83-
console.log("PHVote: Updated config:", updatedConfig);
80+
8481

8582
const { error } = await supabase
8683
.from("classifications")
8784
.update({ classificationConfiguration: updatedConfig })
8885
.eq("id", classificationId);
89-
90-
console.log("PHVote: Database update completed, error:", error);
91-
9286
if (error) {
9387
console.error("PHVote: Error updating classificationConfiguration:", error);
9488
} else {
95-
console.log("PHVote: Vote successful, updating state...");
9689
setClassification((prev: any) =>
9790
prev ? { ...prev, votes: updatedConfig.votes } : prev
9891
);
9992

10093
// Show success popup
101-
console.log("PHVote: Setting vote popup to true");
10294
setShowSuccessPopup(true);
103-
console.log("PHVote: Popup state set, current showSuccessPopup should be true");
10495

10596
// Redirect after 3 seconds
106-
console.log("PHVote: Setting vote redirect timeout");
10797
const redirectTimeout = setTimeout(() => {
108-
console.log("PHVote: Attempting redirect to dashboard...");
10998
try {
11099
router.push('/');
111-
console.log("PHVote: Router.push called successfully");
112100
} catch (error) {
113101
console.error("PHVote: Router.push error:", error);
114102
// Fallback to window.location
115103
window.location.href = '/';
116104
}
117105
}, 3000);
118-
119-
console.log("PHVote: Redirect timeout set, ID:", redirectTimeout);
120106
};
121107
} catch (error) {
122108
console.error("PHVote: Error voting:", error);

β€Žsrc/components/deployment/missions/structures/Astronomers/PlanetHunters/PlanetType.tsxβ€Ž

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -164,8 +164,6 @@ const PlanetTypeCommentForm = ({ classificationId }: PlanetTypeCommentFormProps)
164164
.eq("id", commentId);
165165

166166
if (commentError) throw commentError;
167-
168-
console.log("Preferred comment updated successfully.");
169167
} catch (err) {
170168
console.error("Error updating preferred comment:", err);
171169
}
@@ -182,7 +180,6 @@ const PlanetTypeCommentForm = ({ classificationId }: PlanetTypeCommentFormProps)
182180
}
183181

184182
try {
185-
console.log("Inserting comment...");
186183
const { error } = await supabase.from("comments").insert([
187184
{
188185
content: commentInput,
@@ -198,16 +195,10 @@ const PlanetTypeCommentForm = ({ classificationId }: PlanetTypeCommentFormProps)
198195
}
199196

200197
setCommentInputs((prev) => ({ ...prev, [classificationId]: "" }));
201-
console.log("Comment inserted successfully with planet type.");
202-
203-
// Show success popup
204-
console.log("Setting popup to true");
205198
setShowSuccessPopup(true);
206-
199+
207200
// Redirect after 3 seconds
208-
console.log("Setting redirect timeout");
209201
setTimeout(() => {
210-
console.log("Redirecting to dashboard");
211202
router.push('/');
212203
}, 3000);
213204
} catch (err) {

β€Žsrc/components/discovery/data-sources/Astronomers/PlanetHunters/PlanetGenerator.tsxβ€Ž

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -187,13 +187,11 @@ export default function PlanetGenerator({
187187
}));
188188

189189
// Fetch mineral deposits by classification ID (discovery field)
190-
console.log("πŸ” Fetching deposits for classification:", idAsNumber);
191190
const { data: depositsData, error: depositsError } = await supabase
192191
.from("mineralDeposits")
193192
.select("id, mineralconfiguration, location, discovery, anomaly")
194193
.eq("discovery", idAsNumber);
195194

196-
console.log("πŸ“¦ Deposits data:", depositsData, "Error:", depositsError);
197195

198196
if (!depositsError && depositsData) {
199197
const parsedDeposits: MineralDeposit[] = depositsData.map((deposit: any) => {
@@ -253,7 +251,6 @@ export default function PlanetGenerator({
253251
};
254252
});
255253

256-
console.log("βœ… Parsed deposits:", parsedDeposits);
257254
setDeposits(parsedDeposits);
258255
}
259256

@@ -263,7 +260,7 @@ export default function PlanetGenerator({
263260
.select("id, classificationtype, content, classificationConfiguration")
264261
.or(`parentPlanet.eq.${idAsNumber},source_classification_id.eq.${idAsNumber},classificationConfiguration->>parentPlanetLocation.eq.${idAsNumber}`);
265262

266-
console.log("πŸ” Child classifications data:", childClassData, "Error:", childError);
263+
267264

268265
if (!childError && childClassData) {
269266
const parsedChildren: ChildClassification[] = childClassData.map((c: any) => {
@@ -293,7 +290,6 @@ export default function PlanetGenerator({
293290
};
294291
});
295292

296-
console.log("βœ… Parsed child classifications:", parsedChildren);
297293
setChildClassifications(parsedChildren);
298294
}
299295
};

β€Žsrc/components/discovery/data-sources/Astronomers/PlanetHunters/planet.tsxβ€Ž

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,7 @@ export default function Planet({ config, deposits, childClassifications, onDepos
2222
const materialRef = useRef<THREE.ShaderMaterial | null>(null)
2323
const atmosphereRef = useRef<THREE.Mesh>(null)
2424

25-
console.log("πŸͺ Planet rendering with:", {
26-
deposits: deposits?.length || 0,
27-
childClassifications: childClassifications?.length || 0,
28-
config: config.radius
29-
});
25+
// Planet render info: deposits and child classifications counts
3026

3127
// Create shader material with uniforms based on planet config
3228
const shaderMaterial = useMemo(() => {

β€Žsrc/components/layout/Header/MainHeader.tsxβ€Ž

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,8 +75,7 @@ export default function MainHeader({
7575
if (error) {
7676
console.error("Error signing out:", error.message);
7777
} else {
78-
console.log("User signed out successfully");
79-
// Optionally redirect to home page or login page
78+
// Signed out
8079
window.location.href = '/';
8180
}
8281
};

0 commit comments

Comments
Β (0)