From 2e65a795df604ddd684412d66cd36ce0170435bb Mon Sep 17 00:00:00 2001 From: Djorkaeff Alexandre Date: Thu, 9 Apr 2020 02:20:57 -0300 Subject: [PATCH 1/9] [FIX] DM header blink (#2011) --- app/lib/methods/canOpenRoom.js | 11 +++++++++-- app/lib/rocketchat.js | 4 +++- app/sagas/deepLinking.js | 7 ++++++- app/views/RoomActionsView/index.js | 3 +-- app/views/RoomView/index.js | 4 ++-- app/views/RoomsListView/index.js | 5 +---- 6 files changed, 22 insertions(+), 12 deletions(-) diff --git a/app/lib/methods/canOpenRoom.js b/app/lib/methods/canOpenRoom.js index ab79d1cd3..1578837aa 100644 --- a/app/lib/methods/canOpenRoom.js +++ b/app/lib/methods/canOpenRoom.js @@ -61,8 +61,15 @@ export default async function canOpenRoom({ rid, path }) { if (rid) { try { - await subsCollection.find(rid); - return { rid }; + const room = await subsCollection.find(rid); + return { + rid, + t: room.t, + name: room.name, + fname: room.fname, + prid: room.prid, + uids: room.uids + }; } catch (e) { // Do nothing } diff --git a/app/lib/rocketchat.js b/app/lib/rocketchat.js index f0dbf2489..ced274270 100644 --- a/app/lib/rocketchat.js +++ b/app/lib/rocketchat.js @@ -812,7 +812,9 @@ const RocketChat = { return this.sdk.get('rooms.info', { roomId }); }, - getUidDirectMessage(room, userId) { + getUidDirectMessage(room) { + const { id: userId } = reduxStore.getState().login.user; + // legacy method if (!room.uids && room.rid && room.t === 'd') { return room.rid.replace(userId, '').trim(); diff --git a/app/sagas/deepLinking.js b/app/sagas/deepLinking.js index 86467d3e2..a5427ea4f 100644 --- a/app/sagas/deepLinking.js +++ b/app/sagas/deepLinking.js @@ -34,7 +34,12 @@ const navigate = function* navigate({ params }) { const [type, name] = params.path.split('/'); if (room) { yield Navigation.navigate('RoomsListView'); - Navigation.navigate('RoomView', { name, t: roomTypes[type], ...room }); + Navigation.navigate('RoomView', { + name, + t: roomTypes[type], + roomUserId: RocketChat.getUidDirectMessage(room), + ...room + }); } } else { yield handleInviteLink({ params }); diff --git a/app/views/RoomActionsView/index.js b/app/views/RoomActionsView/index.js index 7fe261a84..21dc281f0 100644 --- a/app/views/RoomActionsView/index.js +++ b/app/views/RoomActionsView/index.js @@ -384,11 +384,10 @@ class RoomActionsView extends React.Component { updateRoomMember = async() => { const { room } = this.state; - const { user } = this.props; try { if (!RocketChat.isGroupChat(room)) { - const roomUserId = RocketChat.getUidDirectMessage(room, user.id); + const roomUserId = RocketChat.getUidDirectMessage(room); const result = await RocketChat.getUserInfo(roomUserId); if (result.success) { this.setState({ member: result.user }); diff --git a/app/views/RoomView/index.js b/app/views/RoomView/index.js index 9774e020b..ce34d46e8 100644 --- a/app/views/RoomView/index.js +++ b/app/views/RoomView/index.js @@ -390,10 +390,10 @@ class RoomView extends React.Component { const { t } = room; if (t === 'd' && !RocketChat.isGroupChat(room)) { - const { user, navigation } = this.props; + const { navigation } = this.props; try { - const roomUserId = RocketChat.getUidDirectMessage(room, user.id); + const roomUserId = RocketChat.getUidDirectMessage(room); navigation.setParams({ roomUserId }); diff --git a/app/views/RoomsListView/index.js b/app/views/RoomsListView/index.js index 61f41d43c..84aa0027b 100644 --- a/app/views/RoomsListView/index.js +++ b/app/views/RoomsListView/index.js @@ -531,10 +531,7 @@ class RoomsListView extends React.Component { getUserPresence = uid => RocketChat.getUserPresence(uid) - getUidDirectMessage = (room) => { - const { user: { id } } = this.props; - return RocketChat.getUidDirectMessage(room, id); - } + getUidDirectMessage = room => RocketChat.getUidDirectMessage(room); goRoom = (item) => { const { navigation } = this.props; From 00a21808edbd32d2799a9287a7f4b8d6139591fa Mon Sep 17 00:00:00 2001 From: Djorkaeff Alexandre Date: Thu, 9 Apr 2020 02:26:28 -0300 Subject: [PATCH 2/9] [FIX] Split get settings into two requests (#2017) * [FIX] Split get settings into two requests * [FIX] Clear settings only when change server * [IMPROVEMENT] Move the way to clear settings * [REVERT] Revert some changes * [FIX] Server Icon Co-authored-by: Diego Mello --- app/lib/methods/getSettings.js | 20 ++++++++++++++++++-- app/sagas/selectServer.js | 5 ++--- 2 files changed, 20 insertions(+), 5 deletions(-) diff --git a/app/lib/methods/getSettings.js b/app/lib/methods/getSettings.js index 35cd20ade..0e13d378b 100644 --- a/app/lib/methods/getSettings.js +++ b/app/lib/methods/getSettings.js @@ -13,6 +13,22 @@ import fetch from '../../utils/fetch'; const serverInfoKeys = ['Site_Name', 'UI_Use_Real_Name', 'FileUpload_MediaTypeWhiteList', 'FileUpload_MaxFileSize']; +// these settings are used only on onboarding process +const loginSettings = [ + 'API_Gitlab_URL', + 'CAS_enabled', + 'CAS_login_url', + 'Accounts_EmailVerification', + 'Accounts_ManuallyApproveNewUsers', + 'Accounts_ShowFormLogin', + 'Site_Url', + 'Accounts_RegistrationForm', + 'Accounts_RegistrationForm_LinkReplacementText', + 'Accounts_EmailOrUsernamePlaceholder', + 'Accounts_PasswordPlaceholder', + 'Accounts_PasswordReset' +]; + const serverInfoUpdate = async(serverInfo, iconSetting) => { const serversDB = database.servers; const serverId = reduxStore.getState().server.server; @@ -54,7 +70,7 @@ const serverInfoUpdate = async(serverInfo, iconSetting) => { export async function getLoginSettings({ server }) { try { - const settingsParams = JSON.stringify(['Accounts_ShowFormLogin', 'Accounts_RegistrationForm']); + const settingsParams = JSON.stringify(loginSettings); const result = await fetch(`${ server }/api/v1/settings.public?query={"_id":{"$in":${ settingsParams }}}`).then(response => response.json()); if (result.success && result.settings.length) { @@ -84,7 +100,7 @@ export async function setSettings() { export default async function() { try { const db = database.active; - const settingsParams = JSON.stringify(Object.keys(settings)); + const settingsParams = JSON.stringify(Object.keys(settings).filter(key => !loginSettings.includes(key))); // RC 0.60.0 const result = await fetch(`${ this.sdk.client.host }/api/v1/settings.public?query={"_id":{"$in":${ settingsParams }}}`).then(response => response.json()); diff --git a/app/sagas/selectServer.js b/app/sagas/selectServer.js index ee2cfc7dd..ed26c4541 100644 --- a/app/sagas/selectServer.js +++ b/app/sagas/selectServer.js @@ -12,8 +12,8 @@ import * as actions from '../actions'; import { serverFailure, selectServerRequest, selectServerSuccess, selectServerFailure } from '../actions/server'; -import { setUser } from '../actions/login'; import { clearSettings } from '../actions/settings'; +import { setUser } from '../actions/login'; import RocketChat from '../lib/rocketchat'; import database from '../lib/database'; import log, { logServerVersion } from '../utils/log'; @@ -98,9 +98,8 @@ const handleSelectServer = function* handleSelectServer({ server, version, fetch const basicAuth = yield RNUserDefaults.get(`${ BASIC_AUTH_KEY }-${ server }`); setBasicAuth(basicAuth); - yield put(clearSettings()); - if (user) { + yield put(clearSettings()); yield RocketChat.connect({ server, user, logoutOnError: true }); yield put(setUser(user)); yield put(actions.appStart('inside')); From 1427e530bff6594f67af291c91919cda88d25f32 Mon Sep 17 00:00:00 2001 From: Djorkaeff Alexandre Date: Thu, 9 Apr 2020 02:27:00 -0300 Subject: [PATCH 3/9] [REGRESSION] Invite Links (#2007) Co-authored-by: Diego Mello --- app/sagas/deepLinking.js | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/app/sagas/deepLinking.js b/app/sagas/deepLinking.js index a5427ea4f..86aa2df69 100644 --- a/app/sagas/deepLinking.js +++ b/app/sagas/deepLinking.js @@ -30,19 +30,21 @@ const handleInviteLink = function* handleInviteLink({ params, requireLogin = fal const navigate = function* navigate({ params }) { yield put(appStart('inside')); if (params.path) { - const room = yield RocketChat.canOpenRoom(params); const [type, name] = params.path.split('/'); - if (room) { - yield Navigation.navigate('RoomsListView'); - Navigation.navigate('RoomView', { - name, - t: roomTypes[type], - roomUserId: RocketChat.getUidDirectMessage(room), - ...room - }); + if (type !== 'invite') { + const room = yield RocketChat.canOpenRoom(params); + if (room) { + yield Navigation.navigate('RoomsListView'); + Navigation.navigate('RoomView', { + name, + t: roomTypes[type], + roomUserId: RocketChat.getUidDirectMessage(room), + ...room + }); + } + } else { + yield handleInviteLink({ params }); } - } else { - yield handleInviteLink({ params }); } }; From 404c381ca2cfe87b20856b474a4b0fdcfa2e3b6c Mon Sep 17 00:00:00 2001 From: Djorkaeff Alexandre Date: Mon, 13 Apr 2020 09:51:16 -0300 Subject: [PATCH 4/9] [FIX] Read only channel/broadcast (#1951) * [FIX] Read only channel/broadcast * [FIX] Roles missing * [FIX] Check roles to readOnly * [FIX] Can post * [FIX] Respect post-readonly permission * [FIX] Search a room readOnly Co-authored-by: Diego Mello --- app/lib/database/index.js | 3 +- app/lib/methods/subscriptions/rooms.js | 1 + app/lib/rocketchat.js | 30 ++++++++++---- app/utils/room.js | 19 +++++++-- app/views/DirectoryView/index.js | 12 ++++-- app/views/RoomView/index.js | 55 ++++++++++++++++++++------ app/views/RoomsListView/index.js | 5 ++- app/views/ShareView/index.js | 23 ++++++++--- 8 files changed, 113 insertions(+), 35 deletions(-) diff --git a/app/lib/database/index.js b/app/lib/database/index.js index c17b18b21..67f1188ae 100644 --- a/app/lib/database/index.js +++ b/app/lib/database/index.js @@ -79,7 +79,8 @@ class DB { Message, Thread, ThreadMessage, - Upload + Upload, + Permission ], actionsEnabled: true }); diff --git a/app/lib/methods/subscriptions/rooms.js b/app/lib/methods/subscriptions/rooms.js index e954e6f14..d80f3dd84 100644 --- a/app/lib/methods/subscriptions/rooms.js +++ b/app/lib/methods/subscriptions/rooms.js @@ -72,6 +72,7 @@ const createOrUpdateSubscription = async(subscription, room) => { autoTranslate: s.autoTranslate, autoTranslateLanguage: s.autoTranslateLanguage, lastMessage: s.lastMessage, + roles: s.roles, usernames: s.usernames, uids: s.uids }; diff --git a/app/lib/rocketchat.js b/app/lib/rocketchat.js index ced274270..3f33071b5 100644 --- a/app/lib/rocketchat.js +++ b/app/lib/rocketchat.js @@ -289,14 +289,11 @@ const RocketChat = { user = { id: userRecord.id, token: userRecord.token, - username: userRecord.username + username: userRecord.username, + roles: userRecord.roles }; } - reduxStore.dispatch(shareSetUser({ - id: user.id, - token: user.token, - username: user.username - })); + reduxStore.dispatch(shareSetUser(user)); await RocketChat.login({ resume: user.token }); } catch (e) { log(e); @@ -308,6 +305,8 @@ const RocketChat = { this.shareSDK = null; } database.share = null; + + reduxStore.dispatch(shareSetUser(null)); }, updateJitsiTimeout(rid) { @@ -580,6 +579,19 @@ const RocketChat = { } data = data.slice(0, 7); + data = data.map((sub) => { + if (sub.t !== 'd') { + return ({ + rid: sub.rid, + name: sub.name, + fname: sub.fname, + t: sub.t, + search: true + }); + } + return sub; + }); + const usernames = data.map(sub => sub.name); try { if (data.length < 7) { @@ -951,7 +963,7 @@ const RocketChat = { // get the room from database const room = await subsCollection.find(rid); // get room roles - roomRoles = room.roles; + roomRoles = room.roles || []; } catch (error) { console.log('hasPermission -> Room not found'); return permissions.reduce((result, permission) => { @@ -962,8 +974,10 @@ const RocketChat = { // get permissions from database try { const permissionsFiltered = await permissionsCollection.query(Q.where('id', Q.oneOf(permissions))).fetch(); + const shareUser = reduxStore.getState().share.user; + const loginUser = reduxStore.getState().login.user; // get user roles on the server from redux - const userRoles = (reduxStore.getState().login.user && reduxStore.getState().login.user.roles) || []; + const userRoles = (shareUser.roles || loginUser.roles) || []; // merge both roles const mergedRoles = [...new Set([...roomRoles, ...userRoles])]; diff --git a/app/utils/room.js b/app/utils/room.js index 3131a6407..6a58c1e8f 100644 --- a/app/utils/room.js +++ b/app/utils/room.js @@ -1,13 +1,26 @@ import moment from 'moment'; import I18n from '../i18n'; +import RocketChat from '../lib/rocketchat'; -export const isOwner = room => room && room.roles && room.roles.length && !!room.roles.find(role => role === 'owner'); +export const canPost = async({ rid }) => { + try { + const permission = await RocketChat.hasPermission(['post-readonly'], rid); + return permission && permission['post-readonly']; + } catch { + // do nothing + } + return false; +}; export const isMuted = (room, user) => room && room.muted && room.muted.find && !!room.muted.find(m => m === user.username); -export const isReadOnly = (room, user) => { - if (isOwner(room)) { +export const isReadOnly = async(room, user) => { + if (room.archived) { + return true; + } + const allowPost = await canPost(room); + if (allowPost) { return false; } return (room && room.ro) || isMuted(room, user); diff --git a/app/views/DirectoryView/index.js b/app/views/DirectoryView/index.js index 3828a7474..180acde91 100644 --- a/app/views/DirectoryView/index.js +++ b/app/views/DirectoryView/index.js @@ -125,10 +125,14 @@ class DirectoryView extends React.Component { this.setState(({ showOptionsDropdown }) => ({ showOptionsDropdown: !showOptionsDropdown })); } - goRoom = async({ rid, name, t }) => { + goRoom = async({ + rid, name, t, search + }) => { const { navigation } = this.props; await navigation.navigate('RoomsListView'); - navigation.navigate('RoomView', { rid, name, t }); + navigation.navigate('RoomView', { + rid, name, t, search + }); } onPressItem = async(item) => { @@ -139,7 +143,9 @@ class DirectoryView extends React.Component { this.goRoom({ rid: result.room._id, name: item.username, t: 'd' }); } } else { - this.goRoom({ rid: item._id, name: item.name, t: 'c' }); + this.goRoom({ + rid: item._id, name: item.name, t: 'c', search: true + }); } } diff --git a/app/views/RoomView/index.js b/app/views/RoomView/index.js index ce34d46e8..001f33277 100644 --- a/app/views/RoomView/index.js +++ b/app/views/RoomView/index.js @@ -65,9 +65,10 @@ const stateAttrsUpdate = [ 'editing', 'replying', 'reacting', + 'readOnly', 'member' ]; -const roomAttrsUpdate = ['f', 'ro', 'blocked', 'blocker', 'archived', 'muted', 'jitsiTimeout', 'announcement', 'sysMes', 'topic', 'name', 'fname']; +const roomAttrsUpdate = ['f', 'ro', 'blocked', 'blocker', 'archived', 'muted', 'jitsiTimeout', 'announcement', 'sysMes', 'topic', 'name', 'fname', 'roles']; class RoomView extends React.Component { static navigationOptions = ({ navigation, screenProps }) => { @@ -164,6 +165,7 @@ class RoomView extends React.Component { const selectedMessage = props.navigation.getParam('message'); const name = props.navigation.getParam('name'); const fname = props.navigation.getParam('fname'); + const search = props.navigation.getParam('search'); const prid = props.navigation.getParam('prid'); this.state = { joined: true, @@ -183,7 +185,7 @@ class RoomView extends React.Component { replying: !!selectedMessage, replyWithMention: false, reacting: false, - announcement: null + readOnly: false }; if (room && room.observe) { @@ -192,6 +194,12 @@ class RoomView extends React.Component { this.findAndObserveRoom(this.rid); } + this.setReadOnly(); + + if (search) { + this.updateRoom(); + } + this.messagebox = React.createRef(); this.list = React.createRef(); this.mounted = false; @@ -278,6 +286,9 @@ class RoomView extends React.Component { if (roomUpdate.topic !== prevState.roomUpdate.topic) { navigation.setParams({ subtitle: roomUpdate.topic }); } + if (!isEqual(prevState.roomUpdate.roles, roomUpdate.roles)) { + this.setReadOnly(); + } } if (((roomUpdate.fname !== prevState.roomUpdate.fname) || (roomUpdate.name !== prevState.roomUpdate.name)) && !this.tmid) { navigation.setParams({ name: this.getRoomTitle(room) }); @@ -346,6 +357,32 @@ class RoomView extends React.Component { }); } + setReadOnly = async() => { + const { room } = this.state; + const { user } = this.props; + const readOnly = await isReadOnly(room, user); + this.setState({ readOnly }); + } + + updateRoom = async() => { + const db = database.active; + + try { + const subCollection = db.collections.get('subscriptions'); + const sub = await subCollection.find(this.rid); + + const { room } = await RocketChat.getRoomInfo(this.rid); + + await db.action(async() => { + await sub.update((s) => { + Object.assign(s, room); + }); + }); + } catch { + // do nothing + } + } + init = async() => { try { this.setState({ loading: true }); @@ -762,12 +799,6 @@ class RoomView extends React.Component { } } - get isReadOnly() { - const { room } = this.state; - const { user } = this.props; - return isReadOnly(room, user); - } - blockAction = ({ actionId, appId, value, blockId, rid, mid }) => RocketChat.triggerBlockAction({ @@ -855,7 +886,7 @@ class RoomView extends React.Component { renderFooter = () => { const { - joined, room, selectedMessage, editing, replying, replyWithMention + joined, room, selectedMessage, editing, replying, replyWithMention, readOnly } = this.state; const { navigation, theme } = this.props; @@ -876,7 +907,7 @@ class RoomView extends React.Component { ); } - if (this.isReadOnly || room.archived) { + if (readOnly) { return ( {I18n.t('This_room_is_read_only')} @@ -914,7 +945,7 @@ class RoomView extends React.Component { renderActions = () => { const { - room, selectedMessage, showActions, showErrorActions, joined + room, selectedMessage, showActions, showErrorActions, joined, readOnly } = this.state; const { user, navigation @@ -935,7 +966,7 @@ class RoomView extends React.Component { editInit={this.onEditInit} replyInit={this.onReplyInit} reactionInit={this.onReactionInit} - isReadOnly={this.isReadOnly} + isReadOnly={readOnly} /> ) : null diff --git a/app/views/RoomsListView/index.js b/app/views/RoomsListView/index.js index 84aa0027b..9cccdfc5b 100644 --- a/app/views/RoomsListView/index.js +++ b/app/views/RoomsListView/index.js @@ -542,8 +542,9 @@ class RoomsListView extends React.Component { name: this.getRoomTitle(item), t: item.t, prid: item.prid, - roomUserId: this.getUidDirectMessage(item), - room: item + room: item, + search: item.search, + roomUserId: this.getUidDirectMessage(item) }); } diff --git a/app/views/ShareView/index.js b/app/views/ShareView/index.js index f55523319..1582b3524 100644 --- a/app/views/ShareView/index.js +++ b/app/views/ShareView/index.js @@ -69,18 +69,29 @@ class ShareView extends React.Component { fileInfo, room, loading: false, + readOnly: false, file: { name: fileInfo ? fileInfo.name : '', description: '' } }; + + this.setReadOnly(); } componentDidMount() { + const { navigation } = this.props; + navigation.setParams({ sendMessage: this._sendMessage }); + } + + setReadOnly = async() => { const { room } = this.state; const { navigation, user } = this.props; const { username } = user; - navigation.setParams({ sendMessage: this._sendMessage, canSend: !(isReadOnly(room, { username }) || isBlocked(room)) }); + const readOnly = await isReadOnly(room, { username }); + + this.setState({ readOnly }); + navigation.setParams({ canSend: !(readOnly || isBlocked(room)) }); } bytesToSize = bytes => `${ (bytes / 1048576).toFixed(2) }MB`; @@ -237,8 +248,9 @@ class ShareView extends React.Component { renderError = () => { const { room } = this.state; + const { theme } = this.props; return ( - + { isBlocked(room) ? I18n.t('This_room_is_blocked') : I18n.t('This_room_is_read_only') @@ -249,13 +261,12 @@ class ShareView extends React.Component { } render() { - const { user, theme } = this.props; - const { username } = user; + const { theme } = this.props; const { - name, loading, isMedia, room + name, loading, isMedia, room, readOnly } = this.state; - if (isReadOnly(room, { username }) || isBlocked(room)) { + if (readOnly || isBlocked(room)) { return this.renderError(); } From acf70790cd739e15c455c7be859eed7b8aa1a65e Mon Sep 17 00:00:00 2001 From: Djorkaeff Alexandre Date: Mon, 13 Apr 2020 10:11:51 -0300 Subject: [PATCH 5/9] [FIX] Cas auth (#2024) Co-authored-by: Diego Mello --- app/views/AuthenticationWebView.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/views/AuthenticationWebView.js b/app/views/AuthenticationWebView.js index 28de76a37..cf169cf98 100644 --- a/app/views/AuthenticationWebView.js +++ b/app/views/AuthenticationWebView.js @@ -80,7 +80,8 @@ class AuthenticationWebView extends React.PureComponent { const { navigation } = this.props; const ssoToken = navigation.getParam('ssoToken'); const parsedUrl = parse(url, true); - if (parsedUrl.pathname?.includes('ticket') || parsedUrl.pathname?.includes('validate') || parsedUrl.query?.saml_idp_credentialToken) { + // ticket -> cas / validate & saml_idp_credentialToken -> saml + if (parsedUrl.pathname?.includes('validate') || parsedUrl.query?.ticket || parsedUrl.query?.saml_idp_credentialToken) { let payload; if (this.authType === 'saml') { const token = parsedUrl.query?.saml_idp_credentialToken || ssoToken; From 2b3ccf4df57b9479928a19de8355938ded009cf4 Mon Sep 17 00:00:00 2001 From: Djorkaeff Alexandre Date: Mon, 13 Apr 2020 10:25:31 -0300 Subject: [PATCH 6/9] [FIX] Login TOTP Compatibility to older servers (#2018) * [FIX] Login TOTP Compatibility to older servers * [FIX] Android crashes if use double negation Co-authored-by: Diego Mello --- app/containers/TwoFactor/index.js | 3 ++- app/containers/TwoFactor/styles.js | 3 ++- app/lib/rocketchat.js | 4 ++-- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/app/containers/TwoFactor/index.js b/app/containers/TwoFactor/index.js index 9d1d9daab..3d1c9fe6d 100644 --- a/app/containers/TwoFactor/index.js +++ b/app/containers/TwoFactor/index.js @@ -48,6 +48,7 @@ const TwoFactor = React.memo(({ theme, split }) => { useDeepCompareEffect(() => { if (!_.isEmpty(data)) { + setCode(''); setVisible(true); } else { setVisible(false); @@ -94,7 +95,7 @@ const TwoFactor = React.memo(({ theme, split }) => { {I18n.t(method?.title || 'Two_Factor_Authentication')} - {I18n.t(method?.text)} + {method?.text ? {I18n.t(method.text)} : null} Date: Mon, 13 Apr 2020 10:26:59 -0300 Subject: [PATCH 7/9] Bump version to 4.6.4 (#2029) Co-authored-by: Diego Mello --- android/app/build.gradle | 2 +- ios/RocketChatRN/Info.plist | 2 +- ios/ShareRocketChatRN/Info.plist | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/android/app/build.gradle b/android/app/build.gradle index 8a335c4e2..89bd6bbdb 100644 --- a/android/app/build.gradle +++ b/android/app/build.gradle @@ -138,7 +138,7 @@ android { minSdkVersion rootProject.ext.minSdkVersion targetSdkVersion rootProject.ext.targetSdkVersion versionCode VERSIONCODE as Integer - versionName "4.6.1" + versionName "4.6.4" vectorDrawables.useSupportLibrary = true manifestPlaceholders = [BugsnagAPIKey: BugsnagAPIKey as String] } diff --git a/ios/RocketChatRN/Info.plist b/ios/RocketChatRN/Info.plist index 018499f57..14d5d2666 100644 --- a/ios/RocketChatRN/Info.plist +++ b/ios/RocketChatRN/Info.plist @@ -19,7 +19,7 @@ CFBundlePackageType APPL CFBundleShortVersionString - 4.6.1 + 4.6.4 CFBundleSignature ???? CFBundleURLTypes diff --git a/ios/ShareRocketChatRN/Info.plist b/ios/ShareRocketChatRN/Info.plist index 676d0c728..3a866bf68 100644 --- a/ios/ShareRocketChatRN/Info.plist +++ b/ios/ShareRocketChatRN/Info.plist @@ -17,7 +17,7 @@ CFBundlePackageType XPC! CFBundleShortVersionString - 4.6.1 + 4.6.4 CFBundleVersion 1 NSAppTransportSecurity From 8445bafad61ffc5751187e505c257543a694b15c Mon Sep 17 00:00:00 2001 From: Djorkaeff Alexandre Date: Mon, 13 Apr 2020 10:56:30 -0300 Subject: [PATCH 8/9] [FIX] Lint (#2030) --- app/utils/isReadOnly.js | 24 ++++++++++++++++++++++++ app/utils/room.js | 24 ------------------------ app/views/RoomView/index.js | 3 ++- app/views/ShareView/index.js | 3 ++- 4 files changed, 28 insertions(+), 26 deletions(-) create mode 100644 app/utils/isReadOnly.js diff --git a/app/utils/isReadOnly.js b/app/utils/isReadOnly.js new file mode 100644 index 000000000..8a6f9c36f --- /dev/null +++ b/app/utils/isReadOnly.js @@ -0,0 +1,24 @@ +import RocketChat from '../lib/rocketchat'; + +const canPost = async({ rid }) => { + try { + const permission = await RocketChat.hasPermission(['post-readonly'], rid); + return permission && permission['post-readonly']; + } catch { + // do nothing + } + return false; +}; + +const isMuted = (room, user) => room && room.muted && room.muted.find && !!room.muted.find(m => m === user.username); + +export const isReadOnly = async(room, user) => { + if (room.archived) { + return true; + } + const allowPost = await canPost(room); + if (allowPost) { + return false; + } + return (room && room.ro) || isMuted(room, user); +}; diff --git a/app/utils/room.js b/app/utils/room.js index 6a58c1e8f..4775fa757 100644 --- a/app/utils/room.js +++ b/app/utils/room.js @@ -1,30 +1,6 @@ import moment from 'moment'; import I18n from '../i18n'; -import RocketChat from '../lib/rocketchat'; - -export const canPost = async({ rid }) => { - try { - const permission = await RocketChat.hasPermission(['post-readonly'], rid); - return permission && permission['post-readonly']; - } catch { - // do nothing - } - return false; -}; - -export const isMuted = (room, user) => room && room.muted && room.muted.find && !!room.muted.find(m => m === user.username); - -export const isReadOnly = async(room, user) => { - if (room.archived) { - return true; - } - const allowPost = await canPost(room); - if (allowPost) { - return false; - } - return (room && room.ro) || isMuted(room, user); -}; export const isBlocked = (room) => { if (room) { diff --git a/app/views/RoomView/index.js b/app/views/RoomView/index.js index 001f33277..341df6ce6 100644 --- a/app/views/RoomView/index.js +++ b/app/views/RoomView/index.js @@ -34,7 +34,8 @@ import { themes } from '../../constants/colors'; import debounce from '../../utils/debounce'; import ReactionsModal from '../../containers/ReactionsModal'; import { LISTENER } from '../../containers/Toast'; -import { isReadOnly, isBlocked } from '../../utils/room'; +import { isBlocked } from '../../utils/room'; +import { isReadOnly } from '../../utils/isReadOnly'; import { isIOS, isTablet } from '../../utils/deviceInfo'; import { showErrorAlert } from '../../utils/info'; import { withTheme } from '../../theme'; diff --git a/app/views/ShareView/index.js b/app/views/ShareView/index.js index 1582b3524..84889d272 100644 --- a/app/views/ShareView/index.js +++ b/app/views/ShareView/index.js @@ -13,7 +13,8 @@ import styles from './styles'; import TextInput from '../../containers/TextInput'; import ActivityIndicator from '../../containers/ActivityIndicator'; import { CustomHeaderButtons, Item } from '../../containers/HeaderButton'; -import { isReadOnly, isBlocked } from '../../utils/room'; +import { isBlocked } from '../../utils/room'; +import { isReadOnly } from '../../utils/isReadOnly'; import { withTheme } from '../../theme'; import { themedHeader } from '../../utils/navigation'; From 91ff6e48d5958b4d3bec7bc209d1aaabac7484f5 Mon Sep 17 00:00:00 2001 From: Djorkaeff Alexandre Date: Mon, 13 Apr 2020 10:56:57 -0300 Subject: [PATCH 9/9] [FIX] UIKit with only one block (#2022) * [FIX] Message with only one block * [FIX] Update headers Co-authored-by: Diego Mello --- app/containers/message/Blocks.js | 3 +-- app/views/ModalBlockView.js | 12 +++++++----- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/app/containers/message/Blocks.js b/app/containers/message/Blocks.js index 76a5e273f..ba74ebe20 100644 --- a/app/containers/message/Blocks.js +++ b/app/containers/message/Blocks.js @@ -6,8 +6,7 @@ const Blocks = React.memo(({ blocks, id: mid, rid, blockAction }) => { if (blocks && blocks.length > 0) { - const [, secondBlock] = blocks; - const { appId = '' } = secondBlock; + const appId = blocks[0]?.appId || ''; return React.createElement( messageBlockWithContext({ action: async({ actionId, value, blockId }) => { diff --git a/app/views/ModalBlockView.js b/app/views/ModalBlockView.js index e00c84931..3c6314e2b 100644 --- a/app/views/ModalBlockView.js +++ b/app/views/ModalBlockView.js @@ -67,7 +67,7 @@ class ModalBlockView extends React.Component { return { title: textParser([title]), ...themedHeader(theme), - headerLeft: ( + headerLeft: close ? ( - ), - headerRight: ( + ) : null, + headerRight: submit ? ( - ) + ) : null }; } @@ -136,7 +136,7 @@ class ModalBlockView extends React.Component { const { navigation } = this.props; const oldData = prevProps.navigation.getParam('data', {}); const newData = navigation.getParam('data', {}); - if (!isEqual(oldData, newData)) { + if (oldData.viewId !== newData.viewId) { navigation.push('ModalBlockView', { data: newData }); } } @@ -148,12 +148,14 @@ class ModalBlockView extends React.Component { } handleUpdate = ({ type, ...data }) => { + const { navigation } = this.props; if ([MODAL_ACTIONS.ERRORS].includes(type)) { const { errors } = data; this.setState({ errors }); } else { this.setState({ data }); } + navigation.setParams({ data }); }; cancel = async({ closeModal }) => {