Skip to content

Commit

Permalink
YAY
Browse files Browse the repository at this point in the history
  • Loading branch information
lacymorrow committed Aug 17, 2024
1 parent d00c373 commit c209aad
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 8 deletions.
4 changes: 4 additions & 0 deletions src/config/strings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,10 @@ export const $actions = {
};

export const $dialog = {
add: {
title: 'Add Media',
buttonLabel: 'Add',
},
error: {
title: 'An error occurred',
ignore: 'Ignore',
Expand Down
2 changes: 1 addition & 1 deletion src/main/media.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,14 +40,14 @@ const parseFileMeta = ({ filename, ext }: MediaType) => {

case 'parse':
default: {
// const parsed = ptf(filename, { extra: /.+/ }, { extra: 'boolean' });
const parsed = ptf(filename + ext);

const extWithoutDot = ext.replace('.', '');

if (String(parsed.title).endsWith(extWithoutDot)) {
parsed.title = parsed.title.replace(extWithoutDot, '');
}

meta = {
...meta,
...parsed,
Expand Down
13 changes: 7 additions & 6 deletions src/renderer/components/media/MediaBrowser.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import { SectionHeader } from '@/renderer/components/ui/SectionHeader';
import { GridIcon, ListIcon } from '@/renderer/config/icons';
import { useGlobalContext } from '@/renderer/context/global-context';
import { MediaType } from '@/types/file';
import { getUUID } from '@/utils/getUUID';

import { BookmarkIcon } from '@radix-ui/react-icons';
import React from 'react';
Expand Down Expand Up @@ -48,12 +49,12 @@ export function MediaBrowser({
};
return (
<ScrollContainer>
{items.length === 0 ? (
{items?.length === 0 ? (
<>
<SectionHeader
title={title}
tagline={tagline}
className="flex items-start flex-col-reverse md:flex-row md:items-center justify-between gap-4"
className="flex items-start flex-col-reverse md:flex-row md:items-start justify-between gap-4"
>
{addMediaButton && <ButtonAddMedia />}
</SectionHeader>
Expand All @@ -65,7 +66,7 @@ export function MediaBrowser({
className="space-y-6 h-full min-h-0 flex flex-col"
onValueChange={handleViewChange}
>
<div className="flex items-start flex-col-reverse md:flex-row md:items-center justify-between gap-4 select-none">
<div className="flex items-start flex-col-reverse md:flex-row md:items-start justify-between gap-4 select-none">
<TabsList className="grow-0">
<TabsTrigger value="grid" className="relative flex gap-2">
<GridIcon /> {$ui.view.grid}
Expand All @@ -83,9 +84,9 @@ export function MediaBrowser({

<TabsContent value="grid" className="border-none p-0 outline-none">
<div className="flex gap-6 pb-6 flex-wrap">
{items.map((media: MediaType) => (
{items?.map((media: MediaType) => (
<MediaArtwork
key={crypto.randomUUID()}
key={getUUID()}
media={media}
className="w-[250px]"
aspectRatio="portrait"
Expand All @@ -112,7 +113,7 @@ export function MediaBrowser({
</TableRow>
</TableHeader>
<TableBody>
{items.map((media: MediaType) => (
{items?.map((media: MediaType) => (
<TableRow key={media.id}>
<TableCell className="font-medium">{media.title}</TableCell>
<TableCell>{media.year}</TableCell>
Expand Down
3 changes: 2 additions & 1 deletion src/renderer/windows/main/pages/Library.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { ScrollContainer } from '@/renderer/components/ui/ScrollContainer';
import { SectionHeader } from '@/renderer/components/ui/SectionHeader';
import { useLibraryContext } from '@/renderer/context/library-context';
import { MediaType } from '@/types/file';
import { getUUID } from '@/utils/getUUID';

type Props = {};

Expand All @@ -31,7 +32,7 @@ export function Library(_props: Props) {
<div className="flex space-x-4 pb-4">
{libraryArray.map((media: MediaType) => (
<MediaArtwork
key={crypto.randomUUID()}
key={getUUID()}
media={media}
className="w-[250px]"
aspectRatio="portrait"
Expand Down

0 comments on commit c209aad

Please sign in to comment.