From 87072c5617468fe4be4f31d7143b92442d4b9426 Mon Sep 17 00:00:00 2001 From: Aleix Soler Date: Thu, 19 Mar 2026 12:34:12 +0100 Subject: [PATCH] fix(templates): correctly evaluate custom vs marketplace templates based on internal lists instead of checking if it has an author --- utils/templateUtils.ts | 24 +++++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-) diff --git a/utils/templateUtils.ts b/utils/templateUtils.ts index a4d9d1a..778e97e 100644 --- a/utils/templateUtils.ts +++ b/utils/templateUtils.ts @@ -1,12 +1,15 @@ import { StatusTemplate } from "@/types/pluginSettings"; import settingsService from "@/core/settingsService"; -import { PREDEFINED_TEMPLATES } from "@/constants/predefinedTemplates"; +import { + PREDEFINED_TEMPLATES, + COMMUNITY_TEMPLATES, +} from "@/constants/predefinedTemplates"; /** * Check if a template is a custom user template (not from marketplace) */ export const isCustomTemplate = (template: StatusTemplate): boolean => { - // Either matches an original marketplace template ID + // Either matches an original predefined template const matchesPredefined = PREDEFINED_TEMPLATES.some( (pt) => pt.id === template.id || @@ -14,9 +17,13 @@ export const isCustomTemplate = (template: StatusTemplate): boolean => { ); if (matchesPredefined) return false; - // Or has metadata from marketplace - const hasMetadata = !!template.authorGithub; - if (hasMetadata) return false; + // Or matches an original community template + const matchesCommunity = COMMUNITY_TEMPLATES.some( + (ct) => + ct.id === template.id || + ct.name.toLowerCase() === template.name.toLowerCase(), + ); + if (matchesCommunity) return false; return true; }; @@ -25,7 +32,11 @@ export const isCustomTemplate = (template: StatusTemplate): boolean => { * Check if a marketplace template has been modified by the user */ export const isTemplateModified = (template: StatusTemplate): boolean => { - const original = PREDEFINED_TEMPLATES.find( + const allMarketplaceTemplates = [ + ...PREDEFINED_TEMPLATES, + ...COMMUNITY_TEMPLATES, + ]; + const original = allMarketplaceTemplates.find( (pt) => pt.id === template.id || pt.name.toLowerCase() === template.name.toLowerCase(), @@ -104,4 +115,3 @@ export const generateTemplateId = ( return id; }; -