[REGRESSION] Avatars doesn't show up on older servers (< 3.6.0) (#2603)

* [REGRESSION] Avatars doesn't show up on older servers (< 3.6.0)

* fix: snapshots tests failing

Co-authored-by: Diego Mello <diegolmello@gmail.com>
This commit is contained in:
Djorkaeff Alexandre 2020-11-03 14:33:03 -03:00 committed by GitHub
parent 9ecb04e8ad
commit 702d36a625
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 1 deletions

View File

@ -1,12 +1,19 @@
import semver from 'semver';
import reduxStore from '../lib/createStore';
const formatUrl = (url, size, query) => `${ url }?format=png&size=${ size }${ query }`; const formatUrl = (url, size, query) => `${ url }?format=png&size=${ size }${ query }`;
export const avatarURL = ({ export const avatarURL = ({
type, text, size, user = {}, avatar, server, avatarETag, rid, blockUnauthenticatedAccess type, text, size, user = {}, avatar, server, avatarETag, rid, blockUnauthenticatedAccess
}) => { }) => {
const { version: serverVersion } = reduxStore.getState().server;
const isLegacy = serverVersion && semver.lt(semver.coerce(serverVersion), '3.6.0');
let room; let room;
if (type === 'd') { if (type === 'd') {
room = text; room = text;
} else if (rid) { } else if (rid && !isLegacy) {
room = `room/${ rid }`; room = `room/${ rid }`;
} else { } else {
room = `@${ text }`; room = `@${ text }`;

View File

@ -6,6 +6,8 @@ import 'react-native-gesture-handler';
// eslint-disable-next-line no-undef // eslint-disable-next-line no-undef
jest.mock('../app/lib/database', () => jest.fn(() => null)); // comment this line to make storybook work jest.mock('../app/lib/database', () => jest.fn(() => null)); // comment this line to make storybook work
// eslint-disable-next-line no-undef
jest.mock('../app/lib/createStore', () => ({ getState: () => ({ server: {} }) })); // comment this line to make storybook work
RNBootSplash.hide(); RNBootSplash.hide();