Skip to content

Commit

Permalink
fix: builder crashing on image upload
Browse files Browse the repository at this point in the history
  • Loading branch information
surajair committed May 7, 2024
1 parent 6926b8b commit 2d419f0
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"author": "Suraj Air",
"license": "BSD-3-Clause",
"homepage": "https://chaibuilder.com",
"version": "1.1.4",
"version": "1.1.5",
"type": "module",
"repository": {
"type": "git",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ export const fetchImage = async (payload: any, accessKey: string) =>
});

const UnsplashImages = ({ isModalView, onSelect }: { isModalView: boolean; onSelect: (_url: string) => void }) => {
const unsplashAccessKey = useBuilderProp("unsplashAccessKey");
const unsplashAccessKey = useBuilderProp("unsplashAccessKey", "");
const [images, setImages] = useState<any[]>([]);
const [page, setPage] = useState(0);
const [orientation, setOrientation] = useState<undefined | "landscape" | "portrait" | "squarish">();
Expand Down Expand Up @@ -68,7 +68,7 @@ const UnsplashImages = ({ isModalView, onSelect }: { isModalView: boolean; onSel
};

useEffect(() => {
if (!isEmpty(debouncedQuery)) {
if (!isEmpty(debouncedQuery) && unsplashAccessKey) {
setIsFetching(true);
const payload: any = { query: debouncedQuery as string, page: 1 };
if (orientation) payload.orientation = orientation;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ const UploadImages = ({ isModalView, onSelect }: { isModalView: boolean; onSelec
setImages(uploadedImages || []);
setIsFetching(false);
})();
}, [fetchImages, setImages]);
}, []);

const onChange = (e: any) => {
if (e && e?.target?.files?.length > 0) setFile(e.target.files[0]);
Expand Down

0 comments on commit 2d419f0

Please sign in to comment.