diff --git a/packs/README.md b/packs/README.md index 46b4ab5..7b28be1 100644 --- a/packs/README.md +++ b/packs/README.md @@ -9,7 +9,8 @@ array. The index.json file should look something like this: ```json { - "homeserver_url": "https://example.com", + "homeserver_url": "https://example.com", // required + "homeserver_animated_url": "https://example.com", // optional : the URL of a webserver which provides a media repo with animated media support "packs": [ "your_telegram_imported_pack.json", "another_telegram_imported_pack.json", diff --git a/web/src/index.js b/web/src/index.js index a215c46..40236b6 100644 --- a/web/src/index.js +++ b/web/src/index.js @@ -28,10 +28,19 @@ const params = new URLSearchParams(document.location.search) if (params.has('config')) { INDEX = params.get("config") } + // This is updated from packs/index.json let HOMESERVER_URL = "https://matrix-client.matrix.org" +let HOMESERVER_ANIMATED_URL = HOMESERVER_URL + +const isAnimated = (content) => { + return content.info["mimetype"] === "image/gif"; +}; -const makeThumbnailURL = mxc => `${HOMESERVER_URL}/_matrix/media/r0/thumbnail/${mxc.substr(6)}?height=128&width=128&method=scale` +const makeThumbnailURL = (content) => { + const homeServerUrl = isAnimated(content) ? HOMESERVER_ANIMATED_URL : HOMESERVER_URL; + return `${homeServerUrl}/_matrix/media/r0/thumbnail/${content.url.substr(6)}?height=128&width=128&method=scale`; +}; // We need to detect iOS webkit because it has a bug related to scrolling non-fixed divs // This is also used to fix scrolling to sections on Element iOS @@ -164,6 +173,7 @@ class App extends Component { } const indexData = await indexRes.json() HOMESERVER_URL = indexData.homeserver_url || HOMESERVER_URL + HOMESERVER_ANIMATED_URL = indexData.homeserver_animated_url || HOMESERVER_URL // TODO only load pack metadata when scrolled into view? for (const packFile of indexData.packs) { let packRes @@ -336,7 +346,7 @@ const NavBarItem = ({ pack, iconOverride = null }) => html` ${iconOverride ? html` ` : html` - `} @@ -348,15 +358,15 @@ const Pack = ({ pack, send }) => html`