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 удалений

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

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