feat: refetch errored/pending images on collab room init load (#5833)
This commit is contained in:
parent
0228646507
commit
938ce241ff
@ -310,16 +310,27 @@ class Collab extends PureComponent<Props, CollabState> {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
private fetchImageFilesFromFirebase = async (scene: {
|
private fetchImageFilesFromFirebase = async (opts: {
|
||||||
elements: readonly ExcalidrawElement[];
|
elements: readonly ExcalidrawElement[];
|
||||||
|
/**
|
||||||
|
* Indicates whether to fetch files that are errored or pending and older
|
||||||
|
* than 10 seconds.
|
||||||
|
*
|
||||||
|
* Use this as a machanism to fetch files which may be ok but for some
|
||||||
|
* reason their status was not updated correctly.
|
||||||
|
*/
|
||||||
|
forceFetchFiles?: boolean;
|
||||||
}) => {
|
}) => {
|
||||||
const unfetchedImages = scene.elements
|
const unfetchedImages = opts.elements
|
||||||
.filter((element) => {
|
.filter((element) => {
|
||||||
return (
|
return (
|
||||||
isInitializedImageElement(element) &&
|
isInitializedImageElement(element) &&
|
||||||
!this.fileManager.isFileHandled(element.fileId) &&
|
!this.fileManager.isFileHandled(element.fileId) &&
|
||||||
!element.isDeleted &&
|
!element.isDeleted &&
|
||||||
element.status === "saved"
|
(opts.forceFetchFiles
|
||||||
|
? element.status !== "pending" ||
|
||||||
|
Date.now() - element.updated > 10000
|
||||||
|
: element.status === "saved")
|
||||||
);
|
);
|
||||||
})
|
})
|
||||||
.map((element) => (element as InitializedExcalidrawImageElement).fileId);
|
.map((element) => (element as InitializedExcalidrawImageElement).fileId);
|
||||||
|
@ -285,6 +285,7 @@ const ExcalidrawWrapper = () => {
|
|||||||
collabAPI
|
collabAPI
|
||||||
.fetchImageFilesFromFirebase({
|
.fetchImageFilesFromFirebase({
|
||||||
elements: data.scene.elements,
|
elements: data.scene.elements,
|
||||||
|
forceFetchFiles: true,
|
||||||
})
|
})
|
||||||
.then(({ loadedFiles, erroredFiles }) => {
|
.then(({ loadedFiles, erroredFiles }) => {
|
||||||
excalidrawAPI.addFiles(loadedFiles);
|
excalidrawAPI.addFiles(loadedFiles);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user