diff --git a/app/components/loading_placeholder/__snapshots__/loading_placeholder.test.js.snap b/app/components/loading_placeholder/__snapshots__/loading_placeholder.test.js.snap deleted file mode 100644 index f387312c0..000000000 --- a/app/components/loading_placeholder/__snapshots__/loading_placeholder.test.js.snap +++ /dev/null @@ -1,153 +0,0 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP - -exports[`LoadingPlaceholder should match snapshot 1`] = ` -ShallowWrapper { - "length": 1, - Symbol(enzyme.__root__): [Circular], - Symbol(enzyme.__unrendered__): , - Symbol(enzyme.__renderer__): Object { - "batchedUpdates": [Function], - "getNode": [Function], - "render": [Function], - "simulateEvent": [Function], - "unmount": [Function], - }, - Symbol(enzyme.__node__): Object { - "instance": null, - "key": undefined, - "nodeType": "class", - "props": Object { - "accessible": true, - "allowFontScaling": true, - "children": Array [ - , - , - ], - "ellipsizeMode": "tail", - }, - "ref": null, - "rendered": Array [ - Object { - "instance": null, - "key": undefined, - "nodeType": "class", - "props": Object { - "defaultMessage": "Loading", - "id": "loading_screen.loading", - }, - "ref": null, - "rendered": null, - "type": [Function], - }, - Object { - "instance": null, - "key": undefined, - "nodeType": "class", - "props": Object { - "animationDelay": 300, - "minOpacity": 0.4, - "numberOfDots": 3, - "style": Object { - "fontSize": 28, - "letterSpacing": -3, - "lineHeight": 30, - "marginLeft": 5, - }, - }, - "ref": null, - "rendered": null, - "type": [Function], - }, - ], - "type": [Function], - }, - Symbol(enzyme.__nodes__): Array [ - Object { - "instance": null, - "key": undefined, - "nodeType": "class", - "props": Object { - "accessible": true, - "allowFontScaling": true, - "children": Array [ - , - , - ], - "ellipsizeMode": "tail", - }, - "ref": null, - "rendered": Array [ - Object { - "instance": null, - "key": undefined, - "nodeType": "class", - "props": Object { - "defaultMessage": "Loading", - "id": "loading_screen.loading", - }, - "ref": null, - "rendered": null, - "type": [Function], - }, - Object { - "instance": null, - "key": undefined, - "nodeType": "class", - "props": Object { - "animationDelay": 300, - "minOpacity": 0.4, - "numberOfDots": 3, - "style": Object { - "fontSize": 28, - "letterSpacing": -3, - "lineHeight": 30, - "marginLeft": 5, - }, - }, - "ref": null, - "rendered": null, - "type": [Function], - }, - ], - "type": [Function], - }, - ], - Symbol(enzyme.__options__): Object { - "adapter": ReactSixteenAdapter { - "options": Object { - "enableComponentDidUpdateOnSetState": true, - }, - }, - }, -} -`; diff --git a/app/components/loading_placeholder/index.js b/app/components/loading_placeholder/index.js deleted file mode 100644 index e2dc72fb9..000000000 --- a/app/components/loading_placeholder/index.js +++ /dev/null @@ -1,28 +0,0 @@ -// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved. -// See LICENSE.txt for license information. - -import React from 'react'; -import AnimatedEllipsis from 'react-native-animated-ellipsis'; -import FormattedText from 'app/components/formatted_text'; - -import {Text} from 'react-native'; - -const LoadingPlaceholder = () => ( - - - - -); - -export default LoadingPlaceholder; diff --git a/app/components/loading_placeholder/loading_placeholder.test.js b/app/components/loading_placeholder/loading_placeholder.test.js deleted file mode 100644 index 96293f111..000000000 --- a/app/components/loading_placeholder/loading_placeholder.test.js +++ /dev/null @@ -1,19 +0,0 @@ -// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved. -// See LICENSE.txt for license information. - -import React from 'react'; -import {configure, shallow} from 'enzyme'; -import Adapter from 'enzyme-adapter-react-16'; -configure({adapter: new Adapter()}); - -import LoadingPlaceholder from './index.js'; - -describe('LoadingPlaceholder', () => { - test('should match snapshot', () => { - const wrapper = shallow( - - ); - - expect(wrapper).toMatchSnapshot(); - }); -}); diff --git a/app/components/sidebars/main/channels_list/channel_item/__snapshots__/channel_item.test.js.snap b/app/components/sidebars/main/channels_list/channel_item/__snapshots__/channel_item.test.js.snap index cba55a39a..0fcd3bb59 100644 --- a/app/components/sidebars/main/channels_list/channel_item/__snapshots__/channel_item.test.js.snap +++ b/app/components/sidebars/main/channels_list/channel_item/__snapshots__/channel_item.test.js.snap @@ -121,9 +121,7 @@ ShallowWrapper { }, ] } - > - - + /> , @@ -202,9 +200,7 @@ ShallowWrapper { }, ] } - > - - + /> , "delayPressOut": 100, @@ -275,9 +271,7 @@ ShallowWrapper { }, ] } - > - - + /> , ], "style": Array [ @@ -340,9 +334,7 @@ ShallowWrapper { }, ] } - > - - , + />, undefined, ], "style": Array [ @@ -390,7 +382,7 @@ ShallowWrapper { "props": Object { "accessible": true, "allowFontScaling": true, - "children": , + "children": undefined, "ellipsizeMode": "tail", "numberOfLines": 1, "style": Array [ @@ -410,15 +402,7 @@ ShallowWrapper { ], }, "ref": null, - "rendered": Object { - "instance": null, - "key": undefined, - "nodeType": "function", - "props": Object {}, - "ref": null, - "rendered": null, - "type": [Function], - }, + "rendered": null, "type": [Function], }, undefined, @@ -512,9 +496,7 @@ ShallowWrapper { }, ] } - > - - + /> , @@ -593,9 +575,7 @@ ShallowWrapper { }, ] } - > - - + /> , "delayPressOut": 100, @@ -666,9 +646,7 @@ ShallowWrapper { }, ] } - > - - + /> , ], "style": Array [ @@ -731,9 +709,7 @@ ShallowWrapper { }, ] } - > - - , + />, undefined, ], "style": Array [ @@ -781,7 +757,7 @@ ShallowWrapper { "props": Object { "accessible": true, "allowFontScaling": true, - "children": , + "children": undefined, "ellipsizeMode": "tail", "numberOfLines": 1, "style": Array [ @@ -801,15 +777,7 @@ ShallowWrapper { ], }, "ref": null, - "rendered": Object { - "instance": null, - "key": undefined, - "nodeType": "function", - "props": Object {}, - "ref": null, - "rendered": null, - "type": [Function], - }, + "rendered": null, "type": [Function], }, undefined, @@ -850,854 +818,3 @@ ShallowWrapper { }, } `; - -exports[`ChannelItem should match snapshot for no displayName 1`] = ` -ShallowWrapper { - "length": 1, - Symbol(enzyme.__root__): [Circular], - Symbol(enzyme.__unrendered__): , - Symbol(enzyme.__renderer__): Object { - "batchedUpdates": [Function], - "getNode": [Function], - "render": [Function], - "simulateEvent": [Function], - "unmount": [Function], - }, - Symbol(enzyme.__node__): Object { - "instance": null, - "key": undefined, - "nodeType": "class", - "props": Object { - "children": - - - - - - - - - , - }, - "ref": [Function], - "rendered": Object { - "instance": null, - "key": undefined, - "nodeType": "class", - "props": Object { - "activeOpacity": 0.85, - "children": - - - - - - - , - "delayPressOut": 100, - "onLongPress": [Function], - "onPress": [Function], - "underlayColor": "rgba(170,170,170,0.5)", - }, - "ref": null, - "rendered": Object { - "instance": null, - "key": undefined, - "nodeType": "class", - "props": Object { - "children": Array [ - undefined, - - - - - - , - ], - "style": Array [ - Object { - "flex": 1, - "flexDirection": "row", - "height": 44, - }, - undefined, - ], - }, - "ref": null, - "rendered": Array [ - undefined, - Object { - "instance": null, - "key": undefined, - "nodeType": "class", - "props": Object { - "children": Array [ - , - - - , - undefined, - ], - "style": Array [ - Object { - "alignItems": "center", - "flex": 1, - "flexDirection": "row", - "paddingLeft": 16, - }, - undefined, - ], - }, - "ref": null, - "rendered": Array [ - Object { - "instance": null, - "key": undefined, - "nodeType": "class", - "props": Object { - "channelId": "channel_id", - "isActive": false, - "isArchived": false, - "isInfo": false, - "isUnread": true, - "membersCount": 1, - "size": 16, - "status": "online", - "teammateDeletedAt": 0, - "theme": Object { - "sidebarText": "#aaa", - "sidebarTextActiveBorder": "#aaa", - "sidebarTextActiveColor": "#aaa", - "sidebarTextHoverBg": "#aaa", - }, - "type": "O", - }, - "ref": null, - "rendered": null, - "type": [Function], - }, - Object { - "instance": null, - "key": undefined, - "nodeType": "class", - "props": Object { - "accessible": true, - "allowFontScaling": true, - "children": , - "ellipsizeMode": "tail", - "numberOfLines": 1, - "style": Array [ - Object { - "color": "rgba(170,170,170,0.4)", - "flex": 1, - "fontSize": 14, - "fontWeight": "600", - "height": "100%", - "lineHeight": 44, - "paddingRight": 40, - "textAlignVertical": "center", - }, - Object { - "color": undefined, - }, - ], - }, - "ref": null, - "rendered": Object { - "instance": null, - "key": undefined, - "nodeType": "function", - "props": Object {}, - "ref": null, - "rendered": null, - "type": [Function], - }, - "type": [Function], - }, - undefined, - ], - "type": [Function], - }, - ], - "type": [Function], - }, - "type": [Function], - }, - "type": [Function], - }, - Symbol(enzyme.__nodes__): Array [ - Object { - "instance": null, - "key": undefined, - "nodeType": "class", - "props": Object { - "children": - - - - - - - - - , - }, - "ref": [Function], - "rendered": Object { - "instance": null, - "key": undefined, - "nodeType": "class", - "props": Object { - "activeOpacity": 0.85, - "children": - - - - - - - , - "delayPressOut": 100, - "onLongPress": [Function], - "onPress": [Function], - "underlayColor": "rgba(170,170,170,0.5)", - }, - "ref": null, - "rendered": Object { - "instance": null, - "key": undefined, - "nodeType": "class", - "props": Object { - "children": Array [ - undefined, - - - - - - , - ], - "style": Array [ - Object { - "flex": 1, - "flexDirection": "row", - "height": 44, - }, - undefined, - ], - }, - "ref": null, - "rendered": Array [ - undefined, - Object { - "instance": null, - "key": undefined, - "nodeType": "class", - "props": Object { - "children": Array [ - , - - - , - undefined, - ], - "style": Array [ - Object { - "alignItems": "center", - "flex": 1, - "flexDirection": "row", - "paddingLeft": 16, - }, - undefined, - ], - }, - "ref": null, - "rendered": Array [ - Object { - "instance": null, - "key": undefined, - "nodeType": "class", - "props": Object { - "channelId": "channel_id", - "isActive": false, - "isArchived": false, - "isInfo": false, - "isUnread": true, - "membersCount": 1, - "size": 16, - "status": "online", - "teammateDeletedAt": 0, - "theme": Object { - "sidebarText": "#aaa", - "sidebarTextActiveBorder": "#aaa", - "sidebarTextActiveColor": "#aaa", - "sidebarTextHoverBg": "#aaa", - }, - "type": "O", - }, - "ref": null, - "rendered": null, - "type": [Function], - }, - Object { - "instance": null, - "key": undefined, - "nodeType": "class", - "props": Object { - "accessible": true, - "allowFontScaling": true, - "children": , - "ellipsizeMode": "tail", - "numberOfLines": 1, - "style": Array [ - Object { - "color": "rgba(170,170,170,0.4)", - "flex": 1, - "fontSize": 14, - "fontWeight": "600", - "height": "100%", - "lineHeight": 44, - "paddingRight": 40, - "textAlignVertical": "center", - }, - Object { - "color": undefined, - }, - ], - }, - "ref": null, - "rendered": Object { - "instance": null, - "key": undefined, - "nodeType": "function", - "props": Object {}, - "ref": null, - "rendered": null, - "type": [Function], - }, - "type": [Function], - }, - undefined, - ], - "type": [Function], - }, - ], - "type": [Function], - }, - "type": [Function], - }, - "type": [Function], - }, - ], - Symbol(enzyme.__options__): Object { - "adapter": ReactSixteenAdapter { - "options": Object { - "enableComponentDidUpdateOnSetState": true, - }, - }, - "context": Object { - "intl": Object { - "formatMessage": [MockFunction] { - "calls": Array [ - Array [ - Object { - "defaultMessage": "{displayName} (you)", - "id": "channel_header.directchannel.you", - }, - Object { - "displayname": "", - }, - ], - ], - }, - }, - }, - }, -} -`; diff --git a/app/components/sidebars/main/channels_list/channel_item/channel_item.js b/app/components/sidebars/main/channels_list/channel_item/channel_item.js index cce3eca36..64ca77380 100644 --- a/app/components/sidebars/main/channels_list/channel_item/channel_item.js +++ b/app/components/sidebars/main/channels_list/channel_item/channel_item.js @@ -14,7 +14,6 @@ import {intlShape} from 'react-intl'; import Badge from 'app/components/badge'; import ChannelIcon from 'app/components/channel_icon'; -import LoadingPlaceholder from 'app/components/loading_placeholder'; import {preventDoubleTap} from 'app/utils/tap'; import {changeOpacity, makeStyleSheetFromTheme} from 'app/utils/theme'; @@ -112,8 +111,20 @@ export default class ChannelItem extends PureComponent { return null; } + if (!this.props.displayName) { + return null; + } + const {intl} = this.context; + let channelDisplayName = displayName; + if (isMyUser) { + channelDisplayName = intl.formatMessage({ + id: 'channel_header.directchannel.you', + defaultMessage: '{displayName} (you)', + }, {displayname: displayName}); + } + const style = getStyleSheet(theme); const isActive = channelId === currentChannelId; @@ -133,20 +144,6 @@ export default class ChannelItem extends PureComponent { extraTextStyle = style.textUnread; } - let channelDisplayName = displayName; - if (isMyUser) { - channelDisplayName = intl.formatMessage({ - id: 'channel_header.directchannel.you', - defaultMessage: '{displayName} (you)', - }, {displayname: displayName}); - } - - if (!channelDisplayName) { - channelDisplayName = ( - - ); - } - let badge; if (mentions) { badge = ( diff --git a/app/components/sidebars/main/channels_list/channel_item/channel_item.test.js b/app/components/sidebars/main/channels_list/channel_item/channel_item.test.js index 7f4bd614f..3ce307c00 100644 --- a/app/components/sidebars/main/channels_list/channel_item/channel_item.test.js +++ b/app/components/sidebars/main/channels_list/channel_item/channel_item.test.js @@ -45,18 +45,4 @@ describe('ChannelItem', () => { expect(wrapper).toMatchSnapshot(); }); - - test('should match snapshot for no displayName', () => { - const props = { - ...baseProps, - displayName: '', - }; - - const wrapper = shallow( - , - {context: {intl: {formatMessage: jest.fn()}}}, - ); - - expect(wrapper).toMatchSnapshot(); - }); }); diff --git a/package-lock.json b/package-lock.json index 438e4511f..c44ff0ad8 100644 --- a/package-lock.json +++ b/package-lock.json @@ -14641,13 +14641,6 @@ "prop-types": "^15.5.10" } }, - "react-native-animated-ellipsis": { - "version": "github:sudheerDev/react-native-animated-ellipsis#326167b8e0fa3b6f0422c06be412bf177b725666", - "from": "github:sudheerDev/react-native-animated-ellipsis#326167b8e0fa3b6f0422c06be412bf177b725666", - "requires": { - "prop-types": "^15.5.10" - } - }, "react-native-bottom-sheet": { "version": "1.0.3", "resolved": "https://registry.npmjs.org/react-native-bottom-sheet/-/react-native-bottom-sheet-1.0.3.tgz", diff --git a/package.json b/package.json index fd74ca14a..196c317a3 100644 --- a/package.json +++ b/package.json @@ -22,7 +22,6 @@ "react-intl": "2.4.0", "react-native": "github:enahum/react-native#mm", "react-native-animatable": "1.2.4", - "react-native-animated-ellipsis": "sudheerDev/react-native-animated-ellipsis.git#326167b8e0fa3b6f0422c06be412bf177b725666", "react-native-bottom-sheet": "1.0.3", "react-native-button": "2.3.0", "react-native-circular-progress": "0.2.0",