Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FIX] Unarchive permission not honored #3237

Merged
merged 10 commits into from
Aug 16, 2021
12 changes: 5 additions & 7 deletions app/views/RoomInfoEditView/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ import { MessageTypeValues } from '../../utils/messageTypes';
import SafeAreaView from '../../containers/SafeAreaView';
import Avatar from '../../containers/Avatar';
import { CustomIcon } from '../../lib/Icons';
import i18nEnJson from '../../i18n/locales/en.json';

const PERMISSION_SET_READONLY = 'set-readonly';
const PERMISSION_SET_REACT_WHEN_READONLY = 'set-react-when-readonly';
Expand Down Expand Up @@ -393,6 +394,8 @@ class RoomInfoEditView extends React.Component {
} catch (e) {
logEvent(events.RI_EDIT_TOGGLE_ARCHIVE_F);
log(e);
const errorType = e?.data?.errorType || e?.data?.error;
showErrorAlert(i18nEnJson[errorType] ? I18n.t(errorType) : errorType);
}
}
}
Expand All @@ -415,11 +418,6 @@ class RoomInfoEditView extends React.Component {
return permissions[PERMISSION_DELETE_C];
}

hasArchivePermission = () => {
const { permissions } = this.state;
return (permissions[PERMISSION_ARCHIVE] || permissions[PERMISSION_UNARCHIVE]);
};

renderSystemMessages = () => {
const { systemMessages, enableSysMes } = this.state;
const { theme } = this.props;
Expand Down Expand Up @@ -691,11 +689,11 @@ class RoomInfoEditView extends React.Component {
style={[
styles.buttonInverted,
styles.buttonContainer_inverted,
!this.hasArchivePermission() && sharedStyles.opacity5,
archived ? !permissions[PERMISSION_UNARCHIVE] && sharedStyles.opacity5 : !permissions[PERMISSION_ARCHIVE] && sharedStyles.opacity5,
{ flex: 1, marginLeft: 10, borderColor: dangerColor }
]}
onPress={this.toggleArchive}
disabled={!this.hasArchivePermission()}
disabled={archived ? !permissions[PERMISSION_UNARCHIVE] : !permissions[PERMISSION_ARCHIVE]}
testID={archived ? 'room-info-edit-view-unarchive' : 'room-info-edit-view-archive'}
>
<Text
Expand Down