Open AMIRKHANEF opened 1 day ago
The pull request introduces significant modifications to the handling of worker contexts within the application. The WorkerContext
type is updated from Worker
to MessagePort
, affecting various functions that interact with workers. The useAssetsBalances
function's signature is altered to accept a MessagePort
, simplifying error handling. Several asset retrieval functions are updated to use the new port
parameter for messaging instead of the global postMessage
. Additionally, the WorkerProvider
component is transitioned to utilize a SharedWorker
, enhancing the communication model. Version updates in package.json
and packageInfo.ts
reflect these changes.
File | Change Summary |
---|---|
packages/extension-polkagate/src/components/contexts.tsx |
Updated WorkerContext type from Worker | undefined to MessagePort | undefined . |
packages/extension-polkagate/src/hooks/useAssetsBalances.ts |
Changed worker parameter type from Worker to MessagePort . Removed error handling for worker's onerror event in three callback functions. |
packages/extension-polkagate/src/util/workers/shared-helpers/getAssetOnAssetHub.js |
Added port parameter of type MessagePort . Updated postMessage calls to use port . Added JSDoc comments for type annotations. |
packages/extension-polkagate/src/util/workers/shared-helpers/getAssetOnMultiAssetChain.js |
Added port parameter of type MessagePort . Updated messaging to use port.postMessage . Added JSDoc comments for type annotations. |
packages/extension-polkagate/src/util/workers/shared-helpers/getAssetOnRelayChain.js |
Added port parameter of type MessagePort . Changed to async/await syntax for asynchronous operations. Enhanced error handling with early returns. |
packages/extension-polkagate/src/util/workers/shared-helpers/getBalances.js |
Added port parameter of type MessagePort . Updated messaging to use port.postMessage . Refactored property access from dot notation to bracket notation. |
packages/extension-polkagate/src/util/workers/sharedWorker.js |
Replaced onmessage with onconnect to handle multiple connections. Updated message handling to use port . Enhanced error handling and logging. |
packages/extension-ui/src/Popup/contexts/WorkerProvider.tsx |
Transitioned from Worker to SharedWorker . Updated state variable from worker to port . Modified cleanup and context provider value accordingly. |
packages/extension/package.json |
Updated version from 0.33.0 to 0.33.1 . |
packages/extension/src/packageInfo.ts |
Updated version in packageInfo from '0.33.0' to '0.33.1' . |
packages/extension-polkagate/src/hooks/useNFT.tsx |
Replaced Worker instantiation with useWorker hook. Updated message handling and error handling for NFT fetching. Added NftItemsWorker interface. |
packages/extension-polkagate/src/util/workers/shared-helpers/getNFTs.js |
Introduced new functions for fetching NFTs and collections, including error handling and retries. |
packages/extension-polkagate/src/util/workers/utils/fastestEndpoint.js |
Added connectionEndpoint property to connections. Improved logic for connected endpoints and cleanup of not connected endpoints. |
WorkerContext
type modification are related to this PR as it involves adding new functionality for managing blockchain endpoints, which may interact with the worker context.useAssetsBalances.ts
to include a worker parameter are directly related to this PR, which also involves changes to the useAssetsBalances
hook.WorkerContext
in the main PR aligns with this PR's focus on using a shared worker for fetching asset balances, indicating a direct relationship between the two.WorkerContext
, as it may improve the organization of context-related code, including the worker context.new feature
, change requested
🐰 In the land of code where workers play,
AMessagePort
leads the way.
With shared tasks and balances fair,
We hop along without a care!
FromWorker
toSharedWorker
, we cheer,
For smoother paths, our goals are clear! 🌟
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?
Close: #1683
Summary by CodeRabbit
Release Notes
New Features
Worker
to aSharedWorker
, enhancing communication between the main thread and the worker.MessagePort
for improved messaging.Bug Fixes
Documentation
Chores
0.33.1
in relevant files.