Skip to content

Commit

Permalink
feat(DoDontBlock): performance improvement (#781)
Browse files Browse the repository at this point in the history
* feat(DoDontBlock): performance improvement

* fix tests

* conditionally request assets

* fix review comments

* fix review comments
  • Loading branch information
fulopdaniel authored Mar 13, 2024
1 parent 5e588f9 commit b3fb348
Show file tree
Hide file tree
Showing 14 changed files with 563 additions and 428 deletions.
3 changes: 3 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,9 @@
"pnpm": {
"overrides": {
"@codesandbox/sandpack-react@^2.12.1>@codesandbox/sandpack-client": "2.10.0"
},
"patchedDependencies": {
"@udecode/[email protected]": "patches/@[email protected]"
}
}
}
26 changes: 26 additions & 0 deletions packages/dos-donts-block/src/AssetsProvider.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
/* (c) Copyright Frontify Ltd., all rights reserved. */

import { AppBridgeBlock, Asset, useBlockAssets } from '@frontify/app-bridge';
import { ReactNode, createContext } from 'react';

type AssetsProviderProps = {
appBridge: AppBridgeBlock;
children: ReactNode;
};

type AssetsContext = {
blockAssets?: Record<string, Asset[]>;
addAssetIdsToKey?: (key: string, assetIds: number[]) => Promise<void>;
deleteAssetIdsFromKey?: (key: string, assetIds: number[]) => Promise<void>;
};

export const AssetsContext = createContext<AssetsContext>({} as AssetsContext);

export const AssetsProvider = ({ appBridge, children }: AssetsProviderProps) => {
const { blockAssets, addAssetIdsToKey, deleteAssetIdsFromKey } = useBlockAssets(appBridge);
return (
<AssetsContext.Provider value={{ blockAssets, addAssetIdsToKey, deleteAssetIdsFromKey }}>
{children}
</AssetsContext.Provider>
);
};
Loading

0 comments on commit b3fb348

Please sign in to comment.