[READ-ONLY] Mirror of https://github.com/flo-bit/skywatched. review movies and tv shows, based on at proto skywatched.app
0

Configure Feed

Select the types of activity you want to include in your feed.

Merge branch 'main' into v2

Florian (Dec 8, 2024, 6:15 PM +0100) 2fe526d7 0f81893a

+28 -14
+1 -1
src/lib/Components/MovieGrid.svelte
··· 8 8 showMark, 9 9 watchedMovies 10 10 }: { 11 - movies: { poster_path: string; original_title: string; id: number }[]; 11 + movies: { poster_path: string; original_title: string; id: number; movieId: number }[]; 12 12 class?: string; 13 13 showMark?: boolean; 14 14 watchedMovies?: Set<number>;
+2 -1
src/lib/server/db/schema.ts
··· 16 16 }); 17 17 18 18 export const movies = sqliteTable('movies', { 19 - id: integer('id').primaryKey(), 19 + id: text('id').primaryKey(), 20 + movieId: integer('movie_id').notNull(), 20 21 username: text('username') 21 22 .notNull() 22 23 .references(() => user.username),
+1 -1
src/lib/server/movies.ts
··· 83 83 const movie = await db 84 84 .select() 85 85 .from(table.movies) 86 - .where(and(eq(table.movies.id, id), eq(table.movies.username, username))); 86 + .where(and(eq(table.movies.movieId, id), eq(table.movies.username, username))); 87 87 88 88 if (movie.length > 0) return movie[0].watched; 89 89
+12 -6
src/routes/+layout.svelte
··· 18 18 <a 19 19 href="/search" 20 20 class="text-sm/6 font-semibold text-white transition-colors duration-75 hover:text-accent-400" 21 - > 21 + > 22 22 <span class="sr-only">add movie</span> 23 - <svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor" class="size-6"> 23 + <svg 24 + xmlns="http://www.w3.org/2000/svg" 25 + fill="none" 26 + viewBox="0 0 24 24" 27 + stroke-width="1.5" 28 + stroke="currentColor" 29 + class="size-6" 30 + > 24 31 <path stroke-linecap="round" stroke-linejoin="round" d="M12 4.5v15m7.5-7.5h-15" /> 25 - </svg> 26 - </a 27 - > 32 + </svg> 33 + </a> 28 34 {/if} 29 - <a 35 + <a 30 36 href="/login" 31 37 class="text-sm/6 font-semibold text-white transition-colors duration-75 hover:text-accent-400" 32 38 >account <span aria-hidden="true">&rarr;</span></a
+9 -3
src/routes/movie/[id]/+page.server.ts
··· 40 40 41 41 const result = await getDetails(movieId); 42 42 43 + // check if user has watched this movie 44 + const movie = await db 45 + .select() 46 + .from(table.movies) 47 + .where(and(eq(table.movies.movieId, movieId), eq(table.movies.username, username))); 43 48 const watched = await checkWatched(movieId, username); 44 49 45 50 if (watched !== false) { 46 51 await db 47 52 .update(table.movies) 48 - .set({ watched: watched ? 0 : 1 }) 49 - .where(and(eq(table.movies.id, movieId), eq(table.movies.username, username))); 53 + .set({ watched: movie[0].watched !== 0 ? 0 : 1 }) 54 + .where(eq(table.movies.movieId, movieId)); 50 55 } else { 51 56 await db.insert(table.movies).values({ 52 57 username, 53 - id: movieId, 58 + id: crypto.randomUUID(), 59 + movieId: movieId, 54 60 watched: 1, 55 61 originalTitle: result.original_title, 56 62 posterPath: result.poster_path,
+1 -1
src/routes/search/+page.server.ts
··· 17 17 if (query) { 18 18 const results = await searchMovie(query); 19 19 20 - return { results, query }; 20 + return { results: results.map((result) => ({ ...result, movieId: result.id })), query }; 21 21 } 22 22 23 23 return { results: [], query };
+2 -1
src/routes/user/[username]/+page.svelte
··· 22 22 movies={data.movies.map((movie) => ({ 23 23 poster_path: movie.posterPath ?? '', 24 24 original_title: movie.originalTitle, 25 - id: movie.id 25 + id: movie.id, 26 + movieId: movie.movieId 26 27 }))} 27 28 /> 28 29 </Container>