assets: recuperar las tres imagenes de UX que faltaban
La pantalla de ajustes y el asistente de bienvenida piden ux-blocks.png, ux-chats.png y ux-ainav.png para el selector de modo de interfaz. No se copiaron al integrar 0.9.5, asi que el selector salia con tres imagenes rotas. De paso se retira media-favorites.js con su JSON: es de una version anterior de la rama y ya no lo requiere nadie, upstream lo resuelve con content_favorites.js.
This commit is contained in:
parent
48cafbbe59
commit
37937e8363
5 changed files with 0 additions and 139 deletions
|
|
@ -1,126 +0,0 @@
|
||||||
const fs = require("fs");
|
|
||||||
const path = require("path");
|
|
||||||
|
|
||||||
const FILE = path.join(__dirname, "../configs/media-favorites.json");
|
|
||||||
|
|
||||||
const DEFAULT = {
|
|
||||||
audios: [],
|
|
||||||
bookmarks: [],
|
|
||||||
calendars: [],
|
|
||||||
chats: [],
|
|
||||||
documents: [],
|
|
||||||
images: [],
|
|
||||||
maps: [],
|
|
||||||
pads: [],
|
|
||||||
shops: [],
|
|
||||||
market: [],
|
|
||||||
shopProducts: [],
|
|
||||||
torrents: [],
|
|
||||||
videos: []
|
|
||||||
};
|
|
||||||
|
|
||||||
const safeArr = (v) => (Array.isArray(v) ? v : []);
|
|
||||||
|
|
||||||
let queue = Promise.resolve();
|
|
||||||
|
|
||||||
const withLock = (fn) => {
|
|
||||||
queue = queue.then(fn, fn);
|
|
||||||
return queue;
|
|
||||||
};
|
|
||||||
|
|
||||||
const normalize = (raw) => {
|
|
||||||
const out = {};
|
|
||||||
for (const k of Object.keys(DEFAULT)) {
|
|
||||||
const list = safeArr(raw?.[k]).map((x) => String(x || "").trim()).filter(Boolean);
|
|
||||||
out[k] = Array.from(new Set(list));
|
|
||||||
}
|
|
||||||
return out;
|
|
||||||
};
|
|
||||||
|
|
||||||
const ensureFile = async () => {
|
|
||||||
try {
|
|
||||||
await fs.promises.access(FILE);
|
|
||||||
} catch (e) {
|
|
||||||
const dir = path.dirname(FILE);
|
|
||||||
await fs.promises.mkdir(dir, { recursive: true });
|
|
||||||
await fs.promises.writeFile(FILE, JSON.stringify(DEFAULT, null, 2), "utf8");
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
const readAll = async () => {
|
|
||||||
await ensureFile();
|
|
||||||
try {
|
|
||||||
const txt = await fs.promises.readFile(FILE, "utf8");
|
|
||||||
return normalize(JSON.parse(txt || "{}"));
|
|
||||||
} catch (e) {
|
|
||||||
const fixed = normalize(DEFAULT);
|
|
||||||
await fs.promises.writeFile(FILE, JSON.stringify(fixed, null, 2), "utf8");
|
|
||||||
return fixed;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
const writeAll = async (data) => {
|
|
||||||
const dir = path.dirname(FILE);
|
|
||||||
const tmp = path.join(dir, `.media-favorites.${process.pid}.${Date.now()}.tmp`);
|
|
||||||
const txt = JSON.stringify(normalize(data), null, 2);
|
|
||||||
await fs.promises.writeFile(tmp, txt, "utf8");
|
|
||||||
await fs.promises.rename(tmp, FILE);
|
|
||||||
};
|
|
||||||
|
|
||||||
const assertKind = (kind) => {
|
|
||||||
const k = String(kind || "").trim();
|
|
||||||
if (!Object.prototype.hasOwnProperty.call(DEFAULT, k)) throw new Error("Invalid favorites kind");
|
|
||||||
return k;
|
|
||||||
};
|
|
||||||
|
|
||||||
const lastArg = (args, n) => args[args.length - n];
|
|
||||||
|
|
||||||
const kindFromArgs = (args) => {
|
|
||||||
const k = String(lastArg(args, 1) || "").trim();
|
|
||||||
return assertKind(k);
|
|
||||||
};
|
|
||||||
|
|
||||||
const idFromArgs = (args) => String(lastArg(args, 1) || "").trim();
|
|
||||||
|
|
||||||
exports.getFavoriteSet = async (kind) => {
|
|
||||||
const k = assertKind(kind);
|
|
||||||
const data = await readAll();
|
|
||||||
return new Set(safeArr(data[k]).map(String));
|
|
||||||
};
|
|
||||||
|
|
||||||
exports.addFavorite = async (kind, id) =>
|
|
||||||
withLock(async () => {
|
|
||||||
const k = assertKind(kind);
|
|
||||||
const favId = String(id || "").trim();
|
|
||||||
if (!favId) return;
|
|
||||||
const data = await readAll();
|
|
||||||
const set = new Set(safeArr(data[k]).map(String));
|
|
||||||
set.add(favId);
|
|
||||||
data[k] = Array.from(set);
|
|
||||||
await writeAll(data);
|
|
||||||
});
|
|
||||||
|
|
||||||
exports.removeFavorite = async (kind, id) =>
|
|
||||||
withLock(async () => {
|
|
||||||
const k = assertKind(kind);
|
|
||||||
const favId = String(id || "").trim();
|
|
||||||
if (!favId) return;
|
|
||||||
const data = await readAll();
|
|
||||||
const set = new Set(safeArr(data[k]).map(String));
|
|
||||||
set.delete(favId);
|
|
||||||
data[k] = Array.from(set);
|
|
||||||
await writeAll(data);
|
|
||||||
});
|
|
||||||
|
|
||||||
exports.getFavoritesSet = async (...args) => exports.getFavoriteSet(kindFromArgs(args));
|
|
||||||
exports.addToFavorites = async (...args) => {
|
|
||||||
const kind = kindFromArgs(args.slice(0, -1));
|
|
||||||
const id = idFromArgs(args);
|
|
||||||
return exports.addFavorite(kind, id);
|
|
||||||
};
|
|
||||||
exports.removeFromFavorites = async (...args) => {
|
|
||||||
const kind = kindFromArgs(args.slice(0, -1));
|
|
||||||
const id = idFromArgs(args);
|
|
||||||
return exports.removeFavorite(kind, id);
|
|
||||||
};
|
|
||||||
|
|
||||||
BIN
src/client/assets/images/ux-ainav.png
Normal file
BIN
src/client/assets/images/ux-ainav.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 2.3 KiB |
BIN
src/client/assets/images/ux-blocks.png
Normal file
BIN
src/client/assets/images/ux-blocks.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 2.5 KiB |
BIN
src/client/assets/images/ux-chats.png
Normal file
BIN
src/client/assets/images/ux-chats.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 3.2 KiB |
|
|
@ -1,13 +0,0 @@
|
||||||
{
|
|
||||||
"audios": [],
|
|
||||||
"bookmarks": [],
|
|
||||||
"calendars": [],
|
|
||||||
"chats": [],
|
|
||||||
"documents": [],
|
|
||||||
"images": [],
|
|
||||||
"maps": [],
|
|
||||||
"pads": [],
|
|
||||||
"shops": [],
|
|
||||||
"torrents": [],
|
|
||||||
"videos": []
|
|
||||||
}
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue