Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove deprecated APIs #675

Merged
merged 2 commits into from
Jun 23, 2024
Merged

Remove deprecated APIs #675

merged 2 commits into from
Jun 23, 2024

Conversation

nd0ut
Copy link
Member

@nd0ut nd0ut commented Jun 17, 2024

Description

Checklist

Summary by CodeRabbit

  • Refactor
    • Simplified the file upload process by removing obsolete methods and metadata handling. Users will experience a more streamlined and efficient upload interface.

@nd0ut nd0ut changed the title Feat/remove-deprecated-api Remove deprecated APIs Jun 17, 2024
@nd0ut nd0ut requested a review from egordidenko June 17, 2024 11:48
Copy link
Contributor

coderabbitai bot commented Jun 17, 2024

Walkthrough

The recent changes simplified the abstract/CTX.js and abstract/UploaderBlock.js files by removing deprecated and unnecessary functionalities. Specifically, in CTX.js, the uploadMetadata property was removed from the uploaderBlockCtx function. In UploaderBlock.js, the setUploadMetadata and addFiles methods were eradicated, leading to a leaner and more efficient codebase.

Changes

Files Change Summary
abstract/CTX.js Removed the uploadMetadata property from the object returned by uploaderBlockCtx function.
abstract/UploaderBlock.js Removed setUploadMetadata method, addFiles method, and related functionalities.

Poem

🐰 Here's a riddle, writ in byte,

With functions trimmed and kept so tight.

Metadata lost to time,

Uploaders now in their prime! 🌟

Code refined, a sleeker feel,

Forward strides, progress is real!


Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (invoked as PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Configration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 18aac85 and 41b2d1a.

Files selected for processing (2)
  • abstract/CTX.js (1 hunks)
  • abstract/UploaderBlock.js (4 hunks)
Files skipped from review due to trivial changes (1)
  • abstract/CTX.js
Additional comments not posted (31)
abstract/UploaderBlock.js (31)

15-15: Import statements are correctly updated and no deprecated APIs are being used.


28-28: Initialization of init$ with uploaderBlockCtx is correct, but ensure that uploaderBlockCtx does not rely on any deprecated features.


32-32: initCallback method properly initializes components and sets up validation managers. Ensure that the super.initCallback() is called appropriately in the base class.


Line range hint 42-42: destroyCtxCallback method correctly cleans up resources. Make sure that the super method destroyCtxCallback is implemented in the base class.


Line range hint 50-50: initCtxOwner method sets isCtxOwner to true and sets up observers. Ensure that the observer methods are implemented correctly and efficiently.


Line range hint 76-76: addFileFromUuid method implementation is consistent with addFileFromUrl. Ensure uniform handling of file additions across different methods.


Line range hint 100-100: addFileFromObject method adds files from file objects correctly. Ensure that the properties like isImage and fileSize are handled correctly in the uploadCollection.


Line range hint 112-112: removeFileByInternalId method correctly handles file removal by internal ID. Ensure that the uploadCollection's read and remove methods are robust and handle errors appropriately.


Line range hint 120-120: uploadAll method initiates the upload process for all eligible files. Ensure that the filtering logic is correct and that all edge cases are handled.


Line range hint 156-156: initFlow method correctly handles the initialization flow based on the upload collection size and configuration. Ensure that the method's logic is consistent with the expected user flow.


Line range hint 168-168: doneFlow method correctly sets the activity state upon completion. Verify that the set$ method is robust and handles state changes correctly.


Line range hint 180-180: uploadCollection getter is implemented correctly. Ensure that the TypedCollection class is robust and supports all operations used here.


Line range hint 204-204: _flushOutputItems method correctly debounces output item updates. Confirm that the debounce function is implemented efficiently and correctly.


Line range hint 216-216: _handleCollectionUpdate method correctly handles updates to the upload collection. Ensure that the event emission logic is correct and efficient.


Line range hint 228-228: _handleCollectionPropertiesUpdate method efficiently handles property changes in the upload collection. Confirm that the validation and event logic is implemented correctly.


Line range hint 240-240: _flushCommonUploadProgress method correctly calculates and updates the common upload progress. Ensure that the progress calculation logic is accurate and handles all cases.


Line range hint 264-264: getMetadataFor method correctly retrieves metadata for a given entry. Confirm that the configuration and metadata retrieval logic are robust and handle all edge cases.


14-14: Ensure @ts-check is effectively used across the file by checking for TypeScript type errors.

#!/bin/bash
# Description: Check for TypeScript type errors.
# Test: Run TypeScript compiler to check for errors.
tsc --noEmit abstract/UploaderBlock.js

Line range hint 23-23: The UploaderBlock class correctly extends ActivityBlock. Ensure that the base class ActivityBlock has all the necessary methods and properties that UploaderBlock relies on.

#!/bin/bash
# Description: Verify that ActivityBlock contains necessary methods and properties.
# Test: Search for ActivityBlock definition and its methods.
ast-grep --lang javascript --pattern $'class ActivityBlock { $$$ }'

Line range hint 25-25: The property couldBeCtxOwner is set to false by default. Confirm if this default value aligns with the intended use cases of UploaderBlock.

#!/bin/bash
# Description: Check usage of `couldBeCtxOwner` in the codebase.
# Test: Search for references to `couldBeCtxHeader` to understand its impact.
rg --type javascript "couldBeCtxOwner"

Line range hint 26-26: The property isCtxOwner is also set to false. Ensure consistency and correct logic where isCtxOwner is used.

#!/bin/bash
# Description: Verify the usage of `isCtxOwner`.
# Test: Search for `isCtxOwner` to see how it's used across the codebase.
rg --type javascript "isCtxOwner"

30-30: The hasCtxOwner getter method uses a callback to check the context owner status. Verify that all instances of UploaderBlock are handled correctly in this callback.

#!/bin/bash
# Description: Check the handling of `UploaderBlock` instances in `hasCtxOwner`.
# Test: Search for usages of `hasCtxOwner` to ensure correct implementation.
rg --type javascript "hasCtxOwner"

Line range hint 40-40: The validationManager getter is implemented correctly. Confirm that the ValidationManager class has all the necessary methods and properties used here.

#!/bin/bash
# Description: Verify the `ValidationManager` class.
# Test: Search for `ValidationManager` definition and its methods.
ast-grep --lang javascript --pattern $'class ValidationManager { $$$ }'

Line range hint 64-64: addFileFromUrl method correctly handles file addition from URLs. Ensure that the uploadCollection object's add method handles all the properties set here appropriately.

#!/bin/bash
# Description: Verify the `add` method of `uploadCollection`.
# Test: Search for `uploadCollection.add` to ensure it handles properties correctly.
rg --type javascript "uploadCollection.add"

88-88: addFileFromCdnUrl method correctly parses CDN URLs and adds files. Verify that parseCdnUrl correctly handles all possible CDN URL formats.

#!/bin/bash
# Description: Verify the `parseCdnUrl` function.
# Test: Search for `parseCdnUrl` definition and its handling of CDN URLs.
ast-grep --lang javascript --pattern $'function parseCdnUrl($_) { $$$ }'

Line range hint 118-118: removeAllFiles method correctly clears all files. Confirm that the clearAll method of uploadCollection does not leave any residual data or references.

#!/bin/bash
# Description: Verify the `clearAll` method of `uploadCollection`.
# Test: Check for residual data after calling `clearAll`.
rg --type javascript "uploadCollection.clearAll"

Line range hint 132-132: openSystemDialog method correctly handles file input creation and event dispatching. Verify that the MIME types and file acceptance logic are correctly implemented.

#!/bin/bash
# Description: Verify file acceptance logic in `openSystemDialog`.
# Test: Check the MIME types and file acceptance settings.
rg --type javascript "openSystemDialog"

Line range hint 144-144: sourceList getter method correctly processes the sourceList configuration. Ensure that the stringToArray function correctly parses the configuration string.

#!/bin/bash
# Description: Verify the `stringToArray` function.
# Test: Search for `stringToArray` definition and its implementation.
ast-grep --lang javascript --pattern $'function stringToArray($_) { $$$ }'

Line range hint 192-192: _createGroup method handles group creation for uploads. Ensure that the uploadFileGroup function is implemented correctly and handles all edge cases.

#!/bin/bash
# Description: Verify the `uploadFileGroup` function.
# Test: Search for `uploadFileGroup` definition and its error handling.
ast-grep --lang javascript --pattern $'function uploadFileGroup($_, $_) { $$$ }'

Line range hint 252-252: setInitialCrop method correctly calculates and sets the initial crop for images. Verify that the calculateMaxCenteredCropFrame and createCdnUrlModifiers functions are implemented correctly.

#!/bin/bash
# Description: Verify the crop calculation and CDN URL modifier functions.
# Test: Search for `calculateMaxCenteredCropFrame` and `createCdnUrlModifiers` definitions.
ast-grep --lang javascript --pattern $'function calculateMaxCenteredCropFrame($_, $_, $_) { $$$ }'
ast-grep --lang javascript --pattern $'function createCdnUrlModifiers($_, $_) { $$$ }'

Line range hint 276-276: getUploadClientOptions method correctly constructs upload options. Ensure that the SecureUploadsManager class and its methods are implemented correctly.

#!/bin/bash
# Description: Verify the `SecureUploadsManager` class and its methods.
# Test: Search for `SecureUploadsManager` definition and its methods.
ast-grep --lang javascript --pattern $'class SecureUploadsManager { $$$ }'

@nd0ut nd0ut force-pushed the feat/remove-deprecated-api branch from 41b2d1a to 51f094f Compare June 17, 2024 13:08
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

Outside diff range and nitpick comments (2)
abstract/UploaderBlock.js (2)

Line range hint 387-390: Consider simplifying the .map().flat() chain to .flatMap().

- const entriesToRunValidation = [
-   ...new Set(
-     Object.entries(changeMap)
-       .filter(([key]) => ['uploadError', 'fileInfo'].includes(key))
-       .map(([, ids]) => [...ids])
-       .flat(),
-   ),
- ];
+ const entriesToRunValidation = [
+   ...new Set(
+     Object.entries(changeMap)
+       .filter(([key]) => ['uploadError', 'fileInfo'].includes(key))
+       .flatMap(([, ids]) => [...ids]),
+   ),
+ ];

This change reduces complexity by combining the map and flatten operations into a single operation, making the code cleaner and potentially improving performance.


Line range hint 586-586: Remove unnecessary double-negation.

- if (!!this.cfg.imgOnly) {
+ if (this.cfg.imgOnly) {

The double-negation (!!) is redundant here as the value is already being coerced to a boolean by the if condition. Removing it simplifies the expression without changing the logic.

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 41b2d1a and 51f094f.

Files selected for processing (2)
  • abstract/CTX.js (1 hunks)
  • abstract/UploaderBlock.js (5 hunks)
Files skipped from review as they are similar to previous changes (1)
  • abstract/CTX.js
Additional context used
Biome
abstract/UploaderBlock.js

[error] 387-390: The call chain .map().flat() can be replaced with a single .flatMap() call. (lint/complexity/useFlatMap)

Safe fix: Replace the chain with .flatMap().


[error] 586-586: Avoid redundant double-negation. (lint/complexity/noExtraBooleanCast)

It is not necessary to use double-negation when a value will already be coerced to a boolean.
Unsafe fix: Remove redundant double-negation

@nd0ut nd0ut merged commit e163ef7 into main Jun 23, 2024
1 check passed
@nd0ut nd0ut deleted the feat/remove-deprecated-api branch June 23, 2024 21:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants