* MM-22686 decrease request timeout to 5s * MM-22752 Fix switching teams with and without connction Co-authored-by: Elias Nahum <nahumhbl@gmail.com>
This commit is contained in:
parent
b4d3e6c9b1
commit
6a2a99b0d6
4 changed files with 25 additions and 23 deletions
|
|
@ -231,7 +231,7 @@ export function loadPostsIfNecessaryWithRetry(channelId) {
|
|||
}
|
||||
|
||||
export async function retryGetPostsAction(action, dispatch, getState, maxTries = MAX_RETRIES) {
|
||||
for (let i = 0; i < maxTries; i++) {
|
||||
for (let i = 0; i <= maxTries; i++) {
|
||||
const {data} = await dispatch(action); // eslint-disable-line no-await-in-loop
|
||||
|
||||
if (data) {
|
||||
|
|
@ -364,14 +364,14 @@ export function handleSelectChannel(channelId, fromPushNotification = false) {
|
|||
dispatch(loadPostsIfNecessaryWithRetry(channelId));
|
||||
}
|
||||
|
||||
if (channel && member) {
|
||||
if (channel) {
|
||||
dispatch({
|
||||
type: ChannelTypes.SELECT_CHANNEL,
|
||||
data: channelId,
|
||||
extra: {
|
||||
channel,
|
||||
member,
|
||||
teamId: currentTeamId,
|
||||
teamId: channel.team_id || currentTeamId,
|
||||
},
|
||||
});
|
||||
}
|
||||
|
|
@ -642,9 +642,9 @@ export function loadChannelsForTeam(teamId) {
|
|||
|
||||
if (currentUserId) {
|
||||
const data = {sync: true, teamId};
|
||||
for (let i = 0; i < MAX_RETRIES; i++) {
|
||||
for (let i = 0; i <= MAX_RETRIES; i++) {
|
||||
try {
|
||||
console.log('Fetching channels attempt', (i + 1)); //eslint-disable-line no-console
|
||||
console.log('Fetching channels attempt', teamId, (i + 1)); //eslint-disable-line no-console
|
||||
const [channels, channelMembers] = await Promise.all([ //eslint-disable-line no-await-in-loop
|
||||
Client4.getMyChannels(teamId, true),
|
||||
Client4.getMyChannelMembers(teamId),
|
||||
|
|
@ -653,10 +653,11 @@ export function loadChannelsForTeam(teamId) {
|
|||
data.channels = channels;
|
||||
data.channelMembers = channelMembers;
|
||||
break;
|
||||
} catch (error) {
|
||||
const result = await dispatch(forceLogoutIfNecessary(error)); //eslint-disable-line no-await-in-loop
|
||||
} catch (err) {
|
||||
const result = await dispatch(forceLogoutIfNecessary(err)); //eslint-disable-line no-await-in-loop
|
||||
if (result || i === MAX_RETRIES) {
|
||||
return {error};
|
||||
const hasChannelsLoaded = state.entities.channels.channelsInTeam[teamId]?.size > 0;
|
||||
return {error: hasChannelsLoaded ? null : err};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -758,7 +759,7 @@ export function getUsersInChannel(channelId) {
|
|||
async function getProfilesFromPromises(dispatch, promiseArray, directChannels) {
|
||||
// Get the profiles returned by the promises and retry those that failed
|
||||
let promises = promiseArray;
|
||||
for (let i = 0; i < MAX_RETRIES; i++) {
|
||||
for (let i = 0; i <= MAX_RETRIES; i++) {
|
||||
if (!promises.length) {
|
||||
return;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,7 +1,9 @@
|
|||
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
|
||||
// See LICENSE.txt for license information.
|
||||
|
||||
import {TeamTypes} from 'mattermost-redux/action_types';
|
||||
import {batchActions} from 'redux-batched-actions';
|
||||
|
||||
import {ChannelTypes, TeamTypes} from 'mattermost-redux/action_types';
|
||||
import {getMyTeams} from 'mattermost-redux/actions/teams';
|
||||
import {RequestStatus} from 'mattermost-redux/constants';
|
||||
import {getConfig} from 'mattermost-redux/selectors/entities/general';
|
||||
|
|
@ -18,7 +20,10 @@ export function handleTeamChange(teamId) {
|
|||
return;
|
||||
}
|
||||
|
||||
dispatch({type: TeamTypes.SELECT_TEAM, data: teamId});
|
||||
dispatch(batchActions([
|
||||
{type: TeamTypes.SELECT_TEAM, data: teamId},
|
||||
{type: ChannelTypes.SELECT_CHANNEL, data: '', extra: {}},
|
||||
]));
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -145,7 +145,10 @@ Client4.doFetchWithResponse = async (url, options) => {
|
|||
};
|
||||
|
||||
const initFetchConfig = async () => {
|
||||
let fetchConfig = {};
|
||||
const fetchConfig = {
|
||||
auto: true,
|
||||
timeout: 5000, // Set the base timeout for every request to 5s
|
||||
};
|
||||
|
||||
try {
|
||||
managedConfig = await mattermostManaged.getConfig();
|
||||
|
|
@ -157,19 +160,11 @@ const initFetchConfig = async () => {
|
|||
Client4.setUserAgent(userAgent);
|
||||
|
||||
if (Platform.OS === 'ios') {
|
||||
const certificate = await mattermostBucket.getPreference('cert');
|
||||
fetchConfig = {
|
||||
auto: true,
|
||||
certificate,
|
||||
};
|
||||
window.fetch = new RNFetchBlob.polyfill.Fetch(fetchConfig).build();
|
||||
} else {
|
||||
fetchConfig = {
|
||||
auto: true,
|
||||
};
|
||||
window.fetch = new RNFetchBlob.polyfill.Fetch(fetchConfig).build();
|
||||
fetchConfig.certificate = await mattermostBucket.getPreference('cert');
|
||||
}
|
||||
|
||||
window.fetch = new RNFetchBlob.polyfill.Fetch(fetchConfig).build();
|
||||
|
||||
return true;
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -216,6 +216,7 @@ export default class ChannelBase extends PureComponent {
|
|||
if (EphemeralStore.appStartedFromPushNotification) {
|
||||
EphemeralStore.appStartedFromPushNotification = false;
|
||||
} else {
|
||||
this.setState({channelsRequestFailed: false});
|
||||
selectInitialChannel(teamId);
|
||||
}
|
||||
});
|
||||
|
|
|
|||
Loading…
Reference in a new issue