From 1c347f25d21ff6cfdcf48c470fb04cd95eec4217 Mon Sep 17 00:00:00 2001 From: Youssef Muhamad Date: Mon, 2 Mar 2020 16:25:02 -0300 Subject: [PATCH 01/10] Improve styling to follow rc server --- app/views/RoomInfoEditView/SwitchContainer.js | 4 ++-- app/views/RoomInfoEditView/styles.js | 9 ++++----- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/app/views/RoomInfoEditView/SwitchContainer.js b/app/views/RoomInfoEditView/SwitchContainer.js index 5b877552da6..1aff46622c8 100644 --- a/app/views/RoomInfoEditView/SwitchContainer.js +++ b/app/views/RoomInfoEditView/SwitchContainer.js @@ -26,8 +26,8 @@ export default class SwitchContainer extends React.PureComponent { [ - {leftLabelPrimary} - {leftLabelSecondary} + {leftLabelPrimary} + {leftLabelSecondary} Date: Mon, 2 Mar 2020 22:06:53 -0300 Subject: [PATCH 02/10] Update SwitchContainer to handle a single label layout --- app/views/RoomInfoEditView/SwitchContainer.js | 19 +++++++++++-------- app/views/RoomInfoEditView/index.js | 14 ++++++++++++-- app/views/RoomInfoEditView/styles.js | 1 - 3 files changed, 23 insertions(+), 11 deletions(-) diff --git a/app/views/RoomInfoEditView/SwitchContainer.js b/app/views/RoomInfoEditView/SwitchContainer.js index 1aff46622c8..86cacb90515 100644 --- a/app/views/RoomInfoEditView/SwitchContainer.js +++ b/app/views/RoomInfoEditView/SwitchContainer.js @@ -15,19 +15,20 @@ export default class SwitchContainer extends React.PureComponent { rightLabelSecondary: PropTypes.string, onValueChange: PropTypes.func, theme: PropTypes.string, - testID: PropTypes.string + testID: PropTypes.string, + hasSingleLabel: PropTypes.bool } render() { const { - value, disabled, onValueChange, leftLabelPrimary, leftLabelSecondary, rightLabelPrimary, rightLabelSecondary, theme, testID + value, disabled, onValueChange, leftLabelPrimary, leftLabelSecondary, rightLabelPrimary, rightLabelSecondary, theme, testID, hasSingleLabel } = this.props; return ( [ - {leftLabelPrimary} - {leftLabelSecondary} + {leftLabelPrimary} + {leftLabelSecondary} - - {rightLabelPrimary} - {rightLabelSecondary} - + {!hasSingleLabel ? ( + + {rightLabelPrimary} + {rightLabelSecondary} + + ) : null} , ] diff --git a/app/views/RoomInfoEditView/index.js b/app/views/RoomInfoEditView/index.js index 2eab199ce7f..1272cfcf5cd 100644 --- a/app/views/RoomInfoEditView/index.js +++ b/app/views/RoomInfoEditView/index.js @@ -70,7 +70,8 @@ class RoomInfoEditView extends React.Component { t: false, ro: false, reactWhenReadOnly: false, - archived: false + archived: false, + systemMessages: false }; this.loadRoom(); } @@ -300,7 +301,7 @@ class RoomInfoEditView extends React.Component { render() { const { - name, nameError, description, topic, announcement, t, ro, reactWhenReadOnly, room, joinCode, saving, permissions, archived + name, nameError, description, topic, announcement, t, ro, reactWhenReadOnly, room, joinCode, saving, permissions, archived, systemMessages } = this.state; const { theme } = this.props; const { dangerColor } = themes[theme]; @@ -408,6 +409,15 @@ class RoomInfoEditView extends React.Component { ] : null } + this.setState({ systemMessages: value })} + /> Date: Tue, 3 Mar 2020 15:05:56 -0300 Subject: [PATCH 03/10] Multiselect to hide system messages --- app/containers/UIKit/MultiSelect/index.js | 6 ++ app/i18n/locales/en.js | 17 +++++ app/lib/database/model/Subscription.js | 2 + app/lib/database/model/migrations.js | 11 ++++ app/lib/database/schema/app.js | 5 +- .../helpers/mergeSubscriptionsRooms.js | 1 + app/utils/messageTypes.js | 42 +++++++++++++ app/views/RoomInfoEditView/SwitchContainer.js | 29 +++++---- app/views/RoomInfoEditView/index.js | 62 +++++++++++++++---- app/views/RoomInfoEditView/styles.js | 17 ++++- app/views/RoomView/List.js | 19 +++++- app/views/RoomView/index.js | 6 +- 12 files changed, 184 insertions(+), 33 deletions(-) create mode 100644 app/utils/messageTypes.js diff --git a/app/containers/UIKit/MultiSelect/index.js b/app/containers/UIKit/MultiSelect/index.js index 47e6141b4a0..553e92c61de 100644 --- a/app/containers/UIKit/MultiSelect/index.js +++ b/app/containers/UIKit/MultiSelect/index.js @@ -41,6 +41,12 @@ export const MultiSelect = React.memo(({ const [currentValue, setCurrentValue] = useState(''); const [showContent, setShowContent] = useState(false); + useEffect(() => { + if (values) { + select(values); + } + }, [values]); + useEffect(() => { setOpen(showContent); }, [showContent]); diff --git a/app/i18n/locales/en.js b/app/i18n/locales/en.js index f6a643d1bda..35ff3752a71 100644 --- a/app/i18n/locales/en.js +++ b/app/i18n/locales/en.js @@ -210,6 +210,21 @@ export default { Has_joined_the_channel: 'Has joined the channel', Has_joined_the_conversation: 'Has joined the conversation', Has_left_the_channel: 'Has left the channel', + Hide_System_Messages: 'Hide System Messages', + Hide_type_messages: 'Hide "{{type}}" messages', + Message_HideType_uj: 'User Join', + Message_HideType_ul: 'User Leave', + Message_HideType_ru: 'User Removed', + Message_HideType_au: 'User Added', + Message_HideType_mute_unmute: 'User Muted / Unmuted', + Message_HideType_r: 'Room Name Changed', + Message_HideType_ut: 'User Joined Conversation', + Message_HideType_wm: 'Welcome', + Message_HideType_rm: 'Message Removed', + Message_HideType_subscription_role_added: 'Was Set Role', + Message_HideType_subscription_role_removed: 'Role No Longer Defined', + Message_HideType_room_archived: 'Room Archived', + Message_HideType_room_unarchived: 'Room Unarchived', In_app: 'In-app', IN_APP_AND_DESKTOP: 'IN-APP AND DESKTOP', In_App_and_Desktop_Alert_info: 'Displays a banner at the top of the screen when app is open, and displays a notification on desktop', @@ -297,6 +312,7 @@ export default { Only_authorized_users_can_write_new_messages: 'Only authorized users can write new messages', Open_emoji_selector: 'Open emoji selector', Open_Source_Communication: 'Open Source Communication', + Overwrites_the_server_configuration_and_use_room_config: 'Overwrites the server configuration and use room config', Password: 'Password', Permalink_copied_to_clipboard: 'Permalink copied to clipboard!', Pin: 'Pin', @@ -456,6 +472,7 @@ export default { Username_is_empty: 'Username is empty', Username: 'Username', Username_or_email: 'Username or email', + Uses_server_configuration: 'Uses server configuration', Validating: 'Validating', Verify_email_title: 'Registration Succeeded!', Verify_email_desc: 'We have sent you an email to confirm your registration. If you do not receive an email shortly, please come back and try again.', diff --git a/app/lib/database/model/Subscription.js b/app/lib/database/model/Subscription.js index 630c640b31c..d40193c5252 100644 --- a/app/lib/database/model/Subscription.js +++ b/app/lib/database/model/Subscription.js @@ -89,4 +89,6 @@ export default class Subscription extends Model { @children('thread_messages') threadMessages; @field('hide_unread_status') hideUnreadStatus; + + @json('sys_mes', sanitizer) sysMes; } diff --git a/app/lib/database/model/migrations.js b/app/lib/database/model/migrations.js index ced859bda76..14313585e19 100644 --- a/app/lib/database/model/migrations.js +++ b/app/lib/database/model/migrations.js @@ -51,6 +51,17 @@ export default schemaMigrations({ ] }) ] + }, + { + toVersion: 6, + steps: [ + addColumns({ + table: 'subscriptions', + columns: [ + { name: 'sys_mes', type: 'string', isOptional: true } + ] + }) + ] } ] }); diff --git a/app/lib/database/schema/app.js b/app/lib/database/schema/app.js index de98df29b9c..20741b573b3 100644 --- a/app/lib/database/schema/app.js +++ b/app/lib/database/schema/app.js @@ -1,7 +1,7 @@ import { appSchema, tableSchema } from '@nozbe/watermelondb'; export default appSchema({ - version: 5, + version: 6, tables: [ tableSchema({ name: 'subscriptions', @@ -39,7 +39,8 @@ export default appSchema({ { name: 'jitsi_timeout', type: 'number', isOptional: true }, { name: 'auto_translate', type: 'boolean', isOptional: true }, { name: 'auto_translate_language', type: 'string' }, - { name: 'hide_unread_status', type: 'boolean', isOptional: true } + { name: 'hide_unread_status', type: 'boolean', isOptional: true }, + { name: 'sys_mes', type: 'string', isOptional: true } ] }), tableSchema({ diff --git a/app/lib/methods/helpers/mergeSubscriptionsRooms.js b/app/lib/methods/helpers/mergeSubscriptionsRooms.js index 02a7a6612f6..6af040f5b1b 100644 --- a/app/lib/methods/helpers/mergeSubscriptionsRooms.js +++ b/app/lib/methods/helpers/mergeSubscriptionsRooms.js @@ -32,6 +32,7 @@ export const merge = (subscription, room) => { } else { subscription.muted = []; } + subscription.sysMes = room.sysMes; } if (!subscription.name) { diff --git a/app/utils/messageTypes.js b/app/utils/messageTypes.js new file mode 100644 index 00000000000..f874a437a84 --- /dev/null +++ b/app/utils/messageTypes.js @@ -0,0 +1,42 @@ +export const MessageTypeValues = [ + { + value: 'uj', + text: 'Message_HideType_uj' + }, { + value: 'ul', + text: 'Message_HideType_ul' + }, { + value: 'ru', + text: 'Message_HideType_ru' + }, { + value: 'au', + text: 'Message_HideType_au' + }, { + value: 'mute_unmute', + text: 'Message_HideType_mute_unmute' + }, { + value: 'r', + text: 'Message_HideType_r' + }, { + value: 'ut', + text: 'Message_HideType_ut' + }, { + value: 'wm', + text: 'Message_HideType_wm' + }, { + value: 'rm', + text: 'Message_HideType_rm' + }, { + value: 'subscription_role_added', + text: 'Message_HideType_subscription_role_added' + }, { + value: 'subscription_role_removed', + text: 'Message_HideType_subscription_role_removed' + }, { + value: 'room_archived', + text: 'Message_HideType_room_archived' + }, { + value: 'room_unarchived', + text: 'Message_HideType_room_unarchived' + } +]; diff --git a/app/views/RoomInfoEditView/SwitchContainer.js b/app/views/RoomInfoEditView/SwitchContainer.js index 86cacb90515..35f4a3c02eb 100644 --- a/app/views/RoomInfoEditView/SwitchContainer.js +++ b/app/views/RoomInfoEditView/SwitchContainer.js @@ -16,20 +16,24 @@ export default class SwitchContainer extends React.PureComponent { onValueChange: PropTypes.func, theme: PropTypes.string, testID: PropTypes.string, - hasSingleLabel: PropTypes.bool + labelContainerStyle: PropTypes.object, + leftLabelStyle: PropTypes.object, + children: PropTypes.any } render() { const { - value, disabled, onValueChange, leftLabelPrimary, leftLabelSecondary, rightLabelPrimary, rightLabelSecondary, theme, testID, hasSingleLabel + children, value, disabled, onValueChange, leftLabelPrimary, leftLabelSecondary, rightLabelPrimary, rightLabelSecondary, theme, testID, labelContainerStyle, leftLabelStyle } = this.props; return ( [ - - - {leftLabelPrimary} - {leftLabelSecondary} - + + {leftLabelPrimary && ( + + {leftLabelPrimary} + {leftLabelSecondary} + + )} - {!hasSingleLabel ? ( - - {rightLabelPrimary} - {rightLabelSecondary} + {rightLabelPrimary && ( + + {rightLabelPrimary} + {rightLabelSecondary} - ) : null} + )} , + children, ] ); diff --git a/app/views/RoomInfoEditView/index.js b/app/views/RoomInfoEditView/index.js index 1272cfcf5cd..9831793cb2a 100644 --- a/app/views/RoomInfoEditView/index.js +++ b/app/views/RoomInfoEditView/index.js @@ -6,6 +6,8 @@ import { import { connect } from 'react-redux'; import { SafeAreaView } from 'react-navigation'; import equal from 'deep-equal'; +import { BLOCK_CONTEXT } from '@rocket.chat/ui-kit'; +import isEqual from 'lodash/isEqual'; import database from '../../lib/database'; import { eraseRoom as eraseRoomAction } from '../../actions/room'; @@ -27,6 +29,8 @@ import StatusBar from '../../containers/StatusBar'; import { themedHeader } from '../../utils/navigation'; import { themes } from '../../constants/colors'; import { withTheme } from '../../theme'; +import { MultiSelect } from '../../containers/UIKit/MultiSelect'; +import { MessageTypeValues } from '../../utils/messageTypes'; const PERMISSION_SET_READONLY = 'set-readonly'; const PERMISSION_SET_REACT_WHEN_READONLY = 'set-react-when-readonly'; @@ -71,7 +75,8 @@ class RoomInfoEditView extends React.Component { ro: false, reactWhenReadOnly: false, archived: false, - systemMessages: false + systemMessages: [], + enableSysMes: false }; this.loadRoom(); } @@ -118,7 +123,7 @@ class RoomInfoEditView extends React.Component { init = (room) => { const { - name, description, topic, announcement, t, ro, reactWhenReadOnly, joinCodeRequired + name, description, topic, announcement, t, ro, reactWhenReadOnly, joinCodeRequired, sysMes } = room; // fake password just to user knows about it this.randomValue = random(15); @@ -132,7 +137,9 @@ class RoomInfoEditView extends React.Component { ro, reactWhenReadOnly, joinCode: joinCodeRequired ? this.randomValue : '', - archived: room.archived + archived: room.archived, + systemMessages: sysMes, + enableSysMes: sysMes.length > 0 }); } @@ -149,7 +156,7 @@ class RoomInfoEditView extends React.Component { formIsChanged = () => { const { - room, name, description, topic, announcement, t, ro, reactWhenReadOnly, joinCode + room, name, description, topic, announcement, t, ro, reactWhenReadOnly, joinCode, systemMessages, enableSysMes } = this.state; const { joinCodeRequired } = room; return !(room.name === name @@ -160,13 +167,15 @@ class RoomInfoEditView extends React.Component { && room.t === 'p' === t && room.ro === ro && room.reactWhenReadOnly === reactWhenReadOnly + && isEqual(room.sysMes, systemMessages) + && enableSysMes === (room.sysMes.length > 0) ); } submit = async() => { Keyboard.dismiss(); const { - room, name, description, topic, announcement, t, ro, reactWhenReadOnly, joinCode + room, name, description, topic, announcement, t, ro, reactWhenReadOnly, joinCode, systemMessages } = this.state; this.setState({ saving: true }); @@ -211,6 +220,10 @@ class RoomInfoEditView extends React.Component { params.reactWhenReadOnly = reactWhenReadOnly; } + if (!isEqual(room.sysMes, systemMessages)) { + params.systemMessages = systemMessages; + } + // Join Code if (this.randomValue !== joinCode) { params.joinCode = joinCode; @@ -299,12 +312,34 @@ class RoomInfoEditView extends React.Component { return (permissions[PERMISSION_ARCHIVE] || permissions[PERMISSION_UNARCHIVE]); }; + renderSystemMessages = () => { + const { systemMessages, enableSysMes } = this.state; + const { theme } = this.props; + + if (!enableSysMes) { + return null; + } + + return ( + ({ value: m.value, text: { text: I18n.t('Hide_type_messages', { type: I18n.t(m.text) }) } }))} + onChange={({ value }) => this.setState({ systemMessages: value })} + placeholder={{ text: I18n.t('Hide_System_Messages') }} + value={systemMessages} + context={BLOCK_CONTEXT.FORM} + multiselect + theme={theme} + /> + ); + } + render() { const { - name, nameError, description, topic, announcement, t, ro, reactWhenReadOnly, room, joinCode, saving, permissions, archived, systemMessages + name, nameError, description, topic, announcement, t, ro, reactWhenReadOnly, room, joinCode, saving, permissions, archived, enableSysMes } = this.state; const { theme } = this.props; const { dangerColor } = themes[theme]; + return ( this.setState({ systemMessages: value })} - /> + onValueChange={value => this.setState(({ systemMessages }) => ({ enableSysMes: value, systemMessages: value ? systemMessages : [] }))} + labelContainerStyle={styles.hideSystemMessages} + leftLabelStyle={styles.systemMessagesLabel} + > + {this.renderSystemMessages()} + { + this.unsubscribeMessages(); + this.init(); + } + // this.state.loading works for this.onEndReached and RoomView.init static getDerivedStateFromProps(props, state) { if (props.loading !== state.loading) { @@ -115,7 +122,7 @@ class List extends React.Component { shouldComponentUpdate(nextProps, nextState) { const { loading, end, refreshing } = this.state; - const { theme } = this.props; + const { hideSystemMessages, theme } = this.props; if (theme !== nextProps.theme) { return true; } @@ -128,9 +135,19 @@ class List extends React.Component { if (refreshing !== nextState.refreshing) { return true; } + if (!isEqual(hideSystemMessages, nextProps.hideSystemMessages)) { + return true; + } return false; } + componentDidUpdate(prevProps) { + const { hideSystemMessages } = this.props; + if (!isEqual(hideSystemMessages, prevProps.hideSystemMessages)) { + this.reload(); + } + } + componentWillUnmount() { this.unsubscribeMessages(); if (this.interaction && this.interaction.cancel) { diff --git a/app/views/RoomView/index.js b/app/views/RoomView/index.js index 39053591dd9..4d11d02b3bb 100644 --- a/app/views/RoomView/index.js +++ b/app/views/RoomView/index.js @@ -68,7 +68,7 @@ const stateAttrsUpdate = [ 'reacting', 'showAnnouncementModal' ]; -const roomAttrsUpdate = ['f', 'ro', 'blocked', 'blocker', 'archived', 'muted', 'jitsiTimeout', 'announcement']; +const roomAttrsUpdate = ['f', 'ro', 'blocked', 'blocker', 'archived', 'muted', 'jitsiTimeout', 'announcement', 'sysMes']; class RoomView extends React.Component { static navigationOptions = ({ navigation, screenProps }) => { @@ -950,7 +950,7 @@ class RoomView extends React.Component { const { user, baseUrl, theme, navigation, Hide_System_Messages } = this.props; - const { rid, t } = room; + const { rid, t, sysMes } = room; return ( {this.renderAnnouncementModal()} {this.renderFooter()} From c8d84974d0fd9b1edee9753141bd1e2f53d5100d Mon Sep 17 00:00:00 2001 From: Djorkaeff Alexandre Date: Wed, 4 Mar 2020 11:23:35 -0300 Subject: [PATCH 04/10] [FIX] Switch code --- app/views/RoomInfoEditView/SwitchContainer.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/app/views/RoomInfoEditView/SwitchContainer.js b/app/views/RoomInfoEditView/SwitchContainer.js index 35f4a3c02eb..69462365a3f 100644 --- a/app/views/RoomInfoEditView/SwitchContainer.js +++ b/app/views/RoomInfoEditView/SwitchContainer.js @@ -26,7 +26,7 @@ export default class SwitchContainer extends React.PureComponent { children, value, disabled, onValueChange, leftLabelPrimary, leftLabelSecondary, rightLabelPrimary, rightLabelSecondary, theme, testID, labelContainerStyle, leftLabelStyle } = this.props; return ( - [ + <> {leftLabelPrimary && ( @@ -48,10 +48,10 @@ export default class SwitchContainer extends React.PureComponent { {rightLabelSecondary} )} - , - children, + + {children} - ] + ); } } From 27ad83e0ebe287fea8a16e3e548c05970b16c00d Mon Sep 17 00:00:00 2001 From: Djorkaeff Alexandre Date: Wed, 4 Mar 2020 15:54:05 -0300 Subject: [PATCH 05/10] [IMPROVEMENT] MultiSelect style --- app/containers/UIKit/MultiSelect/Chips.js | 4 ++-- app/containers/UIKit/MultiSelect/styles.js | 1 + 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/app/containers/UIKit/MultiSelect/Chips.js b/app/containers/UIKit/MultiSelect/Chips.js index 330a04d8f38..3687801a69f 100644 --- a/app/containers/UIKit/MultiSelect/Chips.js +++ b/app/containers/UIKit/MultiSelect/Chips.js @@ -20,7 +20,7 @@ const Chip = ({ item, onSelect, theme }) => ( > <> {item.imageUrl ? : null} - {textParser([item.text])} + {textParser([item.text])} @@ -32,7 +32,7 @@ Chip.propTypes = { }; const Chips = ({ items, onSelect, theme }) => ( - + {items.map(item => )} ); diff --git a/app/containers/UIKit/MultiSelect/styles.js b/app/containers/UIKit/MultiSelect/styles.js index f0034364abb..1d5369fcf49 100644 --- a/app/containers/UIKit/MultiSelect/styles.js +++ b/app/containers/UIKit/MultiSelect/styles.js @@ -72,6 +72,7 @@ export default StyleSheet.create({ }, chipText: { paddingHorizontal: 8, + flexShrink: 1, ...sharedStyles.textMedium, fontSize: 14 }, From 0ce7653e99cca0b9672ec4d18df98b7e928f1299 Mon Sep 17 00:00:00 2001 From: Djorkaeff Alexandre Date: Wed, 4 Mar 2020 16:08:31 -0300 Subject: [PATCH 06/10] [I18n] Add PT-br --- app/containers/UIKit/MultiSelect/styles.js | 1 + app/i18n/locales/pt-BR.js | 17 +++++++++++++++++ 2 files changed, 18 insertions(+) diff --git a/app/containers/UIKit/MultiSelect/styles.js b/app/containers/UIKit/MultiSelect/styles.js index 1d5369fcf49..d5bcc881131 100644 --- a/app/containers/UIKit/MultiSelect/styles.js +++ b/app/containers/UIKit/MultiSelect/styles.js @@ -34,6 +34,7 @@ export default StyleSheet.create({ }, item: { height: 48, + maxWidth: '85%', alignItems: 'center', flexDirection: 'row' }, diff --git a/app/i18n/locales/pt-BR.js b/app/i18n/locales/pt-BR.js index 557ec7a120b..0a40664ee47 100644 --- a/app/i18n/locales/pt-BR.js +++ b/app/i18n/locales/pt-BR.js @@ -201,6 +201,21 @@ export default { Has_joined_the_channel: 'Entrou no canal', Has_joined_the_conversation: 'Entrou na conversa', Has_left_the_channel: 'Saiu da conversa', + Hide_System_Messages: 'Esconder mensagens do sistema', + Hide_type_messages: 'Esconder mensagens de "{{type}}"', + Message_HideType_uj: 'Utilizador Entrou', + Message_HideType_ul: 'Utilizador Saiu', + Message_HideType_ru: 'Utilizador Removido', + Message_HideType_au: 'Utilizador adicionado', + Message_HideType_mute_unmute: 'Utilizador Silenciado', + Message_HideType_r: 'Nome da sala alterado', + Message_HideType_ut: 'Utilizador adicionado ao bate-papo', + Message_HideType_wm: 'Bem Vindo', + Message_HideType_rm: 'Mensagem Removida', + Message_HideType_subscription_role_added: 'Papel atribuído', + Message_HideType_subscription_role_removed: 'Papel removido', + Message_HideType_room_archived: 'Sala arquivada', + Message_HideType_room_unarchived: 'Sala desarquivada', In_app: 'No app', Invisible: 'Invisível', Invite: 'Convidar', @@ -273,6 +288,7 @@ export default { Only_authorized_users_can_write_new_messages: 'Somente usuários autorizados podem escrever novas mensagens', Open_emoji_selector: 'Abrir seletor de emoji', Open_Source_Communication: 'Comunicação Open Source', + Overwrites_the_server_configuration_and_use_room_config: 'Substituir a configuração do servidor e usar a configuração da sala', Password: 'Senha', Permalink_copied_to_clipboard: 'Link-permanente copiado para a área de transferência!', Pin: 'Fixar', @@ -411,6 +427,7 @@ export default { Username_is_empty: 'Usuário está vazio', Username: 'Usuário', Username_or_email: 'Usuário ou email', + Uses_server_configuration: 'Usar configuração do servidor', Verify_email_title: 'Registrado com sucesso!', Verify_email_desc: 'Nós lhe enviamos um e-mail para confirmar o seu registro. Se você não receber um e-mail em breve, por favor retorne e tente novamente.', Video_call: 'Chamada de vídeo', From df9e4e86991282cd36b5681aed29549fdfd423ac Mon Sep 17 00:00:00 2001 From: Djorkaeff Alexandre Date: Wed, 4 Mar 2020 16:09:50 -0300 Subject: [PATCH 07/10] [FIX] Inline Style --- app/containers/UIKit/MultiSelect/Chips.js | 2 +- app/containers/UIKit/MultiSelect/styles.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/app/containers/UIKit/MultiSelect/Chips.js b/app/containers/UIKit/MultiSelect/Chips.js index 3687801a69f..dae9c797e2b 100644 --- a/app/containers/UIKit/MultiSelect/Chips.js +++ b/app/containers/UIKit/MultiSelect/Chips.js @@ -32,7 +32,7 @@ Chip.propTypes = { }; const Chips = ({ items, onSelect, theme }) => ( - + {items.map(item => )} ); diff --git a/app/containers/UIKit/MultiSelect/styles.js b/app/containers/UIKit/MultiSelect/styles.js index d5bcc881131..bac42a168a0 100644 --- a/app/containers/UIKit/MultiSelect/styles.js +++ b/app/containers/UIKit/MultiSelect/styles.js @@ -60,7 +60,7 @@ export default StyleSheet.create({ chips: { flexDirection: 'row', flexWrap: 'wrap', - marginRight: 16 + marginRight: 50 }, chip: { flexDirection: 'row', From 73ba135097d886316d475949f83827b74711deff Mon Sep 17 00:00:00 2001 From: Djorkaeff Alexandre Date: Wed, 4 Mar 2020 16:34:08 -0300 Subject: [PATCH 08/10] [FIX] Crash on Android --- app/views/RoomInfoEditView/index.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/views/RoomInfoEditView/index.js b/app/views/RoomInfoEditView/index.js index a9fbddd6e5d..d287fe0565b 100644 --- a/app/views/RoomInfoEditView/index.js +++ b/app/views/RoomInfoEditView/index.js @@ -139,7 +139,7 @@ class RoomInfoEditView extends React.Component { joinCode: joinCodeRequired ? this.randomValue : '', archived: room.archived, systemMessages: sysMes, - enableSysMes: sysMes.length > 0 + enableSysMes: sysMes && sysMes.length > 0 }); } @@ -168,7 +168,7 @@ class RoomInfoEditView extends React.Component { && room.ro === ro && room.reactWhenReadOnly === reactWhenReadOnly && isEqual(room.sysMes, systemMessages) - && enableSysMes === (room.sysMes.length > 0) + && enableSysMes === (room.sysMes && room.sysMes.length > 0) ); } From 65221fe3f5859d2ca60c7de6f3e57294f79e1306 Mon Sep 17 00:00:00 2001 From: Youssef Muhamad Date: Wed, 4 Mar 2020 16:39:10 -0300 Subject: [PATCH 09/10] [IMPROVEMENT]Refactor SwitchContainer to a memoized functional component --- app/views/RoomInfoEditView/SwitchContainer.js | 95 +++++++++---------- 1 file changed, 46 insertions(+), 49 deletions(-) diff --git a/app/views/RoomInfoEditView/SwitchContainer.js b/app/views/RoomInfoEditView/SwitchContainer.js index 69462365a3f..de1aed98f0a 100644 --- a/app/views/RoomInfoEditView/SwitchContainer.js +++ b/app/views/RoomInfoEditView/SwitchContainer.js @@ -5,53 +5,50 @@ import PropTypes from 'prop-types'; import styles from './styles'; import { SWITCH_TRACK_COLOR, themes } from '../../constants/colors'; -export default class SwitchContainer extends React.PureComponent { - static propTypes = { - value: PropTypes.bool, - disabled: PropTypes.bool, - leftLabelPrimary: PropTypes.string, - leftLabelSecondary: PropTypes.string, - rightLabelPrimary: PropTypes.string, - rightLabelSecondary: PropTypes.string, - onValueChange: PropTypes.func, - theme: PropTypes.string, - testID: PropTypes.string, - labelContainerStyle: PropTypes.object, - leftLabelStyle: PropTypes.object, - children: PropTypes.any - } - - render() { - const { - children, value, disabled, onValueChange, leftLabelPrimary, leftLabelSecondary, rightLabelPrimary, rightLabelSecondary, theme, testID, labelContainerStyle, leftLabelStyle - } = this.props; - return ( - <> - - {leftLabelPrimary && ( - - {leftLabelPrimary} - {leftLabelSecondary} - - )} - - {rightLabelPrimary && ( - - {rightLabelPrimary} - {rightLabelSecondary} - - )} +const SwitchContainer = React.memo(({ + children, value, disabled, onValueChange, leftLabelPrimary, leftLabelSecondary, rightLabelPrimary, rightLabelSecondary, theme, testID, labelContainerStyle, leftLabelStyle +}) => ( + <> + + {leftLabelPrimary && ( + + {leftLabelPrimary} + {leftLabelSecondary} + + )} + + {rightLabelPrimary && ( + + {rightLabelPrimary} + {rightLabelSecondary} - {children} - - - ); - } -} + )} + + {children} + + +)); + +SwitchContainer.propTypes = { + value: PropTypes.bool, + disabled: PropTypes.bool, + leftLabelPrimary: PropTypes.string, + leftLabelSecondary: PropTypes.string, + rightLabelPrimary: PropTypes.string, + rightLabelSecondary: PropTypes.string, + onValueChange: PropTypes.func, + theme: PropTypes.string, + testID: PropTypes.string, + labelContainerStyle: PropTypes.object, + leftLabelStyle: PropTypes.object, + children: PropTypes.any +}; + +export default SwitchContainer; From f0eb6e50f4765ac16b4616cf427980168cad1784 Mon Sep 17 00:00:00 2001 From: Djorkaeff Alexandre Date: Thu, 5 Mar 2020 12:04:56 -0300 Subject: [PATCH 10/10] [FIX] Older servers --- app/views/RoomInfoEditView/index.js | 36 ++++++++++++++++++----------- app/views/RoomView/List.js | 8 ++++++- 2 files changed, 29 insertions(+), 15 deletions(-) diff --git a/app/views/RoomInfoEditView/index.js b/app/views/RoomInfoEditView/index.js index d287fe0565b..bfe11adbc3a 100644 --- a/app/views/RoomInfoEditView/index.js +++ b/app/views/RoomInfoEditView/index.js @@ -8,6 +8,7 @@ import { SafeAreaView } from 'react-navigation'; import equal from 'deep-equal'; import { BLOCK_CONTEXT } from '@rocket.chat/ui-kit'; import isEqual from 'lodash/isEqual'; +import semver from 'semver'; import database from '../../lib/database'; import { eraseRoom as eraseRoomAction } from '../../actions/room'; @@ -56,6 +57,7 @@ class RoomInfoEditView extends React.Component { static propTypes = { navigation: PropTypes.object, eraseRoom: PropTypes.func, + serverVersion: PropTypes.string, theme: PropTypes.string }; @@ -337,7 +339,7 @@ class RoomInfoEditView extends React.Component { const { name, nameError, description, topic, announcement, t, ro, reactWhenReadOnly, room, joinCode, saving, permissions, archived, enableSysMes } = this.state; - const { theme } = this.props; + const { serverVersion, theme } = this.props; const { dangerColor } = themes[theme]; return ( @@ -444,18 +446,20 @@ class RoomInfoEditView extends React.Component { ] : null } - this.setState(({ systemMessages }) => ({ enableSysMes: value, systemMessages: value ? systemMessages : [] }))} - labelContainerStyle={styles.hideSystemMessages} - leftLabelStyle={styles.systemMessagesLabel} - > - {this.renderSystemMessages()} - + {serverVersion && !semver.lt(serverVersion, '3.0.0') ? ( + this.setState(({ systemMessages }) => ({ enableSysMes: value, systemMessages: value ? systemMessages : [] }))} + labelContainerStyle={styles.hideSystemMessages} + leftLabelStyle={styles.systemMessagesLabel} + > + {this.renderSystemMessages()} + + ) : null} ({ + serverVersion: state.server.version +}); + const mapDispatchToProps = dispatch => ({ eraseRoom: (rid, t) => dispatch(eraseRoomAction(rid, t)) }); -export default connect(null, mapDispatchToProps)(withTheme(RoomInfoEditView)); +export default connect(mapStateToProps, mapDispatchToProps)(withTheme(RoomInfoEditView)); diff --git a/app/views/RoomView/List.js b/app/views/RoomView/List.js index b5ca3497d3c..5ca13644b1c 100644 --- a/app/views/RoomView/List.js +++ b/app/views/RoomView/List.js @@ -63,9 +63,15 @@ class List extends React.Component { // eslint-disable-next-line react/sort-comp async init() { - const { rid, tmid, hideSystemMessages = [] } = this.props; + const { rid, tmid } = this.props; const db = database.active; + // handle servers with version < 3.0.0 + let { hideSystemMessages = [] } = this.props; + if (!Array.isArray(hideSystemMessages)) { + hideSystemMessages = []; + } + if (tmid) { try { this.thread = await db.collections