mirror of
https://github.com/redphx/better-xcloud.git
synced 2025-08-05 12:56:42 +02:00
Cache base custom touch layouts
This commit is contained in:
@@ -3472,6 +3472,7 @@ class TouchController {
|
|||||||
static #dataChannel;
|
static #dataChannel;
|
||||||
|
|
||||||
static #customLayouts = {};
|
static #customLayouts = {};
|
||||||
|
static #baseCustomLayouts = {};
|
||||||
static #currentLayoutId;
|
static #currentLayoutId;
|
||||||
|
|
||||||
static enable() {
|
static enable() {
|
||||||
@@ -3559,10 +3560,22 @@ class TouchController {
|
|||||||
|
|
||||||
const layouts = {};
|
const layouts = {};
|
||||||
|
|
||||||
json.layouts.forEach(async file => {
|
json.layouts.forEach(async layoutName => {
|
||||||
const layoutUrl = `${baseUrl}/layouts/${file}.json`;
|
let baseLayouts = {};
|
||||||
const json = await (await NATIVE_FETCH(layoutUrl)).json();
|
if (layoutName in TouchController.#baseCustomLayouts) {
|
||||||
Object.assign(layouts, json.layouts);
|
baseLayouts = TouchController.#baseCustomLayouts[layoutName];
|
||||||
|
} else {
|
||||||
|
try {
|
||||||
|
const layoutUrl = `${baseUrl}/layouts/${layoutName}.json`;
|
||||||
|
const resp = await NATIVE_FETCH(layoutUrl);
|
||||||
|
const json = await resp.json();
|
||||||
|
|
||||||
|
baseLayouts = json.layouts;
|
||||||
|
TouchController.#baseCustomLayouts[layoutName] = baseLayouts;
|
||||||
|
} catch (e) {}
|
||||||
|
}
|
||||||
|
|
||||||
|
Object.assign(layouts, baseLayouts);
|
||||||
});
|
});
|
||||||
|
|
||||||
json.layouts = layouts;
|
json.layouts = layouts;
|
||||||
|
Reference in New Issue
Block a user