mirror of
https://github.com/eliasstepanik/strudel-docker.git
synced 2026-01-11 05:38:34 +00:00
Merge pull request #1297 from daslyfe/jade/fix/importerror
Hotfix: prevent undefined pattern code from crashing strudel on load
This commit is contained in:
commit
c0b3187029
@ -1,6 +1,11 @@
|
||||
const ALLOW_MANY = ['by', 'url', 'genre', 'license'];
|
||||
import { defaultCode } from './user_pattern_utils.mjs';
|
||||
|
||||
export function getMetadata(raw_code) {
|
||||
if (raw_code == null) {
|
||||
console.error('could not extract metadata from missing pattern code');
|
||||
raw_code = defaultCode;
|
||||
}
|
||||
const comment_regexp = /\/\*([\s\S]*?)\*\/|\/\/(.*)$/gm;
|
||||
const comments = [...raw_code.matchAll(comment_regexp)].map((c) => (c[1] || c[2] || '').trim());
|
||||
const tags = {};
|
||||
|
||||
@ -27,14 +27,10 @@ export function PatternLabel({ pattern } /* : { pattern: Tables<'code'> } */) {
|
||||
const date = new Date(pattern.created_at);
|
||||
if (!isNaN(date)) {
|
||||
title = date.toLocaleDateString();
|
||||
} else {
|
||||
title = 'unnamed';
|
||||
}
|
||||
}
|
||||
if (title == null) {
|
||||
title = pattern.hash;
|
||||
}
|
||||
if (title == null) {
|
||||
title = 'unnamed';
|
||||
}
|
||||
|
||||
const author = Array.isArray(meta.by) ? meta.by.join(',') : 'Anonymous';
|
||||
return <>{`${pattern.id}: ${title} by ${author.slice(0, 100)}`.slice(0, 60)}</>;
|
||||
|
||||
@ -111,7 +111,7 @@ export function useActivePattern() {
|
||||
|
||||
export const setLatestCode = (code) => settingsMap.setKey('latestCode', code);
|
||||
|
||||
const defaultCode = '';
|
||||
export const defaultCode = '';
|
||||
export const userPattern = {
|
||||
collection: patternFilterName.user,
|
||||
getAll() {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user