Merge branch 'dev'
This commit is contained in:
commit
8459d979b1
|
|
@ -884,6 +884,23 @@ export function clearShapes(slug: string): void {
|
|||
if (doc) {
|
||||
const newDoc = Automerge.change(doc, "Clear all shapes", (d) => {
|
||||
d.shapes = {};
|
||||
// Reset seeded flag so demo reset can re-seed
|
||||
(d.meta as any).shapesSeeded = false;
|
||||
});
|
||||
communities.set(slug, newDoc);
|
||||
saveCommunity(slug);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Mark a community as having been seeded with shapes.
|
||||
* Prevents re-seeding after users delete all content.
|
||||
*/
|
||||
export function markShapesSeeded(slug: string): void {
|
||||
const doc = communities.get(slug);
|
||||
if (doc) {
|
||||
const newDoc = Automerge.change(doc, "Mark shapes seeded", (d) => {
|
||||
(d.meta as any).shapesSeeded = true;
|
||||
});
|
||||
communities.set(slug, newDoc);
|
||||
saveCommunity(slug);
|
||||
|
|
|
|||
|
|
@ -19,6 +19,7 @@ import {
|
|||
createCommunity,
|
||||
getDocumentData,
|
||||
loadCommunity,
|
||||
markShapesSeeded,
|
||||
} from "./community-store";
|
||||
|
||||
// ── Layout constants ────────────────────────────────────────────
|
||||
|
|
@ -481,15 +482,17 @@ export async function ensureCampaignDemo(): Promise<void> {
|
|||
// Check if already seeded
|
||||
const data = getDocumentData(slug);
|
||||
const shapeCount = data ? Object.keys(data.shapes || {}).length : 0;
|
||||
const alreadySeeded = (data?.meta as any)?.shapesSeeded === true;
|
||||
|
||||
if (shapeCount === 0) {
|
||||
if (shapeCount === 0 && !alreadySeeded) {
|
||||
addShapes(slug, CAMPAIGN_SHAPES);
|
||||
markShapesSeeded(slug);
|
||||
console.log(
|
||||
`[Campaign] Seeded ${CAMPAIGN_SHAPES.length} shapes into campaign-demo`,
|
||||
);
|
||||
} else {
|
||||
console.log(
|
||||
`[Campaign] campaign-demo already has ${shapeCount} shapes`,
|
||||
`[Campaign] campaign-demo already has ${shapeCount} shapes (seeded=${alreadySeeded})`,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -13,6 +13,7 @@ import {
|
|||
createCommunity,
|
||||
getDocumentData,
|
||||
loadCommunity,
|
||||
markShapesSeeded,
|
||||
} from "./community-store";
|
||||
|
||||
// ── Alpine Explorer 2026 — Demo Scenario ──────────────────────────
|
||||
|
|
@ -781,14 +782,16 @@ export async function ensureDemoCommunity(): Promise<void> {
|
|||
await loadCommunity("demo");
|
||||
}
|
||||
|
||||
// Check if already seeded (has shapes)
|
||||
// Check if already seeded (has shapes or was previously seeded then cleared)
|
||||
const data = getDocumentData("demo");
|
||||
const shapeCount = data ? Object.keys(data.shapes || {}).length : 0;
|
||||
const alreadySeeded = (data?.meta as any)?.shapesSeeded === true;
|
||||
|
||||
if (shapeCount === 0) {
|
||||
if (shapeCount === 0 && !alreadySeeded) {
|
||||
addShapes("demo", DEMO_SHAPES);
|
||||
markShapesSeeded("demo");
|
||||
console.log(`[Demo] Seeded ${DEMO_SHAPES.length} shapes into demo community`);
|
||||
} else {
|
||||
console.log(`[Demo] Demo community already has ${shapeCount} shapes`);
|
||||
console.log(`[Demo] Demo community already has ${shapeCount} shapes (seeded=${alreadySeeded})`);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -14,6 +14,7 @@ import {
|
|||
getDocumentData,
|
||||
listCommunities,
|
||||
loadCommunity,
|
||||
markShapesSeeded,
|
||||
} from "./community-store";
|
||||
|
||||
// ── Template Shapes ─────────────────────────────────────────────────
|
||||
|
|
@ -418,12 +419,14 @@ export function seedTemplateShapes(slug: string): boolean {
|
|||
|
||||
const data = getDocumentData(slug);
|
||||
const shapeCount = data ? Object.keys(data.shapes || {}).length : 0;
|
||||
const alreadySeeded = (data?.meta as any)?.shapesSeeded === true;
|
||||
|
||||
if (shapeCount > 0) {
|
||||
if (shapeCount > 0 || alreadySeeded) {
|
||||
return false;
|
||||
}
|
||||
|
||||
addShapes(slug, TEMPLATE_SHAPES);
|
||||
markShapesSeeded(slug);
|
||||
console.log(`[Template] Seeded ${TEMPLATE_SHAPES.length} template shapes into "${slug}"`);
|
||||
return true;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue