Skip to content

Commit

Permalink
Merge pull request #934 from daslyfe/patterntab_fix
Browse files Browse the repository at this point in the history
Fix pattern tab not showing patterns without created date
  • Loading branch information
daslyfe committed Jan 21, 2024
2 parents 2cc428e + c088590 commit 46c2c72
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions website/src/repl/panel/PatternsTab.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,21 +19,20 @@ function classNames(...classes) {

export function PatternLabel({ pattern } /* : { pattern: Tables<'code'> } */) {
const meta = useMemo(() => getMetadata(pattern.code), [pattern]);

let title = meta.title;
if (title == null) {
const date = new Date(pattern.created_at);
if (isNaN(date)) {
return;
if (!isNaN(date)) {
title = date.toLocaleDateString();
}
title = date.toLocaleDateString();
}
if (title == null) {
title = pattern.hash;
}
if (title == null) {
title = 'unnamed';
}

return <>{`${pattern.id}: ${title} by ${Array.isArray(meta.by) ? meta.by.join(',') : 'Anonymous'}`}</>;
}

Expand Down Expand Up @@ -91,6 +90,7 @@ export function PatternsTab({ context }) {
const viewingPatternData = parseJSON(viewingPatternStore);

const { userPatterns, patternFilter } = useSettings();

const examplePatterns = useExamplePatterns();
const collections = examplePatterns.collections;

Expand Down

0 comments on commit 46c2c72

Please sign in to comment.