Skip to content

Commit

Permalink
Add config options for presence & join/leave message visibility
Browse files Browse the repository at this point in the history
  • Loading branch information
vp8x8 authored and saghul committed Jan 22, 2020
1 parent 45aafe5 commit ad68a87
Show file tree
Hide file tree
Showing 6 changed files with 52 additions and 17 deletions.
8 changes: 7 additions & 1 deletion interface_config.js
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,13 @@ var interfaceConfig = {
/**
* If we should capture periodic screenshots of the content sharing.
*/
ENABLE_SCREENSHOT_CAPTURE: false
ENABLE_SCREENSHOT_CAPTURE: false,

// If true, presence status: busy, calling, connected etc. is not displayed
DISABLE_PRESENCE_STATUS: false,

// If true, notifications regarding joining/leaving are no longer displayed
DISABLE_JOIN_LEAVE_NOTIFICATIONS: false

/**
* How many columns the tile view can expand to. The respected range is
Expand Down
2 changes: 2 additions & 0 deletions react/features/base/config/interfaceConfigWhitelist.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ export default [
'CONNECTION_INDICATOR_AUTO_HIDE_TIMEOUT',
'CONNECTION_INDICATOR_DISABLED',
'DEFAULT_BACKGROUND',
'DISABLE_PRESENCE_STATUS',
'DISABLE_JOIN_LEAVE_NOTIFICATIONS',
'DEFAULT_LOCAL_DISPLAY_NAME',
'DEFAULT_REMOTE_DISPLAY_NAME',
'DISABLE_DOMINANT_SPEAKER_INDICATOR',
Expand Down
11 changes: 11 additions & 0 deletions react/features/notifications/functions.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

import { toState } from '../base/redux';

declare var interfaceConfig: Object;

/**
* Tells whether or not the notifications are enabled and if there are any
* notifications to be displayed based on the current Redux state.
Expand All @@ -15,3 +17,12 @@ export function areThereNotifications(stateful: Object | Function) {

return enabled && notifications.length > 0;
}

/**
* Tells wether join/leave notifications are enabled in interface_config.
*
* @returns {boolean}
*/
export function joinLeaveNotificationsDisabled() {
return Boolean(interfaceConfig?.DISABLE_JOIN_LEAVE_NOTIFICATIONS);
}
30 changes: 16 additions & 14 deletions react/features/notifications/middleware.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import {
showParticipantJoinedNotification
} from './actions';
import { NOTIFICATION_TIMEOUT } from './constants';
import { joinLeaveNotificationsDisabled } from './functions';

declare var interfaceConfig: Object;

Expand All @@ -31,7 +32,7 @@ MiddlewareRegistry.register(store => next => action => {

const { participant: p } = action;

if (!p.local) {
if (!p.local && !joinLeaveNotificationsDisabled()) {
store.dispatch(showParticipantJoinedNotification(
getParticipantDisplayName(store.getState, p.id)
));
Expand All @@ -40,20 +41,21 @@ MiddlewareRegistry.register(store => next => action => {
return result;
}
case PARTICIPANT_LEFT: {
const participant = getParticipantById(
store.getState(),
action.participant.id
);
if (!joinLeaveNotificationsDisabled()) {
const participant = getParticipantById(
store.getState(),
action.participant.id
);

if (typeof interfaceConfig === 'object'
&& participant
&& !participant.local) {
store.dispatch(showNotification({
descriptionKey: 'notify.disconnected',
titleKey: 'notify.somebody',
title: participant.name
},
NOTIFICATION_TIMEOUT));
if (typeof interfaceConfig === 'object'
&& participant
&& !participant.local) {
store.dispatch(showNotification({
descriptionKey: 'notify.disconnected',
titleKey: 'notify.somebody',
title: participant.name
}, NOTIFICATION_TIMEOUT));
}
}

return next(action);
Expand Down
6 changes: 4 additions & 2 deletions react/features/presence-status/components/PresenceLabel.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { Text } from '../../base/react';
import { connect } from '../../base/redux';

import { STATUS_TO_I18N_KEY } from '../constants';
import { presenceStatusDisabled } from '../functions';

/**
* The type of the React {@code Component} props of {@link PresenceLabel}.
Expand Down Expand Up @@ -124,8 +125,9 @@ function _mapStateToProps(state, ownProps) {
const participant = getParticipantById(state, ownProps.participantID);

return {
_presence:
(participant && participant.presence) || ownProps.defaultPresence
_presence: presenceStatusDisabled() ? ''
: participant?.presence || ownProps.defaultPresence

};
}

Expand Down
12 changes: 12 additions & 0 deletions react/features/presence-status/functions.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
// @flow

declare var interfaceConfig: Object;

/**
* Tells wether presence status should be displayed.
*
* @returns {boolean}
*/
export function presenceStatusDisabled() {
return Boolean(interfaceConfig?.DISABLE_PRESENCE_STATUS);
}

0 comments on commit ad68a87

Please sign in to comment.