[NEW] Hide system messages (#1755)
Co-authored-by: Diego Mello <diegolmello@gmail.com>
This commit is contained in:
parent
bfc4e8d127
commit
7a4dfef533
|
@ -50,6 +50,9 @@ export default {
|
|||
FEDERATION_Enabled: {
|
||||
type: 'valueAsBoolean'
|
||||
},
|
||||
Hide_System_Messages: {
|
||||
type: 'valueAsArray'
|
||||
},
|
||||
LDAP_Enable: {
|
||||
type: 'valueAsBoolean'
|
||||
},
|
||||
|
@ -120,7 +123,7 @@ export default {
|
|||
type: 'valueAsBoolean'
|
||||
},
|
||||
Threads_enabled: {
|
||||
type: null
|
||||
type: 'valueAsBoolean'
|
||||
},
|
||||
FileUpload_MediaTypeWhiteList: {
|
||||
type: 'valueAsString'
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
import { Model } from '@nozbe/watermelondb';
|
||||
import { field, date } from '@nozbe/watermelondb/decorators';
|
||||
import { field, date, json } from '@nozbe/watermelondb/decorators';
|
||||
|
||||
import { sanitizer } from '../utils';
|
||||
|
||||
export default class Setting extends Model {
|
||||
static table = 'settings';
|
||||
|
@ -10,5 +12,7 @@ export default class Setting extends Model {
|
|||
|
||||
@field('value_as_number') valueAsNumber;
|
||||
|
||||
@json('value_as_array', sanitizer) valueAsArray;
|
||||
|
||||
@date('_updated_at') _updatedAt;
|
||||
}
|
||||
|
|
|
@ -40,6 +40,17 @@ export default schemaMigrations({
|
|||
]
|
||||
})
|
||||
]
|
||||
},
|
||||
{
|
||||
toVersion: 5,
|
||||
steps: [
|
||||
addColumns({
|
||||
table: 'settings',
|
||||
columns: [
|
||||
{ name: 'value_as_array', type: 'string', isOptional: true }
|
||||
]
|
||||
})
|
||||
]
|
||||
}
|
||||
]
|
||||
});
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import { appSchema, tableSchema } from '@nozbe/watermelondb';
|
||||
|
||||
export default appSchema({
|
||||
version: 4,
|
||||
version: 5,
|
||||
tables: [
|
||||
tableSchema({
|
||||
name: 'subscriptions',
|
||||
|
@ -196,6 +196,7 @@ export default appSchema({
|
|||
{ name: 'value_as_string', type: 'string', isOptional: true },
|
||||
{ name: 'value_as_boolean', type: 'boolean', isOptional: true },
|
||||
{ name: 'value_as_number', type: 'number', isOptional: true },
|
||||
{ name: 'value_as_array', type: 'string', isOptional: true },
|
||||
{ name: '_updated_at', type: 'number', isOptional: true }
|
||||
]
|
||||
}),
|
||||
|
|
|
@ -78,6 +78,7 @@ export async function setSettings() {
|
|||
valueAsString: item.valueAsString,
|
||||
valueAsBoolean: item.valueAsBoolean,
|
||||
valueAsNumber: item.valueAsNumber,
|
||||
valueAsArray: item.valueAsArray,
|
||||
_updatedAt: item._updatedAt
|
||||
}));
|
||||
reduxStore.dispatch(actions.setAllSettings(RocketChat.parseSettings(parsed.slice(0, parsed.length))));
|
||||
|
|
|
@ -629,6 +629,10 @@ const RocketChat = {
|
|||
getRoles,
|
||||
parseSettings: settings => settings.reduce((ret, item) => {
|
||||
ret[item._id] = item[defaultSettings[item._id].type];
|
||||
if (item._id === 'Hide_System_Messages') {
|
||||
ret[item._id] = ret[item._id]
|
||||
.reduce((array, value) => [...array, ...value === 'mute_unmute' ? ['user-muted', 'user-unmuted'] : [value]], []);
|
||||
}
|
||||
return ret;
|
||||
}, {}),
|
||||
_prepareSettings(settings) {
|
||||
|
|
|
@ -27,6 +27,7 @@ class List extends React.Component {
|
|||
tmid: PropTypes.string,
|
||||
theme: PropTypes.string,
|
||||
listRef: PropTypes.func,
|
||||
hideSystemMessages: PropTypes.array,
|
||||
navigation: PropTypes.object
|
||||
};
|
||||
|
||||
|
@ -61,7 +62,7 @@ class List extends React.Component {
|
|||
|
||||
// eslint-disable-next-line react/sort-comp
|
||||
async init() {
|
||||
const { rid, tmid } = this.props;
|
||||
const { rid, tmid, hideSystemMessages = [] } = this.props;
|
||||
const db = database.active;
|
||||
|
||||
if (tmid) {
|
||||
|
@ -74,12 +75,12 @@ class List extends React.Component {
|
|||
}
|
||||
this.messagesObservable = db.collections
|
||||
.get('thread_messages')
|
||||
.query(Q.where('rid', tmid))
|
||||
.query(Q.where('rid', tmid), Q.or(Q.where('t', Q.notIn(hideSystemMessages)), Q.where('t', Q.eq(null))))
|
||||
.observe();
|
||||
} else if (rid) {
|
||||
this.messagesObservable = db.collections
|
||||
.get('messages')
|
||||
.query(Q.where('rid', rid))
|
||||
.query(Q.where('rid', rid), Q.or(Q.where('t', Q.notIn(hideSystemMessages)), Q.where('t', Q.eq(null))))
|
||||
.observe();
|
||||
}
|
||||
|
||||
|
|
|
@ -142,6 +142,7 @@ class RoomView extends React.Component {
|
|||
Message_GroupingPeriod: PropTypes.number,
|
||||
Message_TimeFormat: PropTypes.string,
|
||||
Message_Read_Receipt_Enabled: PropTypes.bool,
|
||||
Hide_System_Messages: PropTypes.array,
|
||||
baseUrl: PropTypes.string,
|
||||
customEmojis: PropTypes.object,
|
||||
screenProps: PropTypes.object,
|
||||
|
@ -943,7 +944,7 @@ class RoomView extends React.Component {
|
|||
room, reactionsModalVisible, selectedMessage, loading, reacting
|
||||
} = this.state;
|
||||
const {
|
||||
user, baseUrl, theme, navigation
|
||||
user, baseUrl, theme, navigation, Hide_System_Messages
|
||||
} = this.props;
|
||||
const { rid, t } = room;
|
||||
|
||||
|
@ -969,6 +970,7 @@ class RoomView extends React.Component {
|
|||
renderRow={this.renderItem}
|
||||
loading={loading}
|
||||
navigation={navigation}
|
||||
hideSystemMessages={Hide_System_Messages}
|
||||
/>
|
||||
{this.renderAnnouncementModal()}
|
||||
{this.renderFooter()}
|
||||
|
@ -1003,7 +1005,8 @@ const mapStateToProps = state => ({
|
|||
useMarkdown: state.markdown.useMarkdown,
|
||||
customEmojis: state.customEmojis,
|
||||
baseUrl: state.server.server,
|
||||
Message_Read_Receipt_Enabled: state.settings.Message_Read_Receipt_Enabled
|
||||
Message_Read_Receipt_Enabled: state.settings.Message_Read_Receipt_Enabled,
|
||||
Hide_System_Messages: state.settings.Hide_System_Messages
|
||||
});
|
||||
|
||||
const mapDispatchToProps = dispatch => ({
|
||||
|
|
Loading…
Reference in New Issue