New addon: "delete other assets" (`delete-others`) by jazzathedev · Pull Request #7030 · ScratchAddons/ScratchAddons · GitHub
Skip to content

New addon: "delete other assets" (delete-others) - #7030

Merged
WorldLanguages merged 26 commits into
ScratchAddons:masterfrom
jazzathedev:delete-others
Jun 11, 2024
Merged

WorldLanguages merged 26 commits into
ScratchAddons:masterfrom
jazzathedev:delete-others

Conversation

@jazzathedev

Copy link
Copy Markdown
Contributor

Resolves #4692

Changes

Adds a button to the right click menu for costumes, backdrops, and sounds to delete all the others.

Reason for changes

Apparently people want this.

Tests

Tested on brave, restore deleted costumes etc work, i think its all good. Please suggest changes to addon.json name and desc etc

@ghost

This comment was marked as resolved.

@Joeclinton1 Joeclinton1 left a comment •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

The functionality works well, I just have some nitpick comments on the code:

  • Can you use a single decrementing for loop to delete the costumes? This is a common and recommended method for modifying an array that you are also iterating over.
  • Instead of having two separate parts of logic for sound and costume, can you combine them into a unified loop by using ternary operations for the functions that differ.
    -- E.g deleted = (type === "costume") ? target.deleteCostume(0) : target.deleteSound(0);
  • can you unify the getRestoreCostumeFun and getRestoreSoundFun by making it take "costume" or "sound" as an input and performing the right logic.

The purpose of the unification changes is to reduce code duplication

@jazzathedev

Copy link
Copy Markdown
Contributor Author

@Samq64

Samq64 commented Jan 2, 2024 •

Copy link
Copy Markdown
Member

Shouldn't this be marked dangerous?
EDIT: Oh wait, there's a confirmation. Didn't notice.

I'm not saying it needs to be but disable auto save doesn't remove the confirmation but it's still marked as dangerous.

@Samq64 Samq64 added type: enhancement New feature for the project new addon Related to new addons to this extension. `scope: addon` should still be added. scope: addon Related to one or multiple addons labels Jan 2, 2024
@jazzathedev

Copy link
Copy Markdown
Contributor Author

@Joeclinton1 done, done and done

@WorldLanguages

Copy link
Copy Markdown
Member

Tested on brave, restore deleted costumes etc work,

So does it restore all of the deleted costumes/sounds? I think this is quite important and we didn't mention it in #4692. It's sometimes easy to forget about undo.

@jazzathedev

Copy link
Copy Markdown
Contributor Author

It sure does!

@Secret-chest

Copy link
Copy Markdown
Contributor

I'm not saying it needs to be but disable auto save doesn't remove the confirmation but it's still marked as dangerous.

It's a browser native confirmation, and it should be dangerous because you will forget to save, here you need to invoke it manually.

@Joeclinton1 Joeclinton1 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Works well, and code is much cleaner now. Well done!

Comment thread addons/delete-others/userscript.js Outdated

@Samq64 Samq64 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Could the menu item be made orange by marking it as dangerous? It would also be nice if the restore message was made plural but that isn't really necessary.

Comment thread addons/delete-others/userscript.js
Comment thread addons/delete-others/userscript.js Outdated
@jazzathedev

Copy link
Copy Markdown
Contributor Author

Could the menu item be made orange by marking it as dangerous

I added the dangerous property and set it to true as a test and it seemed to not change the colour? I'm not sure why, perhaps I did something wrong, could someone suggest the code change so that I can see if I'm doing it right?

It would also be nice if the restore message was made plural but that isn't really necessary.

Yeah that annoyed me too, I'll see if it's decently easy for me to do.

@Joeclinton1

Copy link
Copy Markdown
Member

I don't think this should be marked as dangerous, since you can just restore the costumes, there's nothing dangerous about it. This also doesn't remove functionality it adds functionality.

@DNin01

DNin01 commented Jan 4, 2024 •

Copy link
Copy Markdown
Member

I don't think this should be marked as dangerous, since you can just restore the costumes, there's nothing dangerous about it. This also doesn't remove functionality it adds functionality.

I think they were talking about changing the "delete others" button in the context menu to use the color orange when hovered over.

@jazzathedev

Copy link
Copy Markdown
Contributor Author
image image It seems that even with dangerous: true, the button does not change colour when hovered. Tbh, I don't think it needs to be dangerous, there is a confirmation, and you can restore the costumes easily

@mxmou

mxmou commented Jan 5, 2024

Copy link
Copy Markdown
Member

It seems that even with dangerous: true, the button does not change colour when hovered.

That's a bug in editor dark mode. It does become orange on hover if dark mode is disabled.

@jazzathedev

Copy link
Copy Markdown
Contributor Author

Oh ok, I'll add it then

@jazzathedev

Copy link
Copy Markdown
Contributor Author

This should be ready for final reviews and approvals

@Joeclinton1 Joeclinton1 left a comment •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM!

@Samq64 Samq64 removed the status: needs review PR needs 1 more approval label May 17, 2024
Comment thread addons-l10n/en/delete-others.json Outdated
Comment thread addons/delete-others/addon.json Outdated
@mxmou mxmou added the status: needs review PR needs 1 more approval label Jun 9, 2024
@WorldLanguages WorldLanguages changed the title Delete other assets New addon: "delete other assets" (delete-others) Jun 9, 2024
@WorldLanguages

WorldLanguages commented Jun 9, 2024 •

Copy link
Copy Markdown
Member

@WorldLanguages WorldLanguages self-assigned this Jun 9, 2024
Co-authored-by: Maximouse <51849865+mxmou@users.noreply.github.com>
Comment thread addons/delete-others/userscript.js Outdated
@WorldLanguages WorldLanguages removed the status: needs review PR needs 1 more approval label Jun 9, 2024
Co-authored-by: Maximouse <51849865+mxmou@users.noreply.github.com>
Comment thread addons/delete-others/userscript.js Outdated
Comment thread addons/delete-others/userscript.js
@WorldLanguages WorldLanguages added the status: awaiting answer/followup A comment will be sent if there's no activity for 7 days, for issues that have this label. label Jun 9, 2024
Comment thread addons/delete-others/userscript.js Outdated
@WorldLanguages WorldLanguages removed the status: awaiting answer/followup A comment will be sent if there's no activity for 7 days, for issues that have this label. label Jun 11, 2024
@WorldLanguages
WorldLanguages merged commit 0da7e1c into ScratchAddons:master Jun 11, 2024
Comment thread addons/delete-others/addon.json
Comment thread addons/delete-others/addon.json
ilim-cell pushed a commit to ilim-cell/CodeTorchAddons that referenced this pull request Sep 29, 2026
* initial commit

* remove dem dynamics

* confirm

* this should work, testing now

* here

* getting there

* DANGER!!!!

* fuck yes

* no r

* Window.addon is crucial to the working of this addon so we will remove it

Co-authored-by: Samq64 <81489795+Samq64@users.noreply.github.com>

* smaller popup and string changes

* reverse

* dynam en dis

* stupid strings

* opti and var name change

* shit forgot that -1

* fix sounds being added in thr wrong order

* update ver

* Update versionAdded

Co-authored-by: Maximouse <51849865+mxmou@users.noreply.github.com>

* Arrow fix by mxmou

Co-authored-by: Maximouse <51849865+mxmou@users.noreply.github.com>

* Useless await

* Use internal variable instead of abusing Redux

* Cleanup variables

* Use editingTarget.addCostume instead

---------

Co-authored-by: Samq64 <81489795+Samq64@users.noreply.github.com>
Co-authored-by: W_L <mundofinky@gmail.com>
Co-authored-by: Maximouse <51849865+mxmou@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

new addon Related to new addons to this extension. `scope: addon` should still be added. scope: addon Related to one or multiple addons type: enhancement New feature for the project

Projects

None yet

Development

Successfully merging this pull request may close these issues.

"Delete others" button on costumes and sounds context menu

7 participants