tangled
alpha
login
or
join now
danabra.mov
/
sidetrail
49
fork
atom
an app to share curated trails
sidetrail.app
atproto
nextjs
react
rsc
49
fork
atom
overview
issues
pulls
pipelines
avoid extra roundtrips
danabra.mov
3 months ago
43668a7e
93bcda41
+11
-11
3 changed files
expand all
collapse all
unified
split
app
at
(trail)
[handle]
trail
[rkey]
TrailOverview.tsx
TrailWalk.tsx
data
actions.ts
+1
-6
app/at/(trail)/[handle]/trail/[rkey]/TrailOverview.tsx
···
55
55
requireAuth();
56
56
if (!trail.yourWalk && !isEditing) {
57
57
await startWalk(trail.header.uri, trail.header.cid);
58
58
-
router.refresh();
59
59
-
onModeChange("walk");
60
60
-
} else {
61
61
-
onModeChange("walk");
62
58
}
59
59
+
onModeChange("walk");
63
60
};
64
61
65
62
const handleAbandon = async () => {
66
63
if (confirm("abandon this trail? your progress will be lost")) {
67
64
if (trail.yourWalk) {
68
65
await abandonWalk(trail.yourWalk!.uri);
69
69
-
router.refresh();
70
66
}
71
67
}
72
68
};
···
331
327
onDelete={async () => {
332
328
if (confirm("forget this trail? it will be like you never walked here")) {
333
329
await forgetTrail(trail.header.uri);
334
334
-
router.refresh();
335
330
}
336
331
}}
337
332
/>
-5
app/at/(trail)/[handle]/trail/[rkey]/TrailWalk.tsx
···
1
1
import { useState, useLayoutEffect, useRef, Suspense, Activity, type ReactNode } from "react";
2
2
-
import { useRouter } from "next/navigation";
3
2
import type { TrailDetailData } from "@/data/queries";
4
3
import { BackButton } from "@/app/BackButton";
5
4
import { TrailProgress } from "./TrailProgress";
···
55
54
}: Props) {
56
55
const { header, stops, yourWalk } = trail;
57
56
const initialEmbedsMap = new Map(initialEmbeds);
58
58
-
const router = useRouter();
59
57
const requireAuth = useAuthAction();
60
58
61
59
const [currentStopIndex, setCurrentStopIndex] = useState(() => {
···
172
170
} else {
173
171
if (!isEditMode && yourWalk) {
174
172
await completeTrail(yourWalk.uri);
175
175
-
router.refresh();
176
173
setTimeout(() => {
177
174
setIsCompleted(true);
178
175
queueScroll("end");
···
202
199
if (confirm("abandon this trail? your progress will be lost")) {
203
200
if (yourWalk) {
204
201
await abandonWalk(yourWalk.uri);
205
205
-
router.refresh();
206
202
onModeChange("overview");
207
203
}
208
204
}
···
337
333
onDelete={async (key) => {
338
334
if (confirm("delete this completion?")) {
339
335
await deleteCompletion(key);
340
340
-
router.refresh();
341
336
}
342
337
}}
343
338
/>
+10
data/actions.ts
···
104
104
{ rkey },
105
105
);
106
106
});
107
107
+
108
108
+
refresh();
107
109
}
108
110
109
111
export async function visitStop(walkUri: string, stopTid: string): Promise<void> {
···
215
217
await client.delete(walk.main, { rkey: w.rkey });
216
218
}
217
219
});
220
220
+
221
221
+
refresh();
218
222
}
219
223
220
224
export async function abandonWalk(walkUri: string): Promise<void> {
···
244
248
await client.delete(walk.main, { rkey: w.rkey });
245
249
}
246
250
});
251
251
+
252
252
+
refresh();
247
253
}
248
254
249
255
// ============================================================================
···
261
267
after(async () => {
262
268
await client.delete(completion.main, { rkey: completionRkey });
263
269
});
270
270
+
271
271
+
refresh();
264
272
}
265
273
266
274
export async function forgetTrail(trailUri: string): Promise<void> {
···
295
303
await client.delete(completion.main, { rkey: c.rkey });
296
304
}
297
305
});
306
306
+
307
307
+
refresh();
298
308
}
299
309
300
310
// ============================================================================