Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion apps/src/lab2/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ export type ExcalidrawSourceWithExternalFiles = Omit<
};

export type SketchlabProjectFile = Pick<ProjectFile, 'id' | 'url'> & {
uploadFailed?: boolean;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

uploadFailed was something I added a while ago and is no longer being set or used.

uploaded?: boolean;
starterAsset?: boolean;
filenameWithExtension?: string;
};
Expand Down
13 changes: 12 additions & 1 deletion apps/src/sketchlab/SketchlabView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -247,11 +247,22 @@ const SketchlabView: React.FC<LabProps<LevelProperties>> = ({
});

if (newFiles && !readonlyWorkspace) {
uploadExternalFiles(
const newFilesWithUploadStatus = await uploadExternalFiles(
newFiles,
serializedData.files,
filesBeingUploadedRef
);

// We update sources again on upload completion to update the upload status of the new files.
updateSources({
source: {
...serializedData,
externalFiles: {
...currentSources.source.externalFiles,
...newFilesWithUploadStatus,
},
},
});
}
}, DEBOUNCED_WORKSPACE_SERIALIZATION_MS);
},
Expand Down
6 changes: 5 additions & 1 deletion apps/src/sketchlab/utils/uploadExternalFiles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export const uploadExternalFiles = async (
filesToUpload: SketchlabExternalFiles,
excalidrawFiles: ExcalidrawFilesWithOptionalData,
filesBeingUploadedRef: React.MutableRefObject<Set<string>>
) => {
): Promise<SketchlabExternalFiles> => {
for (const [fileId, fileContents] of Object.entries(filesToUpload)) {
filesBeingUploadedRef.current.add(fileId);

Expand All @@ -25,6 +25,8 @@ export const uploadExternalFiles = async (
!!fileContents?.starterAsset,
fileContents?.filenameWithExtension || ''
);

fileContents.uploaded = true;
}
} catch {
// https://codedotorg.atlassian.net/browse/AFL-345
Expand All @@ -33,4 +35,6 @@ export const uploadExternalFiles = async (

filesBeingUploadedRef.current.delete(fileId);
}

return filesToUpload;
};