From 0ff3842f7e1d7b9f142ccb256ae1361ae7fecc29 Mon Sep 17 00:00:00 2001 From: Daniel Maike Date: Wed, 30 Sep 2020 19:02:16 -0300 Subject: [PATCH 01/19] Adding joinCode parameter Co-authored-by: Vitor Leal Co-authored-by: Fernando Aguilar --- app/lib/rocketchat.js | 4 ++-- app/views/RoomView/index.js | 5 +++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/app/lib/rocketchat.js b/app/lib/rocketchat.js index 2ccd1073a1..c41504c338 100644 --- a/app/lib/rocketchat.js +++ b/app/lib/rocketchat.js @@ -597,13 +597,13 @@ const RocketChat = { }); }, - joinRoom(roomId, type) { + joinRoom(roomId, joinCode, type) { // TODO: join code // RC 0.48.0 if (type === 'p') { return this.methodCallWrapper('joinRoom', roomId); } - return this.post('channels.join', { roomId }); + return this.post('channels.join', { roomId, joinCode }); }, triggerBlockAction, triggerSubmitView, diff --git a/app/views/RoomView/index.js b/app/views/RoomView/index.js index ece024a0f1..e3ac193acf 100644 --- a/app/views/RoomView/index.js +++ b/app/views/RoomView/index.js @@ -113,6 +113,7 @@ class RoomView extends React.Component { const search = props.route.params?.search; const prid = props.route.params?.prid; this.state = { + joinCode: '', joined: true, room: room || { rid: this.rid, t: this.t, name, fname, prid @@ -688,12 +689,12 @@ class RoomView extends React.Component { joinRoom = async() => { logEvent(events.ROOM_JOIN); try { - const { room } = this.state; + const { room, joinCode } = this.state; if (this.isOmnichannel) { await takeInquiry(room._id); } else { - await RocketChat.joinRoom(this.rid, this.t); + await RocketChat.joinRoom(this.rid, joinCode, this.t); } this.internalSetState({ joined: true From 9b1253770584c0b43d8c5f0406d9beedb9f9a9c6 Mon Sep 17 00:00:00 2001 From: "Vitor.Leal" Date: Sat, 3 Oct 2020 18:49:43 -0300 Subject: [PATCH 02/19] Insert join code input Signed-off-by: Vitor.Leal --- app/views/RoomView/index.js | 10 +++++++++- app/views/RoomView/styles.js | 6 ++++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/app/views/RoomView/index.js b/app/views/RoomView/index.js index e3ac193acf..289300002c 100644 --- a/app/views/RoomView/index.js +++ b/app/views/RoomView/index.js @@ -55,7 +55,7 @@ import Navigation from '../../lib/Navigation'; import SafeAreaView from '../../containers/SafeAreaView'; import { withDimensions } from '../../dimensions'; import { getHeaderTitlePosition } from '../../containers/Header'; - +import TextInput from '../../presentation/TextInput'; import { takeInquiry } from '../../ee/omnichannel/lib'; const stateAttrsUpdate = [ @@ -908,6 +908,14 @@ class RoomView extends React.Component { return ( {I18n.t('You_are_in_preview_mode')} + { this.setState({ joinCode: value }); }} + underlineColorAndroid='transparent' + style={[styles.joinInput, { borderColor: theme === 'light' ? 'black' : 'white' }]} + theme={theme} + /> Date: Sat, 3 Oct 2020 18:53:54 -0300 Subject: [PATCH 03/19] Add joinCode field on db Signed-off-by: Vitor.Leal --- app/lib/database/model/Subscription.js | 2 ++ app/lib/database/model/migrations.js | 11 +++++++++++ app/lib/database/schema/app.js | 5 +++-- app/lib/methods/helpers/findSubscriptionsRooms.js | 3 ++- app/lib/methods/subscriptions/rooms.js | 5 +++-- 5 files changed, 21 insertions(+), 5 deletions(-) diff --git a/app/lib/database/model/Subscription.js b/app/lib/database/model/Subscription.js index a94e09423a..8a78370ae1 100644 --- a/app/lib/database/model/Subscription.js +++ b/app/lib/database/model/Subscription.js @@ -109,4 +109,6 @@ export default class Subscription extends Model { @json('livechat_data', sanitizer) livechatData; @json('tags', sanitizer) tags; + + @field('join_code') joinCode; } diff --git a/app/lib/database/model/migrations.js b/app/lib/database/model/migrations.js index db3b92dc3a..ee19a05779 100644 --- a/app/lib/database/model/migrations.js +++ b/app/lib/database/model/migrations.js @@ -129,6 +129,17 @@ export default schemaMigrations({ ] }) ] + }, + { + toVersion: 10, + steps: [ + addColumns({ + table: 'subscriptions', + columns: [ + { name: 'join_code', type: 'string', isOptional: false } + ] + }) + ] } ] }); diff --git a/app/lib/database/schema/app.js b/app/lib/database/schema/app.js index 59336e3f04..1f4b26698b 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: 9, + version: 10, tables: [ tableSchema({ name: 'subscriptions', @@ -49,7 +49,8 @@ export default appSchema({ { name: 'department_id', type: 'string', isOptional: true }, { name: 'served_by', type: 'string', isOptional: true }, { name: 'livechat_data', type: 'string', isOptional: true }, - { name: 'tags', type: 'string', isOptional: true } + { name: 'tags', type: 'string', isOptional: true }, + { name: 'join_code', type: 'string', isOptional: false } ] }), tableSchema({ diff --git a/app/lib/methods/helpers/findSubscriptionsRooms.js b/app/lib/methods/helpers/findSubscriptionsRooms.js index 457fc3b5fc..35e98f19a8 100644 --- a/app/lib/methods/helpers/findSubscriptionsRooms.js +++ b/app/lib/methods/helpers/findSubscriptionsRooms.js @@ -49,7 +49,8 @@ export default async(subscriptions = [], rooms = []) => { departmentId: s.departmentId, servedBy: s.servedBy, livechatData: s.livechatData, - tags: s.tags + tags: s.tags, + joinCode: s.joinCode })); subscriptions = subscriptions.concat(existingSubs); diff --git a/app/lib/methods/subscriptions/rooms.js b/app/lib/methods/subscriptions/rooms.js index 700a713b46..fef4741394 100644 --- a/app/lib/methods/subscriptions/rooms.js +++ b/app/lib/methods/subscriptions/rooms.js @@ -32,7 +32,7 @@ const createOrUpdateSubscription = async(subscription, room) => { const db = database.active; const subCollection = db.collections.get('subscriptions'); const roomsCollection = db.collections.get('rooms'); - + subscription.joinCodeRequired = room.joinCodeRequired; if (!subscription) { try { const s = await subCollection.find(room._id); @@ -79,7 +79,8 @@ const createOrUpdateSubscription = async(subscription, room) => { departmentId: s.departmentId, servedBy: s.servedBy, livechatData: s.livechatData, - tags: s.tags + tags: s.tags, + joinCode: s.joinCode }; } catch (error) { try { From c60f7a10ea5ecd8932faa4695572e3bf5be15a9d Mon Sep 17 00:00:00 2001 From: "Vitor.Leal" Date: Sat, 3 Oct 2020 18:56:03 -0300 Subject: [PATCH 04/19] Add label i18 pt-br and en-us Signed-off-by: Vitor.Leal --- app/i18n/locales/en.js | 1 + app/i18n/locales/pt-BR.js | 1 + 2 files changed, 2 insertions(+) diff --git a/app/i18n/locales/en.js b/app/i18n/locales/en.js index 50f2d2f6b8..2070b79dad 100644 --- a/app/i18n/locales/en.js +++ b/app/i18n/locales/en.js @@ -267,6 +267,7 @@ export default { Invite_Link: 'Invite Link', Invite_users: 'Invite users', Join: 'Join', + Join_Code: 'Join Code', Join_our_open_workspace: 'Join our open workspace', Join_your_workspace: 'Join your workspace', Just_invited_people_can_access_this_channel: 'Just invited people can access this channel', diff --git a/app/i18n/locales/pt-BR.js b/app/i18n/locales/pt-BR.js index e289f6abb5..27fe1a7725 100644 --- a/app/i18n/locales/pt-BR.js +++ b/app/i18n/locales/pt-BR.js @@ -255,6 +255,7 @@ export default { Invite_Link: 'Link de Convite', Invite_users: 'Convidar usuários', Join: 'Entrar', + Join_Code: 'Insira o Código da sala', Join_our_open_workspace: 'Entra na nossa workspace pública', Join_your_workspace: 'Entre na sua workspace', Just_invited_people_can_access_this_channel: 'Apenas as pessoas convidadas podem acessar este canal', From e7d452f2c8accb5a3aaccb7e189e9241a8b4aa63 Mon Sep 17 00:00:00 2001 From: "Vitor.Leal" Date: Tue, 6 Oct 2020 14:01:51 -0300 Subject: [PATCH 05/19] Add insert join code text Signed-off-by: Vitor.Leal --- app/i18n/locales/en.js | 1 + app/i18n/locales/pt-BR.js | 1 + 2 files changed, 2 insertions(+) diff --git a/app/i18n/locales/en.js b/app/i18n/locales/en.js index 2070b79dad..90d866a498 100644 --- a/app/i18n/locales/en.js +++ b/app/i18n/locales/en.js @@ -268,6 +268,7 @@ export default { Invite_users: 'Invite users', Join: 'Join', Join_Code: 'Join Code', + Insert_Join_Code: 'Insert Join code', Join_our_open_workspace: 'Join our open workspace', Join_your_workspace: 'Join your workspace', Just_invited_people_can_access_this_channel: 'Just invited people can access this channel', diff --git a/app/i18n/locales/pt-BR.js b/app/i18n/locales/pt-BR.js index 27fe1a7725..f189dbe5e2 100644 --- a/app/i18n/locales/pt-BR.js +++ b/app/i18n/locales/pt-BR.js @@ -256,6 +256,7 @@ export default { Invite_users: 'Convidar usuários', Join: 'Entrar', Join_Code: 'Insira o Código da sala', + Insert_Join_Code: 'Insira o código para entrar na sala', Join_our_open_workspace: 'Entra na nossa workspace pública', Join_your_workspace: 'Entre na sua workspace', Just_invited_people_can_access_this_channel: 'Apenas as pessoas convidadas podem acessar este canal', From ebe257a305c49c0731d5016d5efa691da5d2bde3 Mon Sep 17 00:00:00 2001 From: "Vitor.Leal" Date: Tue, 6 Oct 2020 14:06:38 -0300 Subject: [PATCH 06/19] Fix atribute name Signed-off-by: Vitor.Leal --- app/lib/database/model/Subscription.js | 4 +--- app/lib/database/model/migrations.js | 2 +- app/lib/database/schema/app.js | 3 +-- app/lib/methods/helpers/findSubscriptionsRooms.js | 7 +++---- app/lib/methods/helpers/mergeSubscriptionsRooms.js | 1 + app/lib/methods/subscriptions/rooms.js | 7 +++---- 6 files changed, 10 insertions(+), 14 deletions(-) diff --git a/app/lib/database/model/Subscription.js b/app/lib/database/model/Subscription.js index 8a78370ae1..69af730a4c 100644 --- a/app/lib/database/model/Subscription.js +++ b/app/lib/database/model/Subscription.js @@ -64,8 +64,6 @@ export default class Subscription extends Model { @field('archived') archived; - @field('join_code_required') joinCodeRequired; - @field('notifications') notifications; @json('muted', sanitizer) muted; @@ -110,5 +108,5 @@ export default class Subscription extends Model { @json('tags', sanitizer) tags; - @field('join_code') joinCode; + @field('join_code_required') joinCodeRequired; } diff --git a/app/lib/database/model/migrations.js b/app/lib/database/model/migrations.js index ee19a05779..82649ccb08 100644 --- a/app/lib/database/model/migrations.js +++ b/app/lib/database/model/migrations.js @@ -136,7 +136,7 @@ export default schemaMigrations({ addColumns({ table: 'subscriptions', columns: [ - { name: 'join_code', type: 'string', isOptional: false } + { name: 'join_code_required', type: 'boolean' } ] }) ] diff --git a/app/lib/database/schema/app.js b/app/lib/database/schema/app.js index 1f4b26698b..cb27169c1d 100644 --- a/app/lib/database/schema/app.js +++ b/app/lib/database/schema/app.js @@ -32,7 +32,6 @@ export default appSchema({ { name: 'blocker', type: 'boolean', isOptional: true }, { name: 'react_when_read_only', type: 'boolean', isOptional: true }, { name: 'archived', type: 'boolean' }, - { name: 'join_code_required', type: 'boolean', isOptional: true }, { name: 'muted', type: 'string', isOptional: true }, { name: 'broadcast', type: 'boolean', isOptional: true }, { name: 'prid', type: 'string', isOptional: true }, @@ -50,7 +49,7 @@ export default appSchema({ { name: 'served_by', type: 'string', isOptional: true }, { name: 'livechat_data', type: 'string', isOptional: true }, { name: 'tags', type: 'string', isOptional: true }, - { name: 'join_code', type: 'string', isOptional: false } + { name: 'join_code_required', type: 'boolean' } ] }), tableSchema({ diff --git a/app/lib/methods/helpers/findSubscriptionsRooms.js b/app/lib/methods/helpers/findSubscriptionsRooms.js index 35e98f19a8..92db451ba1 100644 --- a/app/lib/methods/helpers/findSubscriptionsRooms.js +++ b/app/lib/methods/helpers/findSubscriptionsRooms.js @@ -33,7 +33,6 @@ export default async(subscriptions = [], rooms = []) => { blocker: s.blocker, reactWhenReadOnly: s.reactWhenReadOnly, archived: s.archived, - joinCodeRequired: s.joinCodeRequired, muted: s.muted, broadcast: s.broadcast, prid: s.prid, @@ -50,7 +49,7 @@ export default async(subscriptions = [], rooms = []) => { servedBy: s.servedBy, livechatData: s.livechatData, tags: s.tags, - joinCode: s.joinCode + joinCodeRequired: s.joinCodeRequired })); subscriptions = subscriptions.concat(existingSubs); @@ -64,7 +63,6 @@ export default async(subscriptions = [], rooms = []) => { announcement: r.announcement, reactWhenReadOnly: r.reactWhenReadOnly, archived: r.archived, - joinCodeRequired: r.joinCodeRequired, jitsiTimeout: r.jitsiTimeout, usernames: r.usernames, uids: r.uids, @@ -76,7 +74,8 @@ export default async(subscriptions = [], rooms = []) => { departmentId: r.departmentId, servedBy: r.servedBy, livechatData: r.livechatData, - tags: r.tags + tags: r.tags, + joinCodeRequired: r.joinCodeRequired })); rooms = rooms.concat(existingRooms); } catch { diff --git a/app/lib/methods/helpers/mergeSubscriptionsRooms.js b/app/lib/methods/helpers/mergeSubscriptionsRooms.js index c4d3acd405..e0d3f717ae 100644 --- a/app/lib/methods/helpers/mergeSubscriptionsRooms.js +++ b/app/lib/methods/helpers/mergeSubscriptionsRooms.js @@ -26,6 +26,7 @@ export const merge = (subscription, room) => { subscription.uids = room.uids; } subscription.ro = room.ro; + subscription.joinCodeRequired = room.joinCodeRequired; subscription.broadcast = room.broadcast; if (!subscription.roles || !subscription.roles.length) { subscription.roles = []; diff --git a/app/lib/methods/subscriptions/rooms.js b/app/lib/methods/subscriptions/rooms.js index fef4741394..0f59b7f014 100644 --- a/app/lib/methods/subscriptions/rooms.js +++ b/app/lib/methods/subscriptions/rooms.js @@ -32,7 +32,6 @@ const createOrUpdateSubscription = async(subscription, room) => { const db = database.active; const subCollection = db.collections.get('subscriptions'); const roomsCollection = db.collections.get('rooms'); - subscription.joinCodeRequired = room.joinCodeRequired; if (!subscription) { try { const s = await subCollection.find(room._id); @@ -62,7 +61,6 @@ const createOrUpdateSubscription = async(subscription, room) => { blocker: s.blocker, reactWhenReadOnly: s.reactWhenReadOnly, archived: s.archived, - joinCodeRequired: s.joinCodeRequired, muted: s.muted, broadcast: s.broadcast, prid: s.prid, @@ -80,7 +78,7 @@ const createOrUpdateSubscription = async(subscription, room) => { servedBy: s.servedBy, livechatData: s.livechatData, tags: s.tags, - joinCode: s.joinCode + joinCodeRequired: s.joinCodeRequired }; } catch (error) { try { @@ -111,7 +109,8 @@ const createOrUpdateSubscription = async(subscription, room) => { broadcast: r.broadcast, customFields: r.customFields, departmentId: r.departmentId, - livechatData: r.livechatData + livechatData: r.livechatData, + joinCodeRequired: r.joinCodeRequired }; } catch (error) { // Do nothing From 40ca5ea0957cf685a46f2081a502fb5dd58143c1 Mon Sep 17 00:00:00 2001 From: "Vitor.Leal" Date: Tue, 6 Oct 2020 14:08:13 -0300 Subject: [PATCH 07/19] Add join text Signed-off-by: Vitor.Leal Co-authored-by: Daniel Maike Co-authored-by: Fernando Aguilar --- app/views/RoomView/index.js | 31 ++++++++++++++++++++----------- 1 file changed, 20 insertions(+), 11 deletions(-) diff --git a/app/views/RoomView/index.js b/app/views/RoomView/index.js index 289300002c..89ed376362 100644 --- a/app/views/RoomView/index.js +++ b/app/views/RoomView/index.js @@ -109,11 +109,12 @@ class RoomView extends React.Component { const room = props.route.params?.room; const selectedMessage = props.route.params?.message; const name = props.route.params?.name; + const { joinCodeRequired } = props.route.params.room; const fname = props.route.params?.fname; const search = props.route.params?.search; const prid = props.route.params?.prid; this.state = { - joinCode: '', + joinCodeRequired, joined: true, room: room || { rid: this.rid, t: this.t, name, fname, prid @@ -897,7 +898,7 @@ class RoomView extends React.Component { renderFooter = () => { const { - joined, room, selectedMessage, editing, replying, replyWithMention, readOnly + joined, room, selectedMessage, editing, replying, replyWithMention, readOnly, joinCodeRequired } = this.state; const { navigation, theme } = this.props; @@ -907,15 +908,23 @@ class RoomView extends React.Component { if (!joined && !this.tmid) { return ( - {I18n.t('You_are_in_preview_mode')} - { this.setState({ joinCode: value }); }} - underlineColorAndroid='transparent' - style={[styles.joinInput, { borderColor: theme === 'light' ? 'black' : 'white' }]} - theme={theme} - /> + { + joinCodeRequired + ? ( + <> + {I18n.t('Insert_Join_Code')} + { this.setState({ joinCode: value }); }} + underlineColorAndroid='transparent' + style={[styles.joinInput, { borderColor: theme === 'light' ? 'black' : 'white' }]} + theme={theme} + /> + + ) + : {I18n.t('You_are_in_preview_mode')} + } Date: Wed, 7 Oct 2020 00:01:52 -0300 Subject: [PATCH 08/19] Fix attributes joinCode, joinCodeRequired and pass attribute param in navigation Signed-off-by: Daniel Maike Co-authored-by: Vitor Leal --- app/utils/goRoom.js | 5 ++++- app/views/RoomView/index.js | 8 ++++---- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/app/utils/goRoom.js b/app/utils/goRoom.js index f126309513..b506b94436 100644 --- a/app/utils/goRoom.js +++ b/app/utils/goRoom.js @@ -1,13 +1,16 @@ import Navigation from '../lib/Navigation'; import RocketChat from '../lib/rocketchat'; -const navigate = ({ item, isMasterDetail, ...props }) => { +const navigate = async({ item, isMasterDetail, ...props }) => { let navigationMethod = Navigation.navigate; if (isMasterDetail) { navigationMethod = Navigation.replace; } + const { room } = await RocketChat.getRoomInfo(item.rid); + item.joinCodeRequired = room.joinCodeRequired; + navigationMethod('RoomView', { rid: item.rid, name: RocketChat.getRoomTitle(item), diff --git a/app/views/RoomView/index.js b/app/views/RoomView/index.js index 89ed376362..5f02eb55f9 100644 --- a/app/views/RoomView/index.js +++ b/app/views/RoomView/index.js @@ -71,7 +71,7 @@ const stateAttrsUpdate = [ 'readOnly', 'member' ]; -const roomAttrsUpdate = ['f', 'ro', 'blocked', 'blocker', 'archived', 'muted', 'jitsiTimeout', 'announcement', 'sysMes', 'topic', 'name', 'fname', 'roles', 'bannerClosed', 'visitor']; +const roomAttrsUpdate = ['f', 'ro', 'blocked', 'blocker', 'archived', 'muted', 'jitsiTimeout', 'announcement', 'sysMes', 'topic', 'name', 'fname', 'roles', 'bannerClosed', 'visitor', 'joinCodeRequired']; class RoomView extends React.Component { static propTypes = { @@ -109,12 +109,11 @@ class RoomView extends React.Component { const room = props.route.params?.room; const selectedMessage = props.route.params?.message; const name = props.route.params?.name; - const { joinCodeRequired } = props.route.params.room; const fname = props.route.params?.fname; const search = props.route.params?.search; const prid = props.route.params?.prid; this.state = { - joinCodeRequired, + joinCode: '', joined: true, room: room || { rid: this.rid, t: this.t, name, fname, prid @@ -898,9 +897,10 @@ class RoomView extends React.Component { renderFooter = () => { const { - joined, room, selectedMessage, editing, replying, replyWithMention, readOnly, joinCodeRequired + joined, room, selectedMessage, editing, replying, replyWithMention, readOnly } = this.state; const { navigation, theme } = this.props; + const { joinCodeRequired } = room; if (!this.rid) { return null; From a9e200aebda9e9bc04293a609e508c1716815215 Mon Sep 17 00:00:00 2001 From: Daniel Maike Date: Wed, 7 Oct 2020 09:44:54 -0300 Subject: [PATCH 09/19] Fixing attribute joinCodeRequired pass to goRoom Signed-off-by: Daniel Maike --- app/utils/goRoom.js | 5 +---- app/views/DirectoryView/index.js | 3 ++- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/app/utils/goRoom.js b/app/utils/goRoom.js index b506b94436..f126309513 100644 --- a/app/utils/goRoom.js +++ b/app/utils/goRoom.js @@ -1,16 +1,13 @@ import Navigation from '../lib/Navigation'; import RocketChat from '../lib/rocketchat'; -const navigate = async({ item, isMasterDetail, ...props }) => { +const navigate = ({ item, isMasterDetail, ...props }) => { let navigationMethod = Navigation.navigate; if (isMasterDetail) { navigationMethod = Navigation.replace; } - const { room } = await RocketChat.getRoomInfo(item.rid); - item.joinCodeRequired = room.joinCodeRequired; - navigationMethod('RoomView', { rid: item.rid, name: RocketChat.getRoomTitle(item), diff --git a/app/views/DirectoryView/index.js b/app/views/DirectoryView/index.js index 6a02092afd..f9be34e633 100644 --- a/app/views/DirectoryView/index.js +++ b/app/views/DirectoryView/index.js @@ -149,8 +149,9 @@ class DirectoryView extends React.Component { this.goRoom({ rid: result.room._id, name: item.username, t: 'd' }); } } else { + const { room } = await RocketChat.getRoomInfo(item._id); this.goRoom({ - rid: item._id, name: item.name, t: 'c', search: true + rid: item._id, name: item.name, joinCodeRequired: room.joinCodeRequired, t: 'c', search: true }); } } From 68aa40608874fdcd72916a4cde2e9a7418d80bae Mon Sep 17 00:00:00 2001 From: Daniel Maike Date: Wed, 7 Oct 2020 10:09:12 -0300 Subject: [PATCH 10/19] Changed textinput style Signed-off-by: Daniel Maike Co-authored-by: Vitor Leal --- app/views/RoomView/index.js | 4 ++-- app/views/RoomView/styles.js | 7 ++----- 2 files changed, 4 insertions(+), 7 deletions(-) diff --git a/app/views/RoomView/index.js b/app/views/RoomView/index.js index 046570a474..9b9d92d3d0 100644 --- a/app/views/RoomView/index.js +++ b/app/views/RoomView/index.js @@ -56,7 +56,7 @@ import Navigation from '../../lib/Navigation'; import SafeAreaView from '../../containers/SafeAreaView'; import { withDimensions } from '../../dimensions'; import { getHeaderTitlePosition } from '../../containers/Header'; -import TextInput from '../../presentation/TextInput'; +import TextInput from '../../containers/TextInput'; import { E2E_MESSAGE_TYPE, E2E_STATUS } from '../../lib/encryption/constants'; import { takeInquiry } from '../../ee/omnichannel/lib'; @@ -939,7 +939,7 @@ class RoomView extends React.Component { placeholder={I18n.t('Join_Code')} onChangeText={(value) => { this.setState({ joinCode: value }); }} underlineColorAndroid='transparent' - style={[styles.joinInput, { borderColor: theme === 'light' ? 'black' : 'white' }]} + containerStyle={styles.joinCodeInput} theme={theme} /> diff --git a/app/views/RoomView/styles.js b/app/views/RoomView/styles.js index 362b94c9d6..0da77d7371 100644 --- a/app/views/RoomView/styles.js +++ b/app/views/RoomView/styles.js @@ -71,10 +71,7 @@ export default StyleSheet.create({ fontSize: 16, ...sharedStyles.textMedium }, - joinInput: { - marginTop: 10, - borderWidth: 2, - width: '90%', - textAlign: 'center' + joinCodeInput: { + padding: 8 } }); From 13e30351f44b20834f1bb81481a2eed3ada3b64a Mon Sep 17 00:00:00 2001 From: Daniel Maike Date: Wed, 7 Oct 2020 18:46:54 -0300 Subject: [PATCH 11/19] Delete not necessary attribute Signed-off-by: Daniel Maike --- app/lib/database/model/Subscription.js | 2 -- app/lib/database/model/migrations.js | 1 - app/lib/database/schema/app.js | 1 - app/lib/methods/helpers/findSubscriptionsRooms.js | 2 -- app/lib/methods/subscriptions/rooms.js | 4 +--- 5 files changed, 1 insertion(+), 9 deletions(-) diff --git a/app/lib/database/model/Subscription.js b/app/lib/database/model/Subscription.js index c11af8ad80..2f20da4f63 100644 --- a/app/lib/database/model/Subscription.js +++ b/app/lib/database/model/Subscription.js @@ -108,8 +108,6 @@ export default class Subscription extends Model { @json('tags', sanitizer) tags; - @field('join_code_required') joinCodeRequired; - @field('e2e_key') E2EKey; @field('encrypted') encrypted; diff --git a/app/lib/database/model/migrations.js b/app/lib/database/model/migrations.js index 3ce70423fb..9dd8517904 100644 --- a/app/lib/database/model/migrations.js +++ b/app/lib/database/model/migrations.js @@ -136,7 +136,6 @@ export default schemaMigrations({ addColumns({ table: 'subscriptions', columns: [ - { name: 'join_code_required', type: 'boolean' }, { name: 'e2e_key', type: 'string', isOptional: true }, { name: 'encrypted', type: 'boolean', isOptional: true }, { name: 'e2e_key_id', type: 'string', isOptional: true } diff --git a/app/lib/database/schema/app.js b/app/lib/database/schema/app.js index b1b19a3e6c..2b792d2577 100644 --- a/app/lib/database/schema/app.js +++ b/app/lib/database/schema/app.js @@ -49,7 +49,6 @@ export default appSchema({ { name: 'served_by', type: 'string', isOptional: true }, { name: 'livechat_data', type: 'string', isOptional: true }, { name: 'tags', type: 'string', isOptional: true }, - { name: 'join_code_required', type: 'boolean' }, { name: 'e2e_key', type: 'string', isOptional: true }, { name: 'encrypted', type: 'boolean', isOptional: true }, { name: 'e2e_key_id', type: 'string', isOptional: true } diff --git a/app/lib/methods/helpers/findSubscriptionsRooms.js b/app/lib/methods/helpers/findSubscriptionsRooms.js index 339b1a6762..2feb6b269d 100644 --- a/app/lib/methods/helpers/findSubscriptionsRooms.js +++ b/app/lib/methods/helpers/findSubscriptionsRooms.js @@ -49,7 +49,6 @@ export default async(subscriptions = [], rooms = []) => { servedBy: s.servedBy, livechatData: s.livechatData, tags: s.tags, - joinCodeRequired: s.joinCodeRequired, encrypted: s.encrypted, e2eKeyId: s.e2eKeyId, E2EKey: s.E2EKey @@ -78,7 +77,6 @@ export default async(subscriptions = [], rooms = []) => { servedBy: r.servedBy, livechatData: r.livechatData, tags: r.tags, - joinCodeRequired: r.joinCodeRequired, encrypted: r.encrypted, e2eKeyId: r.e2eKeyId })); diff --git a/app/lib/methods/subscriptions/rooms.js b/app/lib/methods/subscriptions/rooms.js index 7d237d3c7d..a2bc6798da 100644 --- a/app/lib/methods/subscriptions/rooms.js +++ b/app/lib/methods/subscriptions/rooms.js @@ -80,7 +80,6 @@ const createOrUpdateSubscription = async(subscription, room) => { servedBy: s.servedBy, livechatData: s.livechatData, tags: s.tags, - joinCodeRequired: s.joinCodeRequired, encrypted: s.encrypted, e2eKeyId: s.e2eKeyId, E2EKey: s.E2EKey @@ -115,8 +114,7 @@ const createOrUpdateSubscription = async(subscription, room) => { broadcast: r.broadcast, customFields: r.customFields, departmentId: r.departmentId, - livechatData: r.livechatData, - joinCodeRequired: r.joinCodeRequired + livechatData: r.livechatData }; } catch (error) { // Do nothing From e224dcba92290946bb7a2546e2cef36d39eacc89 Mon Sep 17 00:00:00 2001 From: Daniel Maike Date: Wed, 7 Oct 2020 23:46:22 -0300 Subject: [PATCH 12/19] Fixing input style Co-authored-by: Vitor Leal --- app/views/RoomView/index.js | 6 ++++-- app/views/RoomView/styles.js | 4 +++- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/app/views/RoomView/index.js b/app/views/RoomView/index.js index 9b9d92d3d0..d66549b77e 100644 --- a/app/views/RoomView/index.js +++ b/app/views/RoomView/index.js @@ -933,7 +933,7 @@ class RoomView extends React.Component { joinCodeRequired ? ( <> - {I18n.t('Insert_Join_Code')} + {I18n.t('Insert_Join_Code')} ) - : {I18n.t('You_are_in_preview_mode')} + : {I18n.t('You_are_in_preview_mode')} } Date: Tue, 13 Oct 2020 12:56:55 -0300 Subject: [PATCH 13/19] Undo unncessary changes --- app/lib/database/model/Subscription.js | 2 ++ app/lib/database/schema/app.js | 1 + app/lib/methods/helpers/findSubscriptionsRooms.js | 2 ++ app/lib/methods/helpers/mergeSubscriptionsRooms.js | 1 - app/lib/methods/subscriptions/rooms.js | 2 ++ 5 files changed, 7 insertions(+), 1 deletion(-) diff --git a/app/lib/database/model/Subscription.js b/app/lib/database/model/Subscription.js index 2f20da4f63..afdd8391f9 100644 --- a/app/lib/database/model/Subscription.js +++ b/app/lib/database/model/Subscription.js @@ -64,6 +64,8 @@ export default class Subscription extends Model { @field('archived') archived; + @field('join_code_required') joinCodeRequired; + @field('notifications') notifications; @json('muted', sanitizer) muted; diff --git a/app/lib/database/schema/app.js b/app/lib/database/schema/app.js index 2b792d2577..3a1935cac4 100644 --- a/app/lib/database/schema/app.js +++ b/app/lib/database/schema/app.js @@ -32,6 +32,7 @@ export default appSchema({ { name: 'blocker', type: 'boolean', isOptional: true }, { name: 'react_when_read_only', type: 'boolean', isOptional: true }, { name: 'archived', type: 'boolean' }, + { name: 'join_code_required', type: 'boolean', isOptional: true }, { name: 'muted', type: 'string', isOptional: true }, { name: 'broadcast', type: 'boolean', isOptional: true }, { name: 'prid', type: 'string', isOptional: true }, diff --git a/app/lib/methods/helpers/findSubscriptionsRooms.js b/app/lib/methods/helpers/findSubscriptionsRooms.js index 2feb6b269d..fb3bc6d33a 100644 --- a/app/lib/methods/helpers/findSubscriptionsRooms.js +++ b/app/lib/methods/helpers/findSubscriptionsRooms.js @@ -33,6 +33,7 @@ export default async(subscriptions = [], rooms = []) => { blocker: s.blocker, reactWhenReadOnly: s.reactWhenReadOnly, archived: s.archived, + joinCodeRequired: s.joinCodeRequired, muted: s.muted, broadcast: s.broadcast, prid: s.prid, @@ -65,6 +66,7 @@ export default async(subscriptions = [], rooms = []) => { announcement: r.announcement, reactWhenReadOnly: r.reactWhenReadOnly, archived: r.archived, + joinCodeRequired: r.joinCodeRequired, jitsiTimeout: r.jitsiTimeout, usernames: r.usernames, uids: r.uids, diff --git a/app/lib/methods/helpers/mergeSubscriptionsRooms.js b/app/lib/methods/helpers/mergeSubscriptionsRooms.js index 5453a1c100..c529102f2d 100644 --- a/app/lib/methods/helpers/mergeSubscriptionsRooms.js +++ b/app/lib/methods/helpers/mergeSubscriptionsRooms.js @@ -27,7 +27,6 @@ export const merge = (subscription, room) => { subscription.uids = room.uids; } subscription.ro = room.ro; - subscription.joinCodeRequired = room.joinCodeRequired; subscription.broadcast = room.broadcast; subscription.encrypted = room.encrypted; subscription.e2eKeyId = room.e2eKeyId; diff --git a/app/lib/methods/subscriptions/rooms.js b/app/lib/methods/subscriptions/rooms.js index a2bc6798da..eee596e860 100644 --- a/app/lib/methods/subscriptions/rooms.js +++ b/app/lib/methods/subscriptions/rooms.js @@ -34,6 +34,7 @@ const createOrUpdateSubscription = async(subscription, room) => { const db = database.active; const subCollection = db.collections.get('subscriptions'); const roomsCollection = db.collections.get('rooms'); + if (!subscription) { try { const s = await subCollection.find(room._id); @@ -63,6 +64,7 @@ const createOrUpdateSubscription = async(subscription, room) => { blocker: s.blocker, reactWhenReadOnly: s.reactWhenReadOnly, archived: s.archived, + joinCodeRequired: s.joinCodeRequired, muted: s.muted, broadcast: s.broadcast, prid: s.prid, From 39c27163f5bd48c8a02799301c8f50df33820aee Mon Sep 17 00:00:00 2001 From: Djorkaeff Alexandre Date: Tue, 13 Oct 2020 14:12:13 -0300 Subject: [PATCH 14/19] use a join code modal --- app/views/RoomView/JoinCode.js | 139 +++++++++++++++++++++++++++++++++ app/views/RoomView/index.js | 51 ++++++------ app/views/RoomView/styles.js | 5 -- 3 files changed, 163 insertions(+), 32 deletions(-) create mode 100644 app/views/RoomView/JoinCode.js diff --git a/app/views/RoomView/JoinCode.js b/app/views/RoomView/JoinCode.js new file mode 100644 index 0000000000..7e93df6417 --- /dev/null +++ b/app/views/RoomView/JoinCode.js @@ -0,0 +1,139 @@ +import React, { + useState, + forwardRef, + useImperativeHandle +} from 'react'; +import PropTypes from 'prop-types'; +import { + View, + Text, + StyleSheet, + InteractionManager +} from 'react-native'; +import Modal from 'react-native-modal'; +import { connect } from 'react-redux'; + +import I18n from '../../i18n'; +import Button from '../../containers/Button'; +import TextInput from '../../containers/TextInput'; +import RocketChat from '../../lib/rocketchat'; +import sharedStyles from '../Styles'; + +import { themes } from '../../constants/colors'; + +const styles = StyleSheet.create({ + container: { + flex: 1, + justifyContent: 'center', + alignItems: 'center' + }, + content: { + padding: 16, + width: '100%', + borderRadius: 4 + }, + title: { + fontSize: 16, + paddingBottom: 8, + ...sharedStyles.textBold, + ...sharedStyles.textAlignCenter + }, + button: { + minWidth: 96, + marginBottom: 0 + }, + buttonContainer: { + flexDirection: 'row', + justifyContent: 'space-between' + }, + tablet: { + height: undefined + } +}); + +const JoinCode = React.memo(forwardRef(({ + rid, + t, + onJoin, + isMasterDetail, + theme +}, ref) => { + const [visible, setVisible] = useState(false); + const [error, setError] = useState(false); + const [code, setCode] = useState(''); + + const show = () => setVisible(true); + + const hide = () => setVisible(false); + + const joinRoom = async() => { + try { + await RocketChat.joinRoom(rid, code, t); + onJoin(); + hide(); + } catch (e) { + setError(true); + } + }; + + useImperativeHandle(ref, () => ({ show })); + + return ( + + + + {I18n.t('Insert_Join_Code')} + InteractionManager.runAfterInteractions(() => e?.getNativeRef()?.focus())} + returnKeyType='send' + autoCapitalize='none' + onChangeText={setCode} + onSubmitEditing={joinRoom} + placeholder={I18n.t('Join_Code')} + secureTextEntry + error={error && { error: 'error-code-invalid', reason: I18n.t('Code_or_password_invalid') }} + testID='join-code-input' + /> + +