-
-
Notifications
You must be signed in to change notification settings - Fork 7
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
Feature: copy/paste images into tier list #146
base: main
Are you sure you want to change the base?
Feature: copy/paste images into tier list #146
Conversation
…s and onItemsCreate functions
@Selenestica is attempting to deploy a commit to the Infinia Team on Vercel. A member of the Team first needs to authorize it. |
WalkthroughThis pull request introduces enhancements to the tier list functionality, focusing on improving item management and image handling. The changes span across three files: Changes
Assessment against linked issues
Possibly related PRs
Suggested reviewers
Poem
Tip CodeRabbit's docstrings feature is now available as part of our Early Access Program! Simply use the command 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? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
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 using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
🧹 Nitpick comments (2)
components/DragDropTierList.tsx (2)
119-144
: Consider usingfor...of
instead offor...in
for clipboard items.
Within theonPasteItem
method,for...in
iterates over all enumerable properties, which may include unintended keys. Switching tofor...of
(or using array methods) would be more robust when processing items.-for (const index in items) { - const item = items[index]; +for (const item of items) {
144-144
: Possible storage-size constraints.
Storing base64-encoded images in localStorage may cause size limitations if users paste numerous or large images. Consider an alternative storage mechanism (e.g., IndexedDB) or controlling maximum uploads to avoid potential out-of-space issues.Would you like suggestions for leveraging IndexedDB or an alternative storage strategy?
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (3)
components/DragDropTierList.tsx
(1 hunks)components/TierListManager.tsx
(1 hunks)lib/TierCortex.ts
(1 hunks)
✅ Files skipped from review due to trivial changes (1)
- components/TierListManager.tsx
🧰 Additional context used
🪛 Biome (1.9.4)
lib/TierCortex.ts
[error] 93-93: Do not access Object.prototype method 'hasOwnProperty' from target object.
It's recommended using Object.hasOwn() instead of using Object.hasOwnProperty().
See MDN web docs for more details.
(lint/suspicious/noPrototypeBuiltins)
🔇 Additional comments (4)
components/DragDropTierList.tsx (2)
20-21
: New prop for item creation looks correct.
The addition of onItemsCreate
to the props interface is consistent with the rest of the code, enabling callbacks for newly pasted or created items.
309-343
: Deletion workflow is well-structured.
The handleDeleteItem
and handleUndoDelete
functions effectively manage item removal, using toast-based undo actions and a shared deletedItemsRef
. This pattern is clear and maintainable.
lib/TierCortex.ts (2)
189-208
: New utility methods effectively safeguard URLs.
The getOgSafeImageUrl
and getOgSafeItem
methods ensure WebP URLs are converted to PNG and that relative paths become absolute. This helps maintain consistent rendering across various environments.
210-217
: Package resolution and asset fetching logic is sound.
The resolveItemsFromPackage
method properly constructs item IDs, while getAssetUrl
defers to getAbsoluteUrl
to produce absolute paths. These enhancements promote modular code and reusability.
Also applies to: 220-221
public isCustomItem(itemId: string): boolean { | ||
return !this.packageItemLookup.hasOwnProperty(itemId); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🛠️ Refactor suggestion
Avoid hasOwnProperty
from the instance directly.
Static analysis warns about using .hasOwnProperty()
from an object. It's safer and clearer to use Object.hasOwn()
or Object.prototype.hasOwnProperty.call(...)
.
-public isCustomItem(itemId: string): boolean {
- return !this.packageItemLookup.hasOwnProperty(itemId);
+public isCustomItem(itemId: string): boolean {
+ return !Object.hasOwn(this.packageItemLookup, itemId);
}
📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
public isCustomItem(itemId: string): boolean { | |
return !this.packageItemLookup.hasOwnProperty(itemId); | |
public isCustomItem(itemId: string): boolean { | |
return !Object.hasOwn(this.packageItemLookup, itemId); | |
} |
🧰 Tools
🪛 Biome (1.9.4)
[error] 93-93: Do not access Object.prototype method 'hasOwnProperty' from target object.
It's recommended using Object.hasOwn() instead of using Object.hasOwnProperty().
See MDN web docs for more details.
(lint/suspicious/noPrototypeBuiltins)
Fixes: #107
Description
Users can copy an image from the internet and paste it into the tier list, removing the need for users to download images from the internet and then upload them.
Checklist:
Additional context
Summary by CodeRabbit
New Features
Improvements
Code Maintenance