AppConfig setting to control the default request timeout (#4797)
* AppConfig setting to control the default request timeout * Set default timeout to 10s
This commit is contained in:
parent
cab0b4fafa
commit
bab1cc0601
3 changed files with 20 additions and 1 deletions
|
|
@ -14,6 +14,8 @@
|
|||
<string name="allowOtherServers_description">Allow the user to change the above server URL.</string>
|
||||
<string name="username_title">Default Username</string>
|
||||
<string name="username_description">Set the username or email address to use to authenticate against the Mattermost Server.</string>
|
||||
<string name="timeout_title">Default Request Timeout</string>
|
||||
<string name="timeout_description">How long in milliseconds the mobile app should wait for the server to respond.</string>
|
||||
<string name="vendor_title">EMM Vendor or Company Name</string>
|
||||
<string name="vendor_description">Name of the EMM vendor or company deploying the app. Used in help text when prompting for passcodes so users are aware why the app is being protected.</string>
|
||||
</resources>
|
||||
|
|
|
|||
|
|
@ -43,6 +43,12 @@
|
|||
android:description="@string/username_description"
|
||||
android:restrictionType="string"
|
||||
android:defaultValue="" />
|
||||
<restriction
|
||||
android:key="timeout"
|
||||
android:title="@string/timeout_title"
|
||||
android:description="@string/timeout_description"
|
||||
android:restrictionType="string"
|
||||
android:defaultValue="10000" />
|
||||
<restriction
|
||||
android:key="vendor"
|
||||
android:title="@string/vendor_title"
|
||||
|
|
|
|||
|
|
@ -20,10 +20,16 @@ import mattermostManaged from 'app/mattermost_managed';
|
|||
|
||||
export const HEADER_X_CLUSTER_ID = 'X-Cluster-Id';
|
||||
export const HEADER_TOKEN = 'Token';
|
||||
const DEFAULT_TIMEOUT = 10000;
|
||||
|
||||
let managedConfig;
|
||||
|
||||
mattermostManaged.addEventListener('managedConfigDidChange', (config) => {
|
||||
if (config.timeout !== managedConfig?.timeout) {
|
||||
initFetchConfig();
|
||||
return;
|
||||
}
|
||||
|
||||
managedConfig = config;
|
||||
});
|
||||
|
||||
|
|
@ -150,11 +156,16 @@ Client4.doFetchWithResponse = async (url, options) => {
|
|||
const initFetchConfig = async () => {
|
||||
const fetchConfig = {
|
||||
auto: true,
|
||||
timeout: 5000, // Set the base timeout for every request to 5s
|
||||
timeout: DEFAULT_TIMEOUT, // Set the base timeout for every request to 5s
|
||||
};
|
||||
|
||||
try {
|
||||
managedConfig = await mattermostManaged.getConfig();
|
||||
|
||||
if (managedConfig?.timeout) {
|
||||
const timeout = parseInt(managedConfig.timeout, 10);
|
||||
fetchConfig.timeout = timeout || DEFAULT_TIMEOUT;
|
||||
}
|
||||
} catch {
|
||||
// no managed config
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue