Skip to content
Open
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
5 changes: 4 additions & 1 deletion plugins/ascii/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,10 @@
const asciiRef = useRef<ASCIIRef | null>(null)
const { gl, toBytes, program, setProgram, setResolution } = useOGLPipeline()

const isAllowedToUpsertImage = useIsAllowedTo("addImage", "setImage")
const isAllowedToAddImage = useIsAllowedTo("addImage")
const isAllowedToSetImage = useIsAllowedTo("setImage")
const isAllowedToUpsertImage =
framer.mode === "canvas" ? isAllowedToAddImage && isAllowedToSetImage : isAllowedToSetImage

useEffect(() => {
asciiRef.current?.setPixelSize(exportSize * 0.02)
Expand Down Expand Up @@ -114,7 +117,7 @@
useEffect(() => {
const assetAspect = assetResolution[0] / assetResolution[1]
setResolution([exportSize, exportSize / assetAspect])
}, [exportSize, assetResolution])

Check warning on line 120 in plugins/ascii/src/App.tsx

View workflow job for this annotation

GitHub Actions / eslint

React Hook useEffect has a missing dependency: 'setResolution'. Either include it or remove the dependency array

const saveEffect = useCallback(() => {
if (!isAllowedToUpsertImage) return
Expand Down
5 changes: 4 additions & 1 deletion plugins/dither/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,10 @@ export interface DroppedAsset {
}

function DitherImage({ image }: { image: ImageAsset | null }) {
const isAllowedToUpsertImage = useIsAllowedTo("addImage", "setImage")
const isAllowedToAddImage = useIsAllowedTo("addImage")
const isAllowedToSetImage = useIsAllowedTo("setImage")
const isAllowedToUpsertImage =
framer.mode === "canvas" ? isAllowedToAddImage && isAllowedToSetImage : isAllowedToSetImage

const canvasContainerRef = useRef<HTMLDivElement>(null)
const [droppedAsset, setDroppedAsset] = useState<DroppedAsset | null>()
Expand Down
19 changes: 10 additions & 9 deletions plugins/unsplash/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ const minWindowWidth = mode === "canvas" ? 260 : 600
const minColumnWidth = 100
const columnGap = 5
const sidePadding = 15 * 2
const resizable = framer.mode === "canvas"
const resizable = mode === "canvas"

void framer.showUI({
position: "top right",
Expand All @@ -34,15 +34,14 @@ void framer.showUI({
})

export function App() {
const isAllowedToUpsertImage = useIsAllowedTo("addImage", "setImage")
const isAllowedToUpsertImage = useIsAllowedTo(mode === "canvas" ? "addImage" : "setImage")

const [query, setQuery] = useState("")

const debouncedQuery = useDebounce(query, 200)

const addRandomMutation = useMutation({
mutationFn: async (query: string) => {
const mode = framer.mode
const randomPhoto = await getRandomPhoto(query)

if (mode === "canvas") {
Expand Down Expand Up @@ -83,7 +82,7 @@ export function App() {
</div>
</div>
<AppErrorBoundary>
<PhotosList query={debouncedQuery} />
<PhotosList query={debouncedQuery} isAllowedToUpsertImage={isAllowedToUpsertImage} />
</AppErrorBoundary>
<div className="mt-[15px] px-[15px]">
<button
Expand All @@ -104,9 +103,13 @@ export function App() {

type PhotoId = string

const PhotosList = memo(function PhotosList({ query }: { query: string }) {
const isAllowedToUpsertImage = useIsAllowedTo("addImage", "setImage")

const PhotosList = memo(function PhotosList({
query,
isAllowedToUpsertImage,
}: {
query: string
isAllowedToUpsertImage: boolean
}) {
const { data, fetchNextPage, isFetchingNextPage, isLoading, hasNextPage } = useListPhotosInfinite(query)
const scrollRef = useRef<HTMLDivElement>(null)
const [windowWidth, setWindowWidth] = useState(window.innerWidth)
Expand Down Expand Up @@ -147,8 +150,6 @@ const PhotosList = memo(function PhotosList({ query }: { query: string }) {

const addPhotoMutation = useMutation({
mutationFn: async (photo: UnsplashPhoto) => {
const mode = framer.mode

if (mode === "canvas") {
await framer.addImage({
image: photo.urls.full,
Expand Down
Loading