Merge branch 'dev'
This commit is contained in:
commit
8459d979b1
|
|
@ -884,6 +884,23 @@ export function clearShapes(slug: string): void {
|
||||||
if (doc) {
|
if (doc) {
|
||||||
const newDoc = Automerge.change(doc, "Clear all shapes", (d) => {
|
const newDoc = Automerge.change(doc, "Clear all shapes", (d) => {
|
||||||
d.shapes = {};
|
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);
|
communities.set(slug, newDoc);
|
||||||
saveCommunity(slug);
|
saveCommunity(slug);
|
||||||
|
|
|
||||||
|
|
@ -19,6 +19,7 @@ import {
|
||||||
createCommunity,
|
createCommunity,
|
||||||
getDocumentData,
|
getDocumentData,
|
||||||
loadCommunity,
|
loadCommunity,
|
||||||
|
markShapesSeeded,
|
||||||
} from "./community-store";
|
} from "./community-store";
|
||||||
|
|
||||||
// ── Layout constants ────────────────────────────────────────────
|
// ── Layout constants ────────────────────────────────────────────
|
||||||
|
|
@ -481,15 +482,17 @@ export async function ensureCampaignDemo(): Promise<void> {
|
||||||
// Check if already seeded
|
// Check if already seeded
|
||||||
const data = getDocumentData(slug);
|
const data = getDocumentData(slug);
|
||||||
const shapeCount = data ? Object.keys(data.shapes || {}).length : 0;
|
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);
|
addShapes(slug, CAMPAIGN_SHAPES);
|
||||||
|
markShapesSeeded(slug);
|
||||||
console.log(
|
console.log(
|
||||||
`[Campaign] Seeded ${CAMPAIGN_SHAPES.length} shapes into campaign-demo`,
|
`[Campaign] Seeded ${CAMPAIGN_SHAPES.length} shapes into campaign-demo`,
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
console.log(
|
console.log(
|
||||||
`[Campaign] campaign-demo already has ${shapeCount} shapes`,
|
`[Campaign] campaign-demo already has ${shapeCount} shapes (seeded=${alreadySeeded})`,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -13,6 +13,7 @@ import {
|
||||||
createCommunity,
|
createCommunity,
|
||||||
getDocumentData,
|
getDocumentData,
|
||||||
loadCommunity,
|
loadCommunity,
|
||||||
|
markShapesSeeded,
|
||||||
} from "./community-store";
|
} from "./community-store";
|
||||||
|
|
||||||
// ── Alpine Explorer 2026 — Demo Scenario ──────────────────────────
|
// ── Alpine Explorer 2026 — Demo Scenario ──────────────────────────
|
||||||
|
|
@ -781,14 +782,16 @@ export async function ensureDemoCommunity(): Promise<void> {
|
||||||
await loadCommunity("demo");
|
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 data = getDocumentData("demo");
|
||||||
const shapeCount = data ? Object.keys(data.shapes || {}).length : 0;
|
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);
|
addShapes("demo", DEMO_SHAPES);
|
||||||
|
markShapesSeeded("demo");
|
||||||
console.log(`[Demo] Seeded ${DEMO_SHAPES.length} shapes into demo community`);
|
console.log(`[Demo] Seeded ${DEMO_SHAPES.length} shapes into demo community`);
|
||||||
} else {
|
} 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,
|
getDocumentData,
|
||||||
listCommunities,
|
listCommunities,
|
||||||
loadCommunity,
|
loadCommunity,
|
||||||
|
markShapesSeeded,
|
||||||
} from "./community-store";
|
} from "./community-store";
|
||||||
|
|
||||||
// ── Template Shapes ─────────────────────────────────────────────────
|
// ── Template Shapes ─────────────────────────────────────────────────
|
||||||
|
|
@ -418,12 +419,14 @@ export function seedTemplateShapes(slug: string): boolean {
|
||||||
|
|
||||||
const data = getDocumentData(slug);
|
const data = getDocumentData(slug);
|
||||||
const shapeCount = data ? Object.keys(data.shapes || {}).length : 0;
|
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;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
addShapes(slug, TEMPLATE_SHAPES);
|
addShapes(slug, TEMPLATE_SHAPES);
|
||||||
|
markShapesSeeded(slug);
|
||||||
console.log(`[Template] Seeded ${TEMPLATE_SHAPES.length} template shapes into "${slug}"`);
|
console.log(`[Template] Seeded ${TEMPLATE_SHAPES.length} template shapes into "${slug}"`);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue