[FIX] Lint (#2030)

This commit is contained in:
Djorkaeff Alexandre 2020-04-13 10:56:30 -03:00 committed by GitHub
parent a7641c19e2
commit 8445bafad6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 28 additions and 26 deletions

24
app/utils/isReadOnly.js Normal file
View File

@ -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);
};

View File

@ -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) {

View File

@ -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';

View File

@ -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';