Skip to content

Commit 5751a0d

Browse files
committed
feat(rich-editor): show an "Uploading…" toast while an image uploads
A persistent progress toast appears per image during upload and is dismissed once it settles, when the upload hook's "Uploaded"/"Failed" toast takes over — previously nothing showed until the upload finished.
1 parent 8ede64a commit 5751a0d

1 file changed

Lines changed: 5 additions & 0 deletions

File tree

apps/sim/app/workspace/[workspaceId]/files/components/file-viewer/rich-markdown-editor/rich-markdown-editor.tsx

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import type { JSONContent } from '@tiptap/core'
55
import type { Editor } from '@tiptap/react'
66
import { EditorContent, useEditor } from '@tiptap/react'
77
import { useRouter } from 'next/navigation'
8+
import { toast } from '@/components/emcn'
89
import { cn } from '@/lib/core/utils/cn'
910
import type { WorkspaceFileRecord } from '@/lib/uploads/contexts/workspace'
1011
import { useUploadWorkspaceFile } from '@/hooks/queries/workspace-files'
@@ -213,9 +214,13 @@ export function LoadedRichMarkdownEditor({
213214
insertImagesRef.current = async (images, at) => {
214215
let position = at
215216
for (const image of images) {
217+
// Persistent (`duration: 0`) progress toast, dismissed once the upload settles — the upload
218+
// hook then shows its own "Uploaded"/"Failed" toast.
219+
const uploadingToastId = toast.info(`Uploading "${image.name}"…`, { duration: 0 })
216220
const result = await uploadFile
217221
.mutateAsync({ workspaceId, file: image, folderId: file.folderId ?? null })
218222
.catch(() => null)
223+
toast.dismiss(uploadingToastId)
219224
const editor = editorInstanceRef.current
220225
if (!result || !editor) continue
221226
const safePosition = Math.min(position, editor.state.doc.content.size)

0 commit comments

Comments
 (0)