Commit be717ca3 authored by diegolmello's avatar diegolmello

Fix jest

parent 43f27374
......@@ -15,8 +15,6 @@ import UnreadBadge from './UnreadBadge';
import TypeIcon from './TypeIcon';
import LastMessage from './LastMessage';
import { CustomIcon } from '../../lib/Icons';
import RocketChat from '../../lib/rocketchat';
import log from '../../utils/log';
export { ROW_HEIGHT };
......@@ -48,7 +46,9 @@ export default class RoomItem extends React.Component {
height: PropTypes.number,
favorite: PropTypes.bool,
isRead: PropTypes.bool,
rid: PropTypes.string
rid: PropTypes.string,
toggleFav: PropTypes.func,
toggleRead: PropTypes.func
}
static defaultProps = {
......@@ -83,22 +83,18 @@ export default class RoomItem extends React.Component {
this.swipeableRow.close();
};
toggleFav = async() => {
try {
const { rid, favorite } = this.props;
await RocketChat.toggleFavorite(rid, !favorite);
} catch (e) {
log('error_toggle_favorite', e);
toggleFav = () => {
const { toggleFav, rid, favorite } = this.props;
if (toggleFav) {
toggleFav(rid, favorite);
}
this.close();
}
toggleRead = async() => {
try {
const { rid, isRead } = this.props;
await RocketChat.toggleRead(isRead, rid);
} catch (e) {
log('error_toggle_read', e);
toggleRead = () => {
const { toggleRead, rid, isRead } = this.props;
if (toggleRead) {
toggleRead(rid, isRead);
}
this.close();
}
......
......@@ -381,6 +381,22 @@ export default class RoomsListView extends React.Component {
}, 100);
}
toggleFav = async(rid, favorite) => {
try {
await RocketChat.toggleFavorite(rid, !favorite);
} catch (e) {
log('error_toggle_favorite', e);
}
}
toggleRead = async(rid, isRead) => {
try {
await RocketChat.toggleRead(isRead, rid);
} catch (e) {
log('error_toggle_read', e);
}
}
goDirectory = () => {
const { navigation } = this.props;
navigation.navigate('DirectoryView');
......@@ -429,6 +445,8 @@ export default class RoomsListView extends React.Component {
onPress={() => this._onPressItem(item)}
testID={`rooms-list-view-item-${ item.name }`}
height={ROW_HEIGHT}
toggleFav={this.toggleFav}
toggleRead={this.toggleRead}
/>
);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment