support open / closed streams

- Tabs for viewing separately
- Context menu to close / open streams
- Update stream particle status field
This commit is contained in:
talksik
2026-04-07 15:09:22 -07:00
parent 5ec24d9542
commit ff6891f57e
14 changed files with 496 additions and 66 deletions
+32
View File
@@ -63,6 +63,7 @@ const particleConverter: FirestoreDataConverter<Particle> = {
: undefined,
last_child_created_at: raw.last_child_created_at ? (raw.last_child_created_at as Timestamp).toDate() : undefined,
huddle_active_participants: raw.huddle_active_participants ?? undefined,
status: raw.status ?? undefined,
});
case "folder":
return ParticleSchema.parse({
@@ -245,6 +246,29 @@ export async function createParticle<T extends ParticleType>(
return ref.id;
}
export async function createStreamParticle(
collectionPath: string,
properties: ParticlePropertiesMap["stream"],
createdByHumanId: string,
visibleTo?: string[],
): Promise<string> {
if (!visibleTo || visibleTo.length === 0) {
throw new Error("visibleTo is required for streams and cannot be empty");
}
const particle: Particle = ParticleSchema.parse({
id: "",
type: "stream",
properties,
created_at: new Date(),
created_by_human_id: createdByHumanId,
visible_to: visibleTo,
status: "open",
});
const ref = await addDoc(typedCollection(collectionPath), particle);
return ref.id;
}
// This allows updating properties without overwriting the entire properties object
export async function updateParticleProperties<T extends ParticleType>(
docPath: string,
@@ -298,6 +322,14 @@ export async function updateParticle(
});
}
export async function updateStreamStatus(
docPath: string,
status: "open" | "closed",
): Promise<void> {
const particleRef = typedDoc(docPath);
await updateDoc(particleRef, { status, updated_at: serverTimestamp() });
}
export async function updateStreamPlaybackMarker(
docPath: string,
humanId: string,