fixed if statement
This commit is contained in:
parent
2cc428e968
commit
192ba69682
1 changed files with 6 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'}`}</>;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -56,6 +55,8 @@ function PatternButtons({ patterns, activePattern, onClick, started }) {
|
||||||
const viewingPatternStore = useViewingPatternData();
|
const viewingPatternStore = useViewingPatternData();
|
||||||
const viewingPatternData = parseJSON(viewingPatternStore);
|
const viewingPatternData = parseJSON(viewingPatternStore);
|
||||||
const viewingPatternID = viewingPatternData.id;
|
const viewingPatternID = viewingPatternData.id;
|
||||||
|
|
||||||
|
console.log({ patterns });
|
||||||
return (
|
return (
|
||||||
<div className="font-mono text-sm">
|
<div className="font-mono text-sm">
|
||||||
{Object.values(patterns)
|
{Object.values(patterns)
|
||||||
|
|
@ -91,6 +92,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