Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix pattern tab not showing patterns without created date #934

Merged
merged 2 commits into from
Jan 21, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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