MM-50122 : Remove and test refetching of channels on browser focus change (#22973)

Этот коммит содержится в:
M-ZubairAhmed
2023-04-19 11:48:27 +05:30
коммит произвёл GitHub
родитель 6ca5824ea1
Коммит 7b9d43e308
9 изменённых файлов: 43 добавлений и 16 удалений

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

@@ -532,6 +532,7 @@ const defaultServerConfig: AdminConfig = {
EnableRemoteClusterService: false,
EnableAppBar: false,
PatchPluginsReactDOM: false,
DisableRefetchingOnBrowserFocus: false,
},
AnalyticsSettings: {
MaxUsersForStatistics: 2500,

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

@@ -94,6 +94,8 @@ func GenerateClientConfig(c *model.Config, telemetryID string, license *model.Li
props["CWSURL"] = *c.CloudSettings.CWSURL
props["DisableRefetchingOnBrowserFocus"] = strconv.FormatBool(*c.ExperimentalSettings.DisableRefetchingOnBrowserFocus)
// Set default values for all options that require a license.
props["ExperimentalEnableAuthenticationTransfer"] = "true"
props["LdapNicknameAttributeSet"] = "false"

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

@@ -979,6 +979,7 @@ type ExperimentalSettings struct {
EnableRemoteClusterService *bool `access:"experimental_features"`
EnableAppBar *bool `access:"experimental_features"`
PatchPluginsReactDOM *bool `access:"experimental_features"`
DisableRefetchingOnBrowserFocus *bool `access:"experimental_features"`
}
func (s *ExperimentalSettings) SetDefaults() {
@@ -1017,6 +1018,10 @@ func (s *ExperimentalSettings) SetDefaults() {
if s.PatchPluginsReactDOM == nil {
s.PatchPluginsReactDOM = NewBool(false)
}
if s.DisableRefetchingOnBrowserFocus == nil {
s.DisableRefetchingOnBrowserFocus = NewBool(false)
}
}
type AnalyticsSettings struct {

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

@@ -750,15 +750,16 @@ func (ts *TelemetryService) trackConfig() {
})
ts.SendTelemetry(TrackConfigExperimental, map[string]any{
"client_side_cert_enable": *cfg.ExperimentalSettings.ClientSideCertEnable,
"isdefault_client_side_cert_check": isDefault(*cfg.ExperimentalSettings.ClientSideCertCheck, model.ClientSideCertCheckPrimaryAuth),
"link_metadata_timeout_milliseconds": *cfg.ExperimentalSettings.LinkMetadataTimeoutMilliseconds,
"restrict_system_admin": *cfg.ExperimentalSettings.RestrictSystemAdmin,
"use_new_saml_library": *cfg.ExperimentalSettings.UseNewSAMLLibrary,
"enable_shared_channels": *cfg.ExperimentalSettings.EnableSharedChannels,
"enable_remote_cluster_service": *cfg.ExperimentalSettings.EnableRemoteClusterService && cfg.FeatureFlags.EnableRemoteClusterService,
"enable_app_bar": *cfg.ExperimentalSettings.EnableAppBar,
"patch_plugins_react_dom": *cfg.ExperimentalSettings.PatchPluginsReactDOM,
"client_side_cert_enable": *cfg.ExperimentalSettings.ClientSideCertEnable,
"isdefault_client_side_cert_check": isDefault(*cfg.ExperimentalSettings.ClientSideCertCheck, model.ClientSideCertCheckPrimaryAuth),
"link_metadata_timeout_milliseconds": *cfg.ExperimentalSettings.LinkMetadataTimeoutMilliseconds,
"restrict_system_admin": *cfg.ExperimentalSettings.RestrictSystemAdmin,
"use_new_saml_library": *cfg.ExperimentalSettings.UseNewSAMLLibrary,
"enable_shared_channels": *cfg.ExperimentalSettings.EnableSharedChannels,
"enable_remote_cluster_service": *cfg.ExperimentalSettings.EnableRemoteClusterService && cfg.FeatureFlags.EnableRemoteClusterService,
"enable_app_bar": *cfg.ExperimentalSettings.EnableAppBar,
"patch_plugins_react_dom": *cfg.ExperimentalSettings.PatchPluginsReactDOM,
"disable_refetching_on_browser_focus": *cfg.ExperimentalSettings.DisableRefetchingOnBrowserFocus,
})
ts.SendTelemetry(TrackConfigAnalytics, map[string]any{

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

@@ -6887,6 +6887,15 @@ const AdminDefinition = {
isHidden: it.licensedForFeature('Cloud'),
isDisabled: it.not(it.userHasWritePermissionOnResource(RESOURCE_KEYS.EXPERIMENTAL.FEATURES)),
},
{
type: Constants.SettingsTypes.TYPE_BOOL,
key: 'ExperimentalSettings.DisableRefetchingOnBrowserFocus',
label: t('admin.experimental.disableRefetchingOnBrowserFocus.title'),
label_default: 'Disable data refetching on browser refocus:',
help_text: t('admin.experimental.disableRefetchingOnBrowserFocus.desc'),
help_text_default: '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)),
},
],
},
},

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

@@ -36,6 +36,7 @@ function mapStateToProps(state: GlobalState, ownProps: OwnProps) {
const currentUser = getCurrentUser(state);
const plugins = state.plugins.components.NeedsTeamComponent;
const graphQLEnabled = isGraphQLEnabled(state);
const disableRefetchingOnBrowserFocus = config.DisableRefetchingOnBrowserFocus === 'true';
return {
currentUser,
@@ -46,6 +47,7 @@ function mapStateToProps(state: GlobalState, ownProps: OwnProps) {
selectedThreadId: getSelectedThreadIdInCurrentTeam(state),
mfaRequired: checkIfMFARequired(currentUser, license, config, ownProps.match.url),
graphQLEnabled,
disableRefetchingOnBrowserFocus,
};
}

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

@@ -70,7 +70,7 @@ function TeamController(props: Props) {
const wakeUpIntervalId = setInterval(() => {
const currentTime = Date.now();
if ((currentTime - lastTime.current) > WAKEUP_THRESHOLD) {
console.log('computer woke up - fetching latest'); //eslint-disable-line no-console
console.log('computer woke up - reconnecting'); //eslint-disable-line no-console
reconnect();
}
lastTime.current = currentTime;
@@ -92,12 +92,15 @@ function TeamController(props: Props) {
props.markChannelAsReadOnFocus(props.currentChannelId);
}
const currentTime = Date.now();
if ((currentTime - blurTime.current) > UNREAD_CHECK_TIME_MILLISECONDS && props.currentTeamId) {
if (props.graphQLEnabled) {
props.fetchChannelsAndMembers(props.currentTeamId);
} else {
props.fetchMyChannelsAndMembersREST(props.currentTeamId);
// Temporary flag to disable refetching of channel members on browser focus
if (!props.disableRefetchingOnBrowserFocus) {
const currentTime = Date.now();
if ((currentTime - blurTime.current) > UNREAD_CHECK_TIME_MILLISECONDS && props.currentTeamId) {
if (props.graphQLEnabled) {
props.fetchChannelsAndMembers(props.currentTeamId);
} else {
props.fetchMyChannelsAndMembersREST(props.currentTeamId);
}
}
}
}

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

@@ -895,6 +895,8 @@
"admin.experimental.collapsedThreads.title": "Collapsed Reply Threads",
"admin.experimental.defaultTheme.desc": "Set a default theme that applies to all new users on the system.",
"admin.experimental.defaultTheme.title": "Default Theme:",
"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.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 = {
DefaultTheme: string;
DiagnosticId: string;
DiagnosticsEnabled: string;
DisableRefetchingOnBrowserFocus: string;
EmailLoginButtonBorderColor: string;
EmailLoginButtonColor: string;
EmailLoginButtonTextColor: string;
@@ -729,6 +730,7 @@ export type ExperimentalSettings = {
EnableRemoteClusterService: boolean;
EnableAppBar: boolean;
PatchPluginsReactDOM: boolean;
DisableRefetchingOnBrowserFocus: boolean;
};
export type AnalyticsSettings = {