Skip to content

Commit

Permalink
follow the rabbit to fix potential issues
Browse files Browse the repository at this point in the history
  • Loading branch information
Dakai committed Oct 13, 2024
1 parent e64a4f2 commit 39f5d26
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 24 deletions.
12 changes: 5 additions & 7 deletions app/components/chat.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -1122,12 +1122,11 @@ function _Chat() {
};

const updateMessageAudio = (msgId?: string, audio_url?: string) => {
chatStore.updateCurrentSession(
(session) =>
(session.messages = session.messages.map((m) =>
m.id === msgId ? { ...m, audio_url } : m,
)),
);
chatStore.updateCurrentSession((session) => {
session.messages = session.messages.map((m) =>
m.id === msgId ? { ...m, audio_url } : m,
);
});
};

const onDelete = (msgId: string) => {
Expand Down Expand Up @@ -1903,7 +1902,6 @@ function _Chat() {
)}
{message.audio_url && (
<audio
id="audio"
preload="auto"
controls
className={styles["chat-message-item-audio"]}
Expand Down
9 changes: 5 additions & 4 deletions app/styles/globals.scss
Original file line number Diff line number Diff line change
Expand Up @@ -403,8 +403,9 @@ pre {
audio {
height: 35px;
}

audio::-webkit-media-controls-play-button,
audio::-webkit-media-controls-panel {
background-color: none;
}
audio::-webkit-media-controls-panel,
audio::-moz-media-controls-play-button,
audio::-moz-media-controls-panel {
background: none;
}
13 changes: 0 additions & 13 deletions app/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -251,19 +251,6 @@ export function getMessageImages(message: RequestMessage): string[] {
return urls;
}

//export function getMessageAudio(message: RequestMessage): string[] {
// if (typeof message.content === "string") {
// return [];
// }
// const urls: string[] = [];
// for (const c of message.content) {
// if (c.type === "image_url") {
// urls.push(c.image_url?.url ?? "");
// }
// }
// return urls;
//}

export function isVisionModel(model: string) {
// Note: This is a better way using the TypeScript feature instead of `&&` or `||` (ts v5.5.0-dev.20240314 I've been using)

Expand Down
3 changes: 3 additions & 0 deletions app/utils/audio.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,9 @@ export function arrayBufferToWav(buffer: ArrayBuffer): ArrayBuffer {

// Helper function to write a string to the DataView
function writeString(view: DataView, offset: number, string: string) {
if (offset + string.length > view.byteLength) {
throw new Error("String is too long for the available space in DataView");
}
for (let i = 0; i < string.length; i++) {
view.setUint8(offset + i, string.charCodeAt(i));
}
Expand Down

0 comments on commit 39f5d26

Please sign in to comment.