Update SdkConfig usage to use new translation layer + update config.md docs (#21429)
* Update SdkConfig usage to use new translation layer * Appease the linter * WIP refactor of config documentation * Finish re-writing config.md * Update surrounding documentation * Apply suggestions from code review Co-authored-by: Germain <germains@element.io> * Textual updates Co-authored-by: Germain <germains@element.io>
This commit is contained in:
parent
071a5410b8
commit
1384783a77
14 changed files with 526 additions and 249 deletions
|
@ -16,9 +16,11 @@ limitations under the License.
|
|||
|
||||
import request from 'browser-request';
|
||||
|
||||
import type { IConfigOptions } from "matrix-react-sdk/src/IConfigOptions";
|
||||
|
||||
// Load the config file. First try to load up a domain-specific config of the
|
||||
// form "config.$domain.json" and if that fails, fall back to config.json.
|
||||
export async function getVectorConfig(relativeLocation='') {
|
||||
export async function getVectorConfig(relativeLocation=''): Promise<IConfigOptions> {
|
||||
if (relativeLocation !== '' && !relativeLocation.endsWith('/')) relativeLocation += '/';
|
||||
|
||||
const specificConfigPromise = getConfig(`${relativeLocation}config.${document.domain}.json`);
|
||||
|
@ -30,9 +32,9 @@ export async function getVectorConfig(relativeLocation='') {
|
|||
if (Object.keys(configJson).length === 0) {
|
||||
throw new Error(); // throw to enter the catch
|
||||
}
|
||||
return configJson;
|
||||
return configJson as IConfigOptions;
|
||||
} catch (e) {
|
||||
return await generalConfigPromise;
|
||||
return await generalConfigPromise as IConfigOptions;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue