Merge pull request #934 from daslyfe/patterntab_fix
Fix pattern tab not showing patterns without created date
This commit is contained in:
commit
46c2c72637
1 changed files with 4 additions and 4 deletions
|
|
@ -19,13 +19,13 @@ function classNames(...classes) {
|
||||||
|
|
||||||
export function PatternLabel({ pattern } /* : { pattern: Tables<'code'> } */) {
|
export function PatternLabel({ pattern } /* : { pattern: Tables<'code'> } */) {
|
||||||
const meta = useMemo(() => getMetadata(pattern.code), [pattern]);
|
const meta = useMemo(() => getMetadata(pattern.code), [pattern]);
|
||||||
|
|
||||||
let title = meta.title;
|
let title = meta.title;
|
||||||
if (title == null) {
|
if (title == null) {
|
||||||
const date = new Date(pattern.created_at);
|
const date = new Date(pattern.created_at);
|
||||||
if (isNaN(date)) {
|
if (!isNaN(date)) {
|
||||||
return;
|
title = date.toLocaleDateString();
|
||||||
}
|
}
|
||||||
title = date.toLocaleDateString();
|
|
||||||
}
|
}
|
||||||
if (title == null) {
|
if (title == null) {
|
||||||
title = pattern.hash;
|
title = pattern.hash;
|
||||||
|
|
@ -33,7 +33,6 @@ export function PatternLabel({ pattern } /* : { pattern: Tables<'code'> } */) {
|
||||||
if (title == null) {
|
if (title == null) {
|
||||||
title = 'unnamed';
|
title = 'unnamed';
|
||||||
}
|
}
|
||||||
|
|
||||||
return <>{`${pattern.id}: ${title} by ${Array.isArray(meta.by) ? meta.by.join(',') : 'Anonymous'}`}</>;
|
return <>{`${pattern.id}: ${title} by ${Array.isArray(meta.by) ? meta.by.join(',') : 'Anonymous'}`}</>;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -91,6 +90,7 @@ export function PatternsTab({ context }) {
|
||||||
const viewingPatternData = parseJSON(viewingPatternStore);
|
const viewingPatternData = parseJSON(viewingPatternStore);
|
||||||
|
|
||||||
const { userPatterns, patternFilter } = useSettings();
|
const { userPatterns, patternFilter } = useSettings();
|
||||||
|
|
||||||
const examplePatterns = useExamplePatterns();
|
const examplePatterns = useExamplePatterns();
|
||||||
const collections = examplePatterns.collections;
|
const collections = examplePatterns.collections;
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue