From 702d36a625af52c5830e00761daf05189b65a5bd Mon Sep 17 00:00:00 2001 From: Djorkaeff Alexandre Date: Tue, 3 Nov 2020 14:33:03 -0300 Subject: [PATCH] [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 --- app/utils/avatar.js | 9 ++++++++- storybook/index.js | 2 ++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/app/utils/avatar.js b/app/utils/avatar.js index b3ef7e41..54ad2238 100644 --- a/app/utils/avatar.js +++ b/app/utils/avatar.js @@ -1,12 +1,19 @@ +import semver from 'semver'; + +import reduxStore from '../lib/createStore'; + const formatUrl = (url, size, query) => `${ url }?format=png&size=${ size }${ query }`; export const avatarURL = ({ 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; if (type === 'd') { room = text; - } else if (rid) { + } else if (rid && !isLegacy) { room = `room/${ rid }`; } else { room = `@${ text }`; diff --git a/storybook/index.js b/storybook/index.js index 8e12a5a9..99b30178 100644 --- a/storybook/index.js +++ b/storybook/index.js @@ -6,6 +6,8 @@ import 'react-native-gesture-handler'; // eslint-disable-next-line no-undef 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();