aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorS1m <git@sgougeon.fr>2021-09-19 17:35:28 +0200
committerS1m <git@sgougeon.fr>2021-09-19 17:35:28 +0200
commit5d3c7d1e2f6d631646ece755d443f59a76dc8f4f (patch)
tree1680c0b4f0d2fc29d45593c0261fcc9e98d631ef
parentec8eeeeaf526a122008aace7c71e5472bce832e6 (diff)
Allow using external index.json and stickerpack
-rw-r--r--web/src/index.js17
1 files changed, 15 insertions, 2 deletions
diff --git a/web/src/index.js b/web/src/index.js
index d084b37..0577b1f 100644
--- a/web/src/index.js
+++ b/web/src/index.js
@@ -21,6 +21,14 @@ import * as frequent from "./frequently-used.js"
// The base URL for fetching packs. The app will first fetch ${PACK_BASE_URL}/index.json,
// then ${PACK_BASE_URL}/${packFile} for each packFile in the packs object of the index.json file.
const PACKS_BASE_URL = "packs"
+
+let INDEX = `${PACKS_BASE_URL}/index.json`;
+let params = new URLSearchParams(document.location.search);
+let REMOTE = false;
+if (params.has('config')) {
+ INDEX = params.get("config");
+ REMOTE = true;
+}
// This is updated from packs/index.json
let HOMESERVER_URL = "https://matrix-client.matrix.org"
@@ -117,7 +125,7 @@ class App extends Component {
_loadPacks(disableCache = false) {
const cache = disableCache ? "no-cache" : undefined
- fetch(`${PACKS_BASE_URL}/index.json`, { cache }).then(async indexRes => {
+ fetch(INDEX, { cache }).then(async indexRes => {
if (indexRes.status >= 400) {
this.setState({
loading: false,
@@ -129,7 +137,12 @@ class App extends Component {
HOMESERVER_URL = indexData.homeserver_url || HOMESERVER_URL
// TODO only load pack metadata when scrolled into view?
for (const packFile of indexData.packs) {
- const packRes = await fetch(`${PACKS_BASE_URL}/${packFile}`, { cache })
+ let packRes;
+ if (REMOTE) {
+ packRes = await fetch(packFile, { cache })
+ } else {
+ packRes = await fetch(`${PACKS_BASE_URL}/${packFile}`, { cache })
+ }
const packData = await packRes.json()
for (const sticker of packData.stickers) {
this.stickersByID.set(sticker.id, sticker)
send patches to the email below
yukais@pinapelz.com
include the subject [PATCH repo_name]
pinapelz.com
homepage