Skip to content

Commit

Permalink
getNewUrl - tiny fix
Browse files Browse the repository at this point in the history
  • Loading branch information
JasminDreasond committed Jul 23, 2024
1 parent efdaf98 commit ccfa871
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 7 deletions.
4 changes: 2 additions & 2 deletions info/dev/requests.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ Botão de copiar imagem.
Ajeitar PowerLevelSelector.jsx
Ajeitar o selecionador de custom status icon.

Opção para ocultar localmente a lista de threads.

Compu
@Tiny Jasmini do u think u could make it so broken images for space icons fall back to the default colored icons for spaces without images set? preferably change it to show the first letter of the space's name?
if media breaks then having just a list of identical broken image icons makes things difficult
Expand All @@ -13,8 +15,6 @@ currently it's just ordered by when u clicked the "use globally" checkbox for ea

Buttons in the picture viewer to go to the next/previous image in the chat

Buscador de emojis de custom status fica gelado.

Usar a mesma lógica de carregar emojis para deixar menos lento o carregamento de imagens do chatbox.

https://www.npmjs.com/package/jimp
Expand Down
3 changes: 2 additions & 1 deletion src/app/atoms/iframe/Iframe.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import React, { useEffect, useRef } from 'react';
import PropTypes from 'prop-types';
import { objType } from 'for-promise/utils/lib.mjs';
import initMatrix from '@src/client/initMatrix';
import MxcUrl from '@src/util/libs/MxcUrl';

export const postMessage = (current, msg = null) => current.contentWindow.postMessage(msg);

Expand All @@ -27,7 +28,7 @@ const Iframe = React.forwardRef(
ref,
) => {
const iframeRef = ref || useRef(null);
const url = initMatrix.mxcUrl.getNewUrl(src);
const url = initMatrix.mxcUrl ? initMatrix.mxcUrl.getNewUrl(src) : MxcUrl.getNewUrl(src);

useEffect(() => {
if (iframeRef.current && onMessage) {
Expand Down
5 changes: 3 additions & 2 deletions src/app/atoms/image/Image.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import React, { useEffect, useRef } from 'react';
import PropTypes from 'prop-types';

import initMatrix from '@src/client/initMatrix';
import MxcUrl from '@src/util/libs/MxcUrl';

const Img = React.forwardRef(
(
Expand All @@ -23,7 +24,7 @@ const Img = React.forwardRef(
) => {
// Ref
const imgRef = ref || useRef(null);
const url = initMatrix.mxcUrl.getNewUrl(src);
const url = initMatrix.mxcUrl ? initMatrix.mxcUrl.getNewUrl(src) : MxcUrl.getNewUrl(src);

useEffect(() => {
if (imgRef.current) {
Expand Down Expand Up @@ -83,7 +84,7 @@ function ImgJquery({
onError = null,
dataMxEmoticon = null,
}) {
const url = initMatrix.mxcUrl.getNewUrl(src);
const url = initMatrix.mxcUrl ? initMatrix.mxcUrl.getNewUrl(src) : MxcUrl.getNewUrl(src);

const ops = {
'data-mx-emoticon': dataMxEmoticon,
Expand Down
4 changes: 2 additions & 2 deletions src/util/libs/MxcUrl.js
Original file line number Diff line number Diff line change
Expand Up @@ -81,12 +81,12 @@ class MxcUrl {
}

// Get Url
getNewUrl(src) {
static getNewUrl(src) {
let url = null;
try {
url =
typeof src === 'string'
? src.startsWith('mxc://')
? src.startsWith('mxc://') && this.toHttp
? this.toHttp(src)
: src.startsWith('./')
? `${location.origin}${location.pathname}${location.pathname.endsWith('/') ? src.substring(2) : src.substring(1)}`
Expand Down

0 comments on commit ccfa871

Please sign in to comment.