Skip to content

[Tweaks n' Stuff] Error on closing a dialog #895

Description

@SnaveSutit

The Issue

It appears as though this code is causing an error because the function Dialog.open passed to the event by this code is either null, undefined, or a function. Neither of which will have an id property to destructure.

Image

How to Reproduce

  1. Install Tweaks n' Stuff.
  2. Open any project.
  3. Open that project's properties dialog.
  4. Close that project's properties dialog.
  5. Note the error in the log.

The fix

The hide_dialog event dispatcher should instead set it's event data like so:

Dialog.prototype.hide = function (...args) {
    // @ts-ignore
    Blockbench.dispatchEvent("hide_dialog", {dialog: this});
    return Mixins.hideDialog.apply(this, args);
};

And the event listener should expect such data:

const hide = Blockbench.on("hide_dialog", ({ dialog }) => {
    if (dialog.id !== "settings_profile") return;
    this.update();
});

@legopitstop

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions