Skip to content

Commit

Permalink
Available on mobile; on hosted
Browse files Browse the repository at this point in the history
  • Loading branch information
rob-gordon committed Jan 11, 2024
1 parent db73575 commit f224388
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 2 deletions.
11 changes: 10 additions & 1 deletion app/src/components/Microphone.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,20 @@ export function Microphone({
const isRecording = useMicrophoneStore((s) => s.isRecording);

const handleFinishRecording = useCallback(() => {
onSend();
const audioBlob = new Blob(useMicrophoneStore.getState().data, {
type: "audio/mp4",
});

// Get length in milliseconds
const lengthInMS = audioBlob.size / audioBlob.type.length;

// Don't send if the recording is too short
if (lengthInMS < 2500) {
return;
}

onSend();

// Base64 encode the blob
let audioUrl = "";
const reader = new FileReader();
Expand Down
7 changes: 7 additions & 0 deletions app/src/pages/EditHosted.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import { useTabsStore } from "../lib/useTabsStore";
import { useIsProUser } from "../lib/hooks";
import { ThemeTab } from "../components/Tabs/ThemeTab";
import { FlowchartLayout } from "../components/FlowchartLayout";
import { EditWithAI } from "../components/EditWithAI";

export default function EditHosted() {
const { id } = useParams<{ id: string }>();
Expand Down Expand Up @@ -98,6 +99,9 @@ export default function EditHosted() {
readOnly: !isProUser,
}}
/>
<div className="absolute top-2 right-2 z-[40] drop-shadow-lg hidden md:block">
<EditWithAI />
</div>
</Tabs.Content>
<Tabs.Content value="Theme" className="overflow-hidden">
<ThemeTab />
Expand All @@ -116,6 +120,9 @@ export default function EditHosted() {
}}
/>
<EditorError />
<div className="absolute top-2 right-2 z-[40] drop-shadow-lg md:hidden">
<EditWithAI />
</div>
</WithGraph>
</Tabs.Root>
</FlowchartLayout>
Expand Down
5 changes: 4 additions & 1 deletion app/src/pages/Sandbox.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ const Sandbox = memo(function Edit() {
<WithGraph>
<Tabs.Content value="Document" className="overflow-hidden relative">
<TextEditor value={text} onChange={onChange} />
<div className="absolute top-2 right-2 z-[40] drop-shadow-lg">
<div className="absolute top-2 right-2 z-[40] drop-shadow-lg hidden md:block">
<EditWithAI />
</div>
</Tabs.Content>
Expand All @@ -132,6 +132,9 @@ const Sandbox = memo(function Edit() {
}}
/>
<EditorError />
<div className="absolute top-2 right-2 z-[40] drop-shadow-lg md:hidden">
<EditWithAI />
</div>
</WithGraph>
</Tabs.Root>
</FlowchartLayout>
Expand Down

0 comments on commit f224388

Please sign in to comment.