Skip to content

Commit 166f443

Browse files
committed
[shelter] read available branches from file
1 parent 84219a1 commit 166f443

File tree

2 files changed

+9
-18
lines changed

2 files changed

+9
-18
lines changed

branches/mod/shelter/preload.js

+8-17
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
const fss = require("fs");
1+
const fs = require("fs");
22
const path = require("path");
33
const { contextBridge, ipcRenderer, webFrame } = require("electron");
44

55
// get selector UI content
6-
const selUiJs = fss.readFileSync(path.join(__dirname, "selector-ui.js"), "utf8");
6+
const selUiJs = fs.readFileSync(path.join(__dirname, "selector-ui.js"), "utf8");
77

88
// build shelter injector plugins manifest
99
const injPlugins = {
@@ -29,7 +29,7 @@ ipcRenderer.invoke("SHELTER_BUNDLE_FETCH").then((bundle) => {
2929

3030
// everything below this comment is for the plugin selector UI exclusively
3131

32-
// fetch branches from server, then create a structure like:
32+
// read branches and then create a structure like:
3333
/*
3434
const branches = {
3535
shelter: {
@@ -46,26 +46,17 @@ ipcRenderer.invoke("SHELTER_BUNDLE_FETCH").then((bundle) => {
4646
}
4747
*/
4848

49-
let branches = {};
50-
51-
fetch("https://inject.shelter.uwu.network/sheltupdate_branches")
52-
.then((r) => r.json())
53-
.then(
54-
(branches_raw) =>
55-
(branches = Object.fromEntries(
56-
branches_raw.map((branch) => [
57-
branch.name,
58-
{ ...branch, name: branch.displayName, desc: branch.description },
59-
]),
60-
)),
61-
);
49+
const branchesRaw = JSON.parse(fs.readFileSync(path.join(__dirname, "branches.json"), "utf8"));
50+
const branches = Object.fromEntries(
51+
branchesRaw.map((branch) => [branch.name, { ...branch, name: branch.displayName, desc: branch.description }]),
52+
);
6253

6354
const readBranches = () => ipcRenderer.invoke("SHELTER_BRANCH_GET");
6455

6556
const setBranches = (branches) => ipcRenderer.invoke("SHELTER_BRANCH_SET", branches);
6657

6758
contextBridge.exposeInMainWorld("SheltupdateNative", {
68-
getAllowedBranches: () => Promise.resolve(branches),
59+
getAvailableBranches: () => Promise.resolve(branches),
6960
getCurrentBranches: readBranches,
7061

7162
setBranches: async (br) => {

branches/mod/shelter/selector-ui.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
if (window.BdApi && !currentBranches().includes("betterdiscord")) setBdOtherwiseLoaded(true);
3535
});
3636

37-
SheltupdateNative.getAllowedBranches().then((branches) => {
37+
SheltupdateNative.getAvailableBranches().then((branches) => {
3838
// group by type, conveniently "mod" is before "tool" alphabetically
3939
const grouped = {};
4040
for (const branchName in branches) {

0 commit comments

Comments
 (0)