[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: {
|
FEDERATION_Enabled: {
|
||||||
type: 'valueAsBoolean'
|
type: 'valueAsBoolean'
|
||||||
},
|
},
|
||||||
|
Hide_System_Messages: {
|
||||||
|
type: 'valueAsArray'
|
||||||
|
},
|
||||||
LDAP_Enable: {
|
LDAP_Enable: {
|
||||||
type: 'valueAsBoolean'
|
type: 'valueAsBoolean'
|
||||||
},
|
},
|
||||||
|
@ -120,7 +123,7 @@ export default {
|
||||||
type: 'valueAsBoolean'
|
type: 'valueAsBoolean'
|
||||||
},
|
},
|
||||||
Threads_enabled: {
|
Threads_enabled: {
|
||||||
type: null
|
type: 'valueAsBoolean'
|
||||||
},
|
},
|
||||||
FileUpload_MediaTypeWhiteList: {
|
FileUpload_MediaTypeWhiteList: {
|
||||||
type: 'valueAsString'
|
type: 'valueAsString'
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
import { Model } from '@nozbe/watermelondb';
|
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 {
|
export default class Setting extends Model {
|
||||||
static table = 'settings';
|
static table = 'settings';
|
||||||
|
@ -10,5 +12,7 @@ export default class Setting extends Model {
|
||||||
|
|
||||||
@field('value_as_number') valueAsNumber;
|
@field('value_as_number') valueAsNumber;
|
||||||
|
|
||||||
|
@json('value_as_array', sanitizer) valueAsArray;
|
||||||
|
|
||||||
@date('_updated_at') _updatedAt;
|
@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';
|
import { appSchema, tableSchema } from '@nozbe/watermelondb';
|
||||||
|
|
||||||
export default appSchema({
|
export default appSchema({
|
||||||
version: 4,
|
version: 5,
|
||||||
tables: [
|
tables: [
|
||||||
tableSchema({
|
tableSchema({
|
||||||
name: 'subscriptions',
|
name: 'subscriptions',
|
||||||
|
@ -196,6 +196,7 @@ export default appSchema({
|
||||||
{ name: 'value_as_string', type: 'string', isOptional: true },
|
{ name: 'value_as_string', type: 'string', isOptional: true },
|
||||||
{ name: 'value_as_boolean', type: 'boolean', isOptional: true },
|
{ name: 'value_as_boolean', type: 'boolean', isOptional: true },
|
||||||
{ name: 'value_as_number', type: 'number', 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 }
|
{ name: '_updated_at', type: 'number', isOptional: true }
|
||||||
]
|
]
|
||||||
}),
|
}),
|
||||||
|
|
|
@ -78,6 +78,7 @@ export async function setSettings() {
|
||||||
valueAsString: item.valueAsString,
|
valueAsString: item.valueAsString,
|
||||||
valueAsBoolean: item.valueAsBoolean,
|
valueAsBoolean: item.valueAsBoolean,
|
||||||
valueAsNumber: item.valueAsNumber,
|
valueAsNumber: item.valueAsNumber,
|
||||||
|
valueAsArray: item.valueAsArray,
|
||||||
_updatedAt: item._updatedAt
|
_updatedAt: item._updatedAt
|
||||||
}));
|
}));
|
||||||
reduxStore.dispatch(actions.setAllSettings(RocketChat.parseSettings(parsed.slice(0, parsed.length))));
|
reduxStore.dispatch(actions.setAllSettings(RocketChat.parseSettings(parsed.slice(0, parsed.length))));
|
||||||
|
|
|
@ -629,6 +629,10 @@ const RocketChat = {
|
||||||
getRoles,
|
getRoles,
|
||||||
parseSettings: settings => settings.reduce((ret, item) => {
|
parseSettings: settings => settings.reduce((ret, item) => {
|
||||||
ret[item._id] = item[defaultSettings[item._id].type];
|
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;
|
return ret;
|
||||||
}, {}),
|
}, {}),
|
||||||
_prepareSettings(settings) {
|
_prepareSettings(settings) {
|
||||||
|
|
|
@ -27,6 +27,7 @@ class List extends React.Component {
|
||||||
tmid: PropTypes.string,
|
tmid: PropTypes.string,
|
||||||
theme: PropTypes.string,
|
theme: PropTypes.string,
|
||||||
listRef: PropTypes.func,
|
listRef: PropTypes.func,
|
||||||
|
hideSystemMessages: PropTypes.array,
|
||||||
navigation: PropTypes.object
|
navigation: PropTypes.object
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -61,7 +62,7 @@ class List extends React.Component {
|
||||||
|
|
||||||
// eslint-disable-next-line react/sort-comp
|
// eslint-disable-next-line react/sort-comp
|
||||||
async init() {
|
async init() {
|
||||||
const { rid, tmid } = this.props;
|
const { rid, tmid, hideSystemMessages = [] } = this.props;
|
||||||
const db = database.active;
|
const db = database.active;
|
||||||
|
|
||||||
if (tmid) {
|
if (tmid) {
|
||||||
|
@ -74,12 +75,12 @@ class List extends React.Component {
|
||||||
}
|
}
|
||||||
this.messagesObservable = db.collections
|
this.messagesObservable = db.collections
|
||||||
.get('thread_messages')
|
.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();
|
.observe();
|
||||||
} else if (rid) {
|
} else if (rid) {
|
||||||
this.messagesObservable = db.collections
|
this.messagesObservable = db.collections
|
||||||
.get('messages')
|
.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();
|
.observe();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -142,6 +142,7 @@ class RoomView extends React.Component {
|
||||||
Message_GroupingPeriod: PropTypes.number,
|
Message_GroupingPeriod: PropTypes.number,
|
||||||
Message_TimeFormat: PropTypes.string,
|
Message_TimeFormat: PropTypes.string,
|
||||||
Message_Read_Receipt_Enabled: PropTypes.bool,
|
Message_Read_Receipt_Enabled: PropTypes.bool,
|
||||||
|
Hide_System_Messages: PropTypes.array,
|
||||||
baseUrl: PropTypes.string,
|
baseUrl: PropTypes.string,
|
||||||
customEmojis: PropTypes.object,
|
customEmojis: PropTypes.object,
|
||||||
screenProps: PropTypes.object,
|
screenProps: PropTypes.object,
|
||||||
|
@ -943,7 +944,7 @@ class RoomView extends React.Component {
|
||||||
room, reactionsModalVisible, selectedMessage, loading, reacting
|
room, reactionsModalVisible, selectedMessage, loading, reacting
|
||||||
} = this.state;
|
} = this.state;
|
||||||
const {
|
const {
|
||||||
user, baseUrl, theme, navigation
|
user, baseUrl, theme, navigation, Hide_System_Messages
|
||||||
} = this.props;
|
} = this.props;
|
||||||
const { rid, t } = room;
|
const { rid, t } = room;
|
||||||
|
|
||||||
|
@ -969,6 +970,7 @@ class RoomView extends React.Component {
|
||||||
renderRow={this.renderItem}
|
renderRow={this.renderItem}
|
||||||
loading={loading}
|
loading={loading}
|
||||||
navigation={navigation}
|
navigation={navigation}
|
||||||
|
hideSystemMessages={Hide_System_Messages}
|
||||||
/>
|
/>
|
||||||
{this.renderAnnouncementModal()}
|
{this.renderAnnouncementModal()}
|
||||||
{this.renderFooter()}
|
{this.renderFooter()}
|
||||||
|
@ -1003,7 +1005,8 @@ const mapStateToProps = state => ({
|
||||||
useMarkdown: state.markdown.useMarkdown,
|
useMarkdown: state.markdown.useMarkdown,
|
||||||
customEmojis: state.customEmojis,
|
customEmojis: state.customEmojis,
|
||||||
baseUrl: state.server.server,
|
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 => ({
|
const mapDispatchToProps = dispatch => ({
|
||||||
|
|
Loading…
Reference in New Issue