[MM-57407] Add setting to disable the wake up on reconnect handler (#26924)

* [MM-57407] Add setting to disable the wake up on reconnect handler

* Add dependency

---------

Co-authored-by: Mattermost Build <build@mattermost.com>
This commit is contained in:
Devin Binnie
2024-05-03 09:06:06 -04:00
committed by GitHub
co-authored by Mattermost Build
parent 4b5d02990d
commit 8da64a5c34
7 changed files with 23 additions and 1 deletions
+1
View File
@@ -96,6 +96,7 @@ func GenerateClientConfig(c *model.Config, telemetryID string, license *model.Li
props["CWSMock"] = model.MockCWS
props["DisableRefetchingOnBrowserFocus"] = strconv.FormatBool(*c.ExperimentalSettings.DisableRefetchingOnBrowserFocus)
props["DisableWakeUpReconnectHandler"] = strconv.FormatBool(*c.ExperimentalSettings.DisableWakeUpReconnectHandler)
// Set default values for all options that require a license.
props["ExperimentalEnableAuthenticationTransfer"] = "true"
+5
View File
@@ -1009,6 +1009,7 @@ type ExperimentalSettings struct {
DisableAppBar *bool `access:"experimental_features"`
DisableRefetchingOnBrowserFocus *bool `access:"experimental_features"`
DelayChannelAutocomplete *bool `access:"experimental_features"`
DisableWakeUpReconnectHandler *bool `access:"experimental_features"`
}
func (s *ExperimentalSettings) SetDefaults() {
@@ -1047,6 +1048,10 @@ func (s *ExperimentalSettings) SetDefaults() {
if s.DelayChannelAutocomplete == nil {
s.DelayChannelAutocomplete = NewBool(false)
}
if s.DisableWakeUpReconnectHandler == nil {
s.DisableWakeUpReconnectHandler = NewBool(false)
}
}
type AnalyticsSettings struct {
@@ -6204,6 +6204,13 @@ const AdminDefinition: AdminDefinitionType = {
help_text: defineMessage({id: 'admin.experimental.disableRefetchingOnBrowserFocus.desc', defaultMessage: 'When true, Mattermost will not refetch channels and channel members when the browser regains focus. This may result in improved performance for users with many channels and channel members.'}),
isDisabled: it.not(it.userHasWritePermissionOnResource(RESOURCE_KEYS.EXPERIMENTAL.FEATURES)),
},
{
type: 'bool',
key: 'ExperimentalSettings.DisableWakeUpReconnectHandler',
label: defineMessage({id: 'admin.experimental.disableWakeUpReconnectHandler.title', defaultMessage: 'Disable Wake Up Reconnect Handler:'}),
help_text: defineMessage({id: 'admin.experimental.disableWakeUpReconnectHandler.desc', defaultMessage: 'When true, Mattermost will not attempt to detect when the computer has woken up and refetch data. This might reduce the amount of regular network traffic the app is sending.'}),
isDisabled: it.not(it.userHasWritePermissionOnResource(RESOURCE_KEYS.EXPERIMENTAL.FEATURES)),
},
{
type: 'bool',
key: 'ExperimentalSettings.DelayChannelAutocomplete',
@@ -35,6 +35,7 @@ function mapStateToProps(state: GlobalState, ownProps: OwnProps) {
const currentUser = getCurrentUser(state);
const plugins = state.plugins.components.NeedsTeamComponent;
const disableRefetchingOnBrowserFocus = config.DisableRefetchingOnBrowserFocus === 'true';
const disableWakeUpReconnectHandler = config.DisableWakeUpReconnectHandler === 'true';
return {
currentTeamId: getCurrentTeamId(state),
@@ -44,6 +45,7 @@ function mapStateToProps(state: GlobalState, ownProps: OwnProps) {
selectedThreadId: getSelectedThreadIdInCurrentTeam(state),
mfaRequired: checkIfMFARequired(currentUser, license, config, ownProps.match.url),
disableRefetchingOnBrowserFocus,
disableWakeUpReconnectHandler,
};
}
@@ -63,6 +63,10 @@ function TeamController(props: Props) {
}, []);
useEffect(() => {
if (props.disableWakeUpReconnectHandler) {
return () => {};
}
const wakeUpIntervalId = setInterval(() => {
const currentTime = Date.now();
if ((currentTime - lastTime.current) > WAKEUP_THRESHOLD) {
@@ -75,7 +79,7 @@ function TeamController(props: Props) {
return () => {
clearInterval(wakeUpIntervalId);
};
}, []);
}, [props.disableWakeUpReconnectHandler]);
// Effect runs on mount, add event listeners on windows object
useEffect(() => {
+2
View File
@@ -899,6 +899,8 @@
"admin.experimental.disableAppBar.title": "Disable Apps Bar:",
"admin.experimental.disableRefetchingOnBrowserFocus.desc": "When true, Mattermost will not refetch channels and channel members when the browser regains focus. This may result in improved performance for users with many channels and channel members.",
"admin.experimental.disableRefetchingOnBrowserFocus.title": "Disable data refetching on browser refocus:",
"admin.experimental.disableWakeUpReconnectHandler.desc": "When true, Mattermost will not attempt to detect when the computer has woken up and refetch data. This might reduce the amount of regular network traffic the app is sending.",
"admin.experimental.disableWakeUpReconnectHandler.title": "Disable Wake Up Reconnect Handler:",
"admin.experimental.emailBatchingBufferSize.desc": "Specify the maximum number of notifications batched into a single email.",
"admin.experimental.emailBatchingBufferSize.example": "E.g.: \"256\"",
"admin.experimental.emailBatchingBufferSize.title": "Email Batching Buffer Size:",
+1
View File
@@ -38,6 +38,7 @@ export type ClientConfig = {
DiagnosticId: string;
DiagnosticsEnabled: string;
DisableRefetchingOnBrowserFocus: string;
DisableWakeUpReconnectHandler: string;
EmailLoginButtonBorderColor: string;
EmailLoginButtonColor: string;
EmailLoginButtonTextColor: string;