Skip to content

armgit / ente

Public Imported from GitHub
0

πŸ’š End-to-end encrypted cloud for everything.

fix(gallery):cleared-ref-after-album-creation

Aswin Asok25300a70fe5a
diff --git a/web/apps/photos/src/pages/gallery.tsx b/web/apps/photos/src/pages/gallery.tsx
index 7ce87a1ced..983cb3f52b 100644
--- a/web/apps/photos/src/pages/gallery.tsx
+++ b/web/apps/photos/src/pages/gallery.tsx
@@ -721,23 +721,29 @@ const Page: React.FC = () => {
const handleAlbumNameSubmit = useCallback(
async (name: string) => {
- const collection = await createAlbum(name);
+ try {
+ const collection = await createAlbum(name);
- if (pendingSingleFileAdd.current) {
- await performCollectionOp(
- "add",
- collection,
- [pendingSingleFileAdd.current.file],
- pendingSingleFileAdd.current.sourceCollectionID,
- );
- }
+ if (pendingSingleFileAdd.current) {
+ await performCollectionOp(
+ "add",
+ collection,
+ [pendingSingleFileAdd.current.file],
+ pendingSingleFileAdd.current.sourceCollectionID,
+ );
+ }
- setPostCreateAlbumOp((postCreateAlbumOp) => {
- // The function returned by createHandleCollectionOp does its
- // own progress and error reporting, defer to that.
- createOnSelectForCollectionOp(postCreateAlbumOp!)(collection);
- return undefined;
- });
+ setPostCreateAlbumOp((postCreateAlbumOp) => {
+ // The function returned by createHandleCollectionOp does its
+ // own progress and error reporting, defer to that.
+ createOnSelectForCollectionOp(postCreateAlbumOp!)(
+ collection,
+ );
+ return undefined;
+ });
+ } finally {
+ pendingSingleFileAdd.current = undefined;
+ }
},
[createOnSelectForCollectionOp],
);