Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
this.setState({ loading: true });
const {
sortBy,
showUnread,
showFavorites,
groupByType
} = this.props;
const db = database.active;
const observable = await db.collections
.get('subscriptions')
.query(
Q.where('archived', false),
Q.where('open', true),
Q.where('t', Q.notEq('l'))
)
.observeWithColumns(['room_updated_at', 'unread', 'alert', 'user_mentions', 'f', 't']);
this.querySubscription = observable.subscribe((data) => {
let tempChats = [];
let chats = [];
if (sortBy === 'alphabetical') {
chats = orderBy(data, ['name'], ['asc']);
} else {
chats = orderBy(data, ['roomUpdatedAt'], ['desc']);
}
// it's better to map and test all subs altogether then testing them individually
const allChats = data.map(item => ({
alert: item.alert,
unread: item.unread,