Skip to content

_⚠️ Potential issue_ #15

@gitnasr

Description

@gitnasr

⚠️ Potential issue

Image-count limit still bypassable

Users can select >3 files in one dialog. Cap total previews to 3:

-for (let i = 0; i < files.length; i++) {
+for (let i = 0; i < files.length && this.imagePreviews.length < 3; i++) {

Optionally show a toast when the limit is reached.

Minor: type the event properly to avoid any:

onFileSelected(event: Event): void {
  const input = event.target as HTMLInputElement;
  const files = input.files!;
  ...
}
🤖 Prompt for AI Agents
In src/app/features/add-new-post/add-new-post.component.ts around lines 235 to
277, the current code allows users to select more than 3 image files, bypassing
the intended limit. To fix this, add a check to cap the total number of image
previews to 3 by limiting the loop or skipping files beyond the third. Also,
replace the event parameter type from 'any' to 'Event' and cast event.target to
HTMLInputElement to properly type the files variable. Optionally, add a toast
notification when the limit is reached to inform users.

Originally posted by @coderabbitai[bot] in #14 (comment)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions