Browse Source

Create sortMenuMode.js

Adds menu option to override litegraph default menu sorting behavior
pull/2370/head
jyokum 11 months ago
parent
commit
d3b35605d4
  1. 37
      web/extensions/core/sortMenuMode.js

37
web/extensions/core/sortMenuMode.js

@ -0,0 +1,37 @@
import { app } from "../../scripts/app.js";
const id = "Comfy.SortMenuMode";
const ext = {
name: id,
async setup(app) {
app.ui.settings.addSetting({
id,
name: "Sort Menu",
type: "combo",
defaultValue: 0,
options: [
{ text: "LiteGraph Default", value: "litegraph" },
{ text: "True", value: "true" },
{ text: "False", value: "false" },
],
onChange(value) {
switch (value) {
case "litegraph": // Default
if (localStorage.getItem("Comfy.Settings.Comfy.SortMenuMode.defAutoSort") != null) {
LiteGraph.auto_sort_node_types = JSON.parse(localStorage.getItem("Comfy.Settings.Comfy.SortMenuMode.defAutoSort")); // reset to original;
localStorage.removeItem("Comfy.Settings.Comfy.SortMenuMode.defAutoSort");
}
break;
default:
if (localStorage.getItem("Comfy.Settings.Comfy.SortMenuMode.defAutoSort") == null) {
localStorage.setItem(["Comfy.Settings.Comfy.SortMenuMode.defAutoSort"], LiteGraph.auto_sort_node_types);
}
LiteGraph.auto_sort_node_types = JSON.parse(value);
}
},
});
},
};
app.registerExtension(ext);
Loading…
Cancel
Save