[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:
parent
9ecb04e8ad
commit
702d36a625
|
@ -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 }`;
|
||||||
|
|
|
@ -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();
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue