[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>
Этот коммит содержится в:
Devin Binnie
2024-05-03 09:06:06 -04:00
коммит произвёл GitHub
родитель 4b5d02990d
Коммит 8da64a5c34
7 изменённых файлов: 23 добавлений и 1 удалений

Просмотреть файл

@@ -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"

Просмотреть файл

@@ -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(() => {

Просмотреть файл

@@ -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:",

Просмотреть файл

@@ -38,6 +38,7 @@ export type ClientConfig = {
DiagnosticId: string;
DiagnosticsEnabled: string;
DisableRefetchingOnBrowserFocus: string;
DisableWakeUpReconnectHandler: string;
EmailLoginButtonBorderColor: string;
EmailLoginButtonColor: string;
EmailLoginButtonTextColor: string;