Live video on the AT Protocol

send a temp message to the stream for viewers already watching

authored by Natalie B. and committed by Eli Mallon d7f7bf74 4fbd0e32

+22 -4
+10
js/components/src/lib/system-messages.ts
··· 73 73 { duration }, 74 74 ), 75 75 76 + teleportArrival: ( 77 + streamerName: string, 78 + count: number, 79 + ): ChatMessageViewHydrated => 80 + createSystemMessage( 81 + SystemMessageType.notification, 82 + `${count} viewer${count !== 1 ? "s" : ""} teleported from ${streamerName}'s stream! Say hi!`, 83 + { streamerName, count }, 84 + ), 85 + 76 86 notification: (message: string): ChatMessageViewHydrated => 77 87 createSystemMessage(SystemMessageType.notification, message), 78 88 };
+12 -4
js/components/src/livestream-store/websocket-consumer.tsx
··· 12 12 PlaceStreamSegment, 13 13 } from "streamplace"; 14 14 import { SystemMessages } from "../lib/system-messages"; 15 + import { formatHandleWithAt } from "../utils/format-handle"; 15 16 import { reduceChat } from "./chat"; 16 17 import { LivestreamState } from "./livestream-state"; 17 18 import { findProblems } from "./problems"; ··· 129 130 activeTeleport: teleportRecord, 130 131 }; 131 132 } else if (PlaceStreamLivestream.isTeleportArrival(message)) { 133 + console.log("teleport succeeded"); 134 + // teleport has succeeded, we are now at the target stream 132 135 const arrival = message as PlaceStreamLivestream.TeleportArrival; 133 - // when receiving a teleportArrival, we're the target 134 - // the source is teleporting to us 135 - console.log("Received teleport arrival", arrival); 136 - // TODO: show notification or UI for incoming teleport 136 + const systemMessage = SystemMessages.teleportArrival( 137 + formatHandleWithAt(arrival.source), 138 + arrival.viewerCount, 139 + ); 140 + // set proper times 141 + systemMessage.indexedAt = arrival.startsAt; 142 + systemMessage.record.createdAt = arrival.startsAt; 143 + 144 + state = reduceChat(state, [systemMessage], []); 137 145 } else if (PlaceStreamLivestream.isTeleportCanceled(message)) { 138 146 // teleport was canceled (deleted or denied) 139 147 state = {