mirror of
https://github.com/yusufipk/OpenFrame.git
synced 2026-09-11 17:46:06 +00:00
refactor: Update response handling for comments and uploads to access nested data structure
This commit is contained in:
@@ -539,7 +539,8 @@ export default function WatchPage() {
|
||||
});
|
||||
|
||||
if (res.ok) {
|
||||
const newComment = await res.json();
|
||||
const response = await res.json();
|
||||
const newComment = response.data;
|
||||
// Replace temp comment with real one
|
||||
setVideo((prev) => {
|
||||
if (!prev) return prev;
|
||||
@@ -659,7 +660,8 @@ export default function WatchPage() {
|
||||
throw new Error('Failed to upload audio');
|
||||
}
|
||||
|
||||
const { url } = await uploadRes.json();
|
||||
const uploadData = await uploadRes.json();
|
||||
const { url } = uploadData.data;
|
||||
await handleAddComment({ url, duration: recordingTime });
|
||||
setAudioBlob(null);
|
||||
setRecordingTime(0);
|
||||
@@ -900,7 +902,8 @@ export default function WatchPage() {
|
||||
});
|
||||
|
||||
if (res.ok) {
|
||||
const newReply = await res.json();
|
||||
const response = await res.json();
|
||||
const newReply = response.data;
|
||||
// Replace temp reply with real one
|
||||
setVideo((prev) => {
|
||||
if (!prev) return prev;
|
||||
@@ -1026,7 +1029,8 @@ export default function WatchPage() {
|
||||
formData.append('audio', replyAudioBlob, 'recording.webm');
|
||||
const uploadRes = await fetch('/api/upload/audio', { method: 'POST', body: formData });
|
||||
if (!uploadRes.ok) throw new Error('Failed to upload audio');
|
||||
const { url } = await uploadRes.json();
|
||||
const uploadData = await uploadRes.json();
|
||||
const { url } = uploadData.data;
|
||||
await handleReplyComment(parentId, { url, duration: replyRecordingTime });
|
||||
} catch (err) {
|
||||
console.error('Failed to submit voice reply:', err);
|
||||
@@ -1484,17 +1488,17 @@ export default function WatchPage() {
|
||||
)}
|
||||
>
|
||||
<div className="flex items-start justify-between gap-2 mb-2">
|
||||
<div className="flex items-center gap-2">
|
||||
<Avatar className="h-6 w-6">
|
||||
<div className="flex items-center gap-2 min-w-0">
|
||||
<Avatar className="h-6 w-6 shrink-0">
|
||||
<AvatarImage src={comment.author?.image ?? undefined} />
|
||||
<AvatarFallback className="text-xs">
|
||||
{authorName.charAt(0)}
|
||||
</AvatarFallback>
|
||||
</Avatar>
|
||||
<span className="text-sm font-medium">{authorName}</span>
|
||||
<span className="text-sm font-medium truncate">{authorName}</span>
|
||||
{comment.tag && (
|
||||
<span
|
||||
className="text-[10px] font-medium px-1.5 py-0.5 rounded-full text-white"
|
||||
className="text-[10px] font-medium px-1.5 py-0.5 rounded-full text-white shrink-0"
|
||||
style={{ backgroundColor: comment.tag.color }}
|
||||
>
|
||||
{comment.tag.name}
|
||||
@@ -1502,7 +1506,7 @@ export default function WatchPage() {
|
||||
)}
|
||||
</div>
|
||||
|
||||
<div className="flex items-center gap-1">
|
||||
<div className="flex items-center gap-1 shrink-0">
|
||||
<button
|
||||
onClick={() => handleSeekToTimestamp(comment.timestamp)}
|
||||
className="flex items-center gap-1 text-xs text-primary hover:underline px-1.5 py-0.5 rounded bg-primary/10 hover:bg-primary/20 transition-colors"
|
||||
|
||||
Reference in New Issue
Block a user