Merge remote-tracking branch 'github/dev' into dev

This commit is contained in:
2024-12-25 18:04:28 +08:00
4 changed files with 504 additions and 430 deletions

View File

@@ -3,6 +3,13 @@ import { createRef } from "preact";
import { ChatStore } from "@/types/chatstore";
import { StateUpdater, useEffect, useState, Dispatch } from "preact/hooks";
import { Button } from "@/components/ui/button";
import {
AudioWaveform,
AudioWaveformIcon,
CircleStopIcon,
MicIcon,
VoicemailIcon,
} from "lucide-react";
const WhisperButton = (props: {
chatStore: ChatStore;
@@ -14,11 +21,14 @@ const WhisperButton = (props: {
const [isRecording, setIsRecording] = useState("Mic");
return (
<Button
variant={isRecording === "Recording" ? "destructive" : "default"}
variant="ghost"
size="icon"
className={`m-1 p-1 ${isRecording !== "Mic" ? "animate-pulse" : ""}`}
disabled={isRecording === "Transcribing"}
ref={mediaRef}
onClick={async () => {
onClick={async (event) => {
event.preventDefault(); // Prevent the default behavior
if (isRecording === "Recording") {
// @ts-ignore
window.mediaRecorder.stop();
@@ -124,7 +134,13 @@ const WhisperButton = (props: {
}
}}
>
{isRecording}
{isRecording === "Mic" ? (
<MicIcon />
) : isRecording === "Recording" ? (
<CircleStopIcon />
) : (
<AudioWaveformIcon />
)}
</Button>
);
};