Skip to content

Commit 833a057

Browse files
Fix note image duplication on navigate (#1047)
Co-authored-by: Kent C. Dodds <[email protected]>
1 parent 0921caa commit 833a057

File tree

4 files changed

+14
-11
lines changed

4 files changed

+14
-11
lines changed

app/routes/users+/$username_+/notes.$noteId.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ export async function loader({ params }: Route.LoaderArgs) {
3232
updatedAt: true,
3333
images: {
3434
select: {
35+
id: true,
3536
altText: true,
3637
objectKey: true,
3738
},
@@ -123,7 +124,7 @@ export default function NoteRoute({
123124
<div className={`${displayBar ? 'pb-24' : 'pb-12'} overflow-y-auto`}>
124125
<ul className="flex flex-wrap gap-5 py-5">
125126
{loaderData.note.images.map((image) => (
126-
<li key={image.objectKey}>
127+
<li key={image.id}>
127128
<a href={getNoteImgSrc(image.objectKey)}>
128129
<Img
129130
src={getNoteImgSrc(image.objectKey)}

app/utils/cache.server.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import fs from 'node:fs'
22
import path from 'node:path'
3+
import { DatabaseSync } from 'node:sqlite'
34
import {
45
cachified as baseCachified,
56
verboseReporter,
@@ -13,7 +14,6 @@ import {
1314
} from '@epic-web/cachified'
1415
import { remember } from '@epic-web/remember'
1516
import { LRUCache } from 'lru-cache'
16-
import { DatabaseSync } from 'node:sqlite'
1717
import { z } from 'zod'
1818
import { updatePrimaryCacheValue } from '#app/routes/admin+/cache_.sqlite.server.ts'
1919
import { getInstanceInfo, getInstanceInfoSync } from './litefs.server.ts'

prisma/seed.ts

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -54,19 +54,21 @@ async function seed() {
5454

5555
// Add images to note
5656
const noteImageCount = faker.number.int({ min: 1, max: 3 })
57-
for (let imageIndex = 0; imageIndex < noteImageCount; imageIndex++) {
58-
const imgNumber = faker.number.int({ min: 0, max: 9 })
59-
const noteImage = noteImages[imgNumber]
60-
if (noteImage) {
61-
await prisma.noteImage.create({
57+
const selectedImages = faker.helpers.arrayElements(
58+
noteImages,
59+
noteImageCount,
60+
)
61+
await Promise.all(
62+
selectedImages.map((noteImage) =>
63+
prisma.noteImage.create({
6264
data: {
6365
noteId: note.id,
6466
altText: noteImage.altText,
6567
objectKey: noteImage.objectKey,
6668
},
67-
})
68-
}
69-
}
69+
}),
70+
),
71+
)
7072
}
7173
}
7274
console.timeEnd(`👤 Created ${totalUsers} users...`)

tests/e2e/passkey.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ test('Users can register and use passkeys', async ({
2424
navigate,
2525
login,
2626
}) => {
27-
const user = await login()
27+
await login()
2828

2929
const { client, authenticatorId } = await setupWebAuthn(page)
3030

0 commit comments

Comments
 (0)