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
|
<Document
|
||||||
file={src}
|
file={src}
|
||||||
|
key={src + "document"}
|
||||||
onLoadSuccess={onDocumentLoadSuccess}
|
onLoadSuccess={onDocumentLoadSuccess}
|
||||||
className="flex flex-col gap-4 py-10"
|
className="flex flex-col gap-4 py-10"
|
||||||
ref={documentRef}
|
ref={documentRef}
|
||||||
|
|||||||
@@ -43,6 +43,7 @@ import (
|
|||||||
"github.com/getprobo/probo/pkg/statelesstoken"
|
"github.com/getprobo/probo/pkg/statelesstoken"
|
||||||
"github.com/go-chi/chi/v5"
|
"github.com/go-chi/chi/v5"
|
||||||
"github.com/vektah/gqlparser/v2/gqlerror"
|
"github.com/vektah/gqlparser/v2/gqlerror"
|
||||||
|
"go.gearno.de/crypto/uuid"
|
||||||
"go.gearno.de/kit/log"
|
"go.gearno.de/kit/log"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -163,8 +164,14 @@ func NewMux(
|
|||||||
return
|
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-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.WriteHeader(http.StatusOK)
|
||||||
w.Write(pdfData)
|
w.Write(pdfData)
|
||||||
},
|
},
|
||||||
|
|||||||
Reference in New Issue
Block a user