MCPcopy Index your code
hub / github.com/spicetify/cli / openConfig

Function openConfig

CustomApps/reddit/Settings.js:3–116  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

1let configContainer;
2
3function openConfig() {
4 if (configContainer) {
5 Spicetify.PopupModal.display({
6 title: "Reddit",
7 content: configContainer,
8 });
9 return;
10 }
11
12 CONFIG.servicesElement = {};
13
14 configContainer = document.createElement("div");
15 configContainer.id = "reddit-config-container";
16
17 const optionHeader = document.createElement("h2");
18 optionHeader.innerText = "Options";
19
20 const serviceHeader = document.createElement("h2");
21 serviceHeader.innerText = "Subreddits";
22
23 const serviceContainer = document.createElement("div");
24
25 function stackServiceElements() {
26 CONFIG.services.forEach((name, index) => {
27 const el = CONFIG.servicesElement[name];
28
29 const [up, down] = el.querySelectorAll("button");
30 if (CONFIG.services.length === 1) {
31 up.disabled = true;
32 down.disabled = true;
33 } else if (index === 0) {
34 up.disabled = true;
35 down.disabled = false;
36 } else if (index === CONFIG.services.length - 1) {
37 up.disabled = false;
38 down.disabled = true;
39 } else {
40 up.disabled = false;
41 down.disabled = false;
42 }
43
44 serviceContainer.append(el);
45 });
46 gridUpdateTabs?.();
47 }
48
49 function posCallback(el, dir) {
50 const id = el.dataset.id;
51 const curPos = CONFIG.services.findIndex((val) => val === id);
52 const newPos = curPos + dir;
53
54 if (CONFIG.services.length > 1) {
55 const temp = CONFIG.services[newPos];
56 CONFIG.services[newPos] = CONFIG.services[curPos];
57 CONFIG.services[curPos] = temp;
58 }
59
60 localStorage.setItem("reddit:services", JSON.stringify(CONFIG.services));

Callers

nothing calls this directly

Calls 4

displayMethod · 0.80
createServiceOptionFunction · 0.70
stackServiceElementsFunction · 0.70
createSliderFunction · 0.70

Tested by

no test coverage detected