Fix react-pdf race condition
Signed-off-by: Bryan Frimin <bryan@getprobo.com>
This commit is contained in:
@@ -110,6 +110,7 @@ export function PDFPreview({ src, name }: { src: string; name?: string }) {
|
||||
>
|
||||
<Document
|
||||
file={src}
|
||||
key={src + "document"}
|
||||
onLoadSuccess={onDocumentLoadSuccess}
|
||||
className="flex flex-col gap-4 py-10"
|
||||
ref={documentRef}
|
||||
|
||||
@@ -43,6 +43,7 @@ import (
|
||||
"github.com/getprobo/probo/pkg/statelesstoken"
|
||||
"github.com/go-chi/chi/v5"
|
||||
"github.com/vektah/gqlparser/v2/gqlerror"
|
||||
"go.gearno.de/crypto/uuid"
|
||||
"go.gearno.de/kit/log"
|
||||
)
|
||||
|
||||
@@ -163,8 +164,14 @@ func NewMux(
|
||||
return
|
||||
}
|
||||
|
||||
uuid, err := uuid.NewV7()
|
||||
if err != nil {
|
||||
http.Error(w, "failed to generate uuid", http.StatusInternalServerError)
|
||||
return
|
||||
}
|
||||
|
||||
w.Header().Set("Content-Type", "application/pdf")
|
||||
w.Header().Set("Content-Disposition", "inline; filename=\"document.pdf\"")
|
||||
w.Header().Set("Content-Disposition", fmt.Sprintf("inline; filename=\"%s.pdf\"", uuid.String()))
|
||||
w.WriteHeader(http.StatusOK)
|
||||
w.Write(pdfData)
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user