[IMPROVEMENT] Respect "Hide counter" preference (#1306)

This commit is contained in:
Calebe Rios 2019-10-28 17:04:44 -03:00 committed by Diego Mello
parent 8bffe1f28c
commit 20a73907ff
5 changed files with 25 additions and 9 deletions

View File

@ -87,4 +87,6 @@ export default class Subscription extends Model {
@children('threads') threads;
@children('thread_messages') threadMessages;
@field('hide_unread_status') hideUnreadStatus;
}

View File

@ -12,6 +12,17 @@ export default schemaMigrations({
]
})
]
},
{
toVersion: 3,
steps: [
addColumns({
table: 'subscriptions',
columns: [
{ name: 'hide_unread_status', type: 'boolean', isOptional: true }
]
})
]
}
]
});

View File

@ -1,7 +1,7 @@
import { appSchema, tableSchema } from '@nozbe/watermelondb';
export default appSchema({
version: 2,
version: 3,
tables: [
tableSchema({
name: 'subscriptions',
@ -38,7 +38,8 @@ export default appSchema({
{ name: 'last_thread_sync', type: 'number', isOptional: true },
{ name: 'jitsi_timeout', type: 'number', isOptional: true },
{ name: 'auto_translate', type: 'boolean', isOptional: true },
{ name: 'auto_translate_language', type: 'string' }
{ name: 'auto_translate_language', type: 'string' },
{ name: 'hide_unread_status', type: 'boolean', isOptional: true }
]
}),
tableSchema({

View File

@ -64,7 +64,8 @@ class RoomItem extends React.Component {
toggleFav: PropTypes.func,
toggleRead: PropTypes.func,
hideChannel: PropTypes.func,
avatar: PropTypes.bool
avatar: PropTypes.bool,
hideUnreadStatus: PropTypes.bool
}
static defaultProps = {
@ -218,7 +219,7 @@ class RoomItem extends React.Component {
render() {
const {
unread, userMentions, name, _updatedAt, alert, testID, type, avatarSize, baseUrl, userId, username, token, id, prid, showLastMessage, lastMessage, isRead, width, favorite, status, avatar
unread, userMentions, name, _updatedAt, alert, testID, type, avatarSize, baseUrl, userId, username, token, id, prid, showLastMessage, lastMessage, isRead, width, favorite, status, avatar, hideUnreadStatus
} = this.props;
const date = formatDate(_updatedAt);
@ -294,7 +295,7 @@ class RoomItem extends React.Component {
<Text
style={[
styles.title,
alert && styles.alert
alert && !hideUnreadStatus && styles.alert
]}
ellipsizeMode='tail'
numberOfLines={1}
@ -305,7 +306,7 @@ class RoomItem extends React.Component {
<Text
style={[
styles.date,
alert && styles.updateAlert
alert && !hideUnreadStatus && styles.updateAlert
]}
ellipsizeMode='tail'
numberOfLines={1}
@ -320,7 +321,7 @@ class RoomItem extends React.Component {
type={type}
showLastMessage={showLastMessage}
username={username}
alert={alert}
alert={alert && !hideUnreadStatus}
/>
<UnreadBadge
unread={unread}

View File

@ -372,7 +372,7 @@ class RoomsListView extends React.Component {
// unread
if (showUnread) {
unread = chats.filter(s => s.unread > 0 || s.alert);
unread = chats.filter(s => (s.unread > 0 || s.alert) && !s.hideUnreadStatus);
} else {
unread = [];
}
@ -391,7 +391,7 @@ class RoomsListView extends React.Component {
privateGroup = chats.filter(s => s.t === 'p' && !s.prid);
direct = chats.filter(s => s.t === 'd' && !s.prid);
} else if (showUnread) {
chats = chats.filter(s => !s.unread && !s.alert);
chats = chats.filter(s => (!s.unread && !s.alert) || s.hideUnreadStatus);
}
this.internalSetState({
@ -606,6 +606,7 @@ class RoomsListView extends React.Component {
<RoomItem
alert={item.alert}
unread={item.unread}
hideUnreadStatus={item.hideUnreadStatus}
userMentions={item.userMentions}
isRead={this.getIsRead(item)}
favorite={item.f}