WeakAuras / WeakAuras2

World of Warcraft addon that provides a powerful framework to display customizable graphics on your screen.
https://weakauras.wtf
GNU General Public License v2.0
1.32k stars 318 forks source link

Add "Clean/Optimize" Button to Remove Unused Configuration Data in WeakAuras #5511

Closed masterkain closed 3 weeks ago

masterkain commented 3 weeks ago

WeakAuras currently retains configuration data—including triggers, actions, and load conditions—even when they are no longer in use. For example, if I create a WeakAura with a custom trigger and associated Lua functions, then later convert it to a built-in Health trigger, the custom code remains embedded in the final WeakAuras.lua file. This residual code ensures that if I revert to the custom trigger, the original functions are still intact.

Issues:

Proposed Solution: Introduce a "Clean" or "Optimize" button within the WeakAuras interface. This feature would:

Consider the following WeakAura configuration:

{
    ["trigger"] = {
        ["type"] = "unit",
        ["use_absorbHealMode"] = true,
        ["custom_type"] = "status",
        ["custom_hide"] = "timed",
        ["percenthealth"] = {
            "75",
            "0",
        },
        ["event"] = "Health",
        ["unit"] = "player",
        ["use_absorbMode"] = true,
        ["events"] = "UNIT_HEALTH:player",
        ["custom"] = 'function()\n    local maxHealth blabla',
        ["use_unit"] = true,
        ["check"] = "event",
        ["use_percenthealth"] = true,
        ["percenthealth_operator"] = {
            "<=",
            ">",
        },
        ["debuffType"] = "HELPFUL",
    },
    ["untrigger"] = {
        ["custom"] = 'function()\n    local maxHealth blabla',
    },
}

In this example, a custom trigger was initially used but later converted to a standard Health trigger. However, the custom trigger and untrigger code remain in the configuration. A "Clean" button would remove these unused custom functions, resulting in a streamlined WeakAura that reflects only the current active settings.

Since WeakAuras does not immediately writes the file upon editing maybe there can be a checkbox in the info panel that when enabled it will save that weakaura as "cleaned/optimized", warning the user there will be no undos.

InfusOnWoW commented 3 weeks ago

Duplicate of https://github.com/WeakAuras/WeakAuras2/issues/803