Skip to content

armgit / Piik

Public Imported from GitHub
0

Free, open-source screen sharing for private live streams with friends. Watch together in a browser or self-host Piik. 免费开源的私密屏幕共享,支持游戏直播、一起看电影与自部署。

1.2 KB
Raw Blame
import { useSyncExternalStore } from "react";
import { CHAT_HISTORY_LIMIT, RoomInteractionSession } from "../../lib/room-interactions";
import { downloadBlob } from "../../lib/download";
import { formatChatTranscript } from "../../lib/room-chat-export";
import { useCopy } from "../../ui/copy";
import { Btn } from "./primitives";
import { Tooltip } from "./Tooltip";

export function RoomChatSettings({ session }: { session: RoomInteractionSession }) {
  const { messages } = useSyncExternalStore(session.subscribe, session.getSnapshot);
  const { t, vis } = useCopy();
  return <div className="lr-floating-scroll lr-interaction-settings lr-chat-settings">
    <div className="lr-chat-export">
      {!vis && <p>{t("interaction.ephemeral")}</p>}
      <Tooltip kind="hint-chat-export" text={vis ? undefined : t("interaction.exportLimit", { count: String(CHAT_HISTORY_LIMIT) })}>
      <Btn icon="save" title="interaction.export" cap="interaction.export" disabled={!messages.length} onClick={() => {
          downloadBlob(new Blob([formatChatTranscript(messages)], { type: "text/plain;charset=utf-8" }),
            `piik-chat-${new Date().toISOString().replace(/[:.]/g, "-")}.txt`);
        }} />
      </Tooltip>
    </div>
  </div>;
}