Settings › About's Download source said "from usemagpie.ai, and from
GitHub when that fails" whatever Update source said, right above it: with
usemagpie.ai only it still offered a GitHub mirror that is never used
(the site alone never asks GitHub), and with GitHub only it still named
usemagpie.ai as the source and the checksum's home. Its line, its
tooltip and its host now follow Update source: site says no mirror is
used, GitHub only says updates come from GitHub (or through the mirror)
and are checked against the release's signed checksums.
The row's drawing (renderUpdateMirror, setUpdateMirror, editMirror) moved
into updatesource.js, which About already imports for Update source, so
the core's script shrinks rather than grows; no budget raise.
Run (mica, at this tree):
- settings-update-source (Chromium and WebKit, every language, 1100 and
420 wide), update-mirror, i18n-keys: 56 pass.
- the 18 GUI files that open Settings › About or search Settings
(update-*, whats-new*, segs-glide, uninstall-settings,
settings-search, settings-groups, gui-de): 409 pass, 6 red, all in
settings-groups' "warm-ups and check-in" (an extra "Spend extra usage"
row), red the same on origin/main 265217bf4 and filed as #6597.
- go test ./internal/gui -run 'TestCoreScriptBudget|TestI18n|TestCSS': ok.
Broken by hand: Download source reading "" for the source:
settings-update-source 10 of 10 red (Chromium), then put back.
Not tried: the real app window.
63 lines
3.9 KiB
JavaScript
63 lines
3.9 KiB
JavaScript
// Settings › About's Update source (RootSir and Sakugar_ on X): where an
|
||
// update is read and downloaded from, one menu button as the language's is.
|
||
// app.js imports this when the page is drawn, so it weighs nothing on the
|
||
// core. "" is automatic; site never goes to GitHub, github never to
|
||
// usemagpie.ai.
|
||
window.updateSourcePick = function updateSourcePick(s, keep) {
|
||
const names = { "": "Automatic", site: "usemagpie.ai only", github: "GitHub only" };
|
||
const b = $("#updateSourcePick");
|
||
const chosen = s.updateSource in names ? s.updateSource : "";
|
||
b.dataset.value = chosen;
|
||
b.setAttribute("aria-label", t("Update source"));
|
||
b.replaceChildren(el("span", "", t(names[chosen])), svg(CHEV, 11, 1.6));
|
||
b.onclick = (e) => {
|
||
e.stopPropagation();
|
||
if (b.classList.contains("open")) return closeProtoMenu();
|
||
openProtoMenu(b, Object.entries(names).map(([v, name]) => ({ v, name, note: "" })), chosen, (v) => {
|
||
if (v !== chosen) savePrefs({ ...keep, updateSource: v });
|
||
}, "Update source", "sess-menu", "right");
|
||
};
|
||
};
|
||
|
||
// Settings' Download source, drawn here with Update source so it weighs
|
||
// nothing on the core; it says what the source picked does
|
||
window.setUpdateMirror = function (mirror) {
|
||
return writingPrefs(api("settings/update-mirror", { mirror }))
|
||
.then((ns) => { prefs = ns; mirrorEditing = false; mirrorDraft = mirrorErr = ""; renderSettings(); status(t("Saved"), "ok", 1500); return ns; });
|
||
};
|
||
// Use a mirror… and Change open the field from mirroredit.js
|
||
const editMirror = (r, s, v) => import("./mirroredit.js").then(() => { mirrorEditing = true; mirrorDraft = v; renderUpdateMirror(r, s); }, statusErr);
|
||
window.renderUpdateMirror = function (r, s) {
|
||
r.classList.add("update-mirror-row");
|
||
const who = r.querySelector(".who"), val = r.querySelector(".val");
|
||
who.querySelector(".sub")?.remove();
|
||
val.replaceChildren();
|
||
const sub = el("div", "sub");
|
||
who.append(sub);
|
||
const m = s.updateMirror || "", from = s.updateSource;
|
||
// as Update source says: site never asks GitHub, so no mirror is used
|
||
sub.textContent = mirrorErr || (from === "site" ? t("Update source is usemagpie.ai only: updates never come from GitHub, so no mirror is used")
|
||
: from === "github" ? (m ? t("Update source is GitHub only: updates come through this mirror, each checked against the release's signed checksums") : t("Update source is GitHub only: updates come from GitHub; a mirror can stand in for it where it is slow"))
|
||
: m ? t("Updates are downloaded from usemagpie.ai, and through this mirror when that fails, each checked against usemagpie.ai's checksum")
|
||
: t("Updates are downloaded from usemagpie.ai, and from GitHub when that fails; a mirror can stand in for GitHub where it is slow"));
|
||
// the docs' Mirrors page says which mirror and how (WeltAn_X on X)
|
||
const more = el("button", "sub-more", t("How mirrors work"));
|
||
more.onclick = () => api("open", { url: "https://usemagpie.ai/docs/" + ({ zh: "zh/", "zh-TW": "zh/", ja: "ja/" }[locale] || "") + "mirrors#settings" }).catch(() => {});
|
||
sub.append(" ", more);
|
||
sub.classList.toggle("err", !!mirrorErr);
|
||
sub.title = from === "github" ? t("The checksums come signed with the release; a file from the mirror that doesn't match them is not installed.")
|
||
: t("The update and its checksum always come from usemagpie.ai; a file from the mirror that doesn't match it is not installed.");
|
||
if (mirrorEditing) return mirrorEdit(r, s, sub, val);
|
||
if (m) {
|
||
const official = el("button", "text", t("Remove mirror"));
|
||
official.onclick = () => setUpdateMirror("").catch(statusTErr);
|
||
const change = el("button", "text", t("Change"));
|
||
change.onclick = () => editMirror(r, s, m);
|
||
val.append(el("code", "", m), change, official);
|
||
} else {
|
||
const add = el("button", "text", t("Use a mirror…"));
|
||
add.onclick = () => editMirror(r, s, "");
|
||
val.append(el("code", "", from === "github" ? "github.com" : "usemagpie.ai"), add);
|
||
}
|
||
};
|