mirror of
https://github.com/SchildiChat/element-web.git
synced 2024-10-01 01:26:12 -04:00
Improve code as per Sonar suggestions (#22224)
This commit is contained in:
parent
0292f66365
commit
ca98529bd2
@ -18,7 +18,6 @@
|
|||||||
* ```
|
* ```
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
class Optional {
|
class Optional {
|
||||||
static from(value) {
|
static from(value) {
|
||||||
return value && Some.of(value) || None;
|
return value && Some.of(value) || None;
|
||||||
|
@ -102,7 +102,7 @@ function fetchAsSubject(endpoint) {
|
|||||||
const contentLength = res.headers.get("content-length");
|
const contentLength = res.headers.get("content-length");
|
||||||
const context = contentLength ? { length: parseInt(contentLength) } : {};
|
const context = contentLength ? { length: parseInt(contentLength) } : {};
|
||||||
|
|
||||||
const streamer = observeReadableStream(res.body, context, endpoint);
|
const streamer = observeReadableStream(res.body, context);
|
||||||
streamer.subscribe((value) => {
|
streamer.subscribe((value) => {
|
||||||
fetcher.next(value);
|
fetcher.next(value);
|
||||||
});
|
});
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
<html>
|
<!doctype html>
|
||||||
|
<html lang="en">
|
||||||
<head>
|
<head>
|
||||||
<title>Rageshake decoder ring</title>
|
<title>Rageshake decoder ring</title>
|
||||||
<script crossorigin src="https://unpkg.com/source-map@0.7.3/dist/source-map.js"></script>
|
<script crossorigin src="https://unpkg.com/source-map@0.7.3/dist/source-map.js"></script>
|
||||||
|
@ -47,7 +47,6 @@ h1::after {
|
|||||||
display: flex;
|
display: flex;
|
||||||
-webkit-justify-content: space-around;
|
-webkit-justify-content: space-around;
|
||||||
-ms-flex-pack: distribute;
|
-ms-flex-pack: distribute;
|
||||||
justify-content: space-around;
|
|
||||||
-webkit-box-align: center;
|
-webkit-box-align: center;
|
||||||
-webkit-align-items: center;
|
-webkit-align-items: center;
|
||||||
-ms-flex-align: center;
|
-ms-flex-align: center;
|
||||||
|
@ -74,7 +74,7 @@ const ack = (ev: CustomEvent<IWidgetApiRequest>) => widgetApi.transport.reply(ev
|
|||||||
if (!optional && vals.length !== 1) {
|
if (!optional && vals.length !== 1) {
|
||||||
throw new Error(`Expected singular ${name} in query string`);
|
throw new Error(`Expected singular ${name} in query string`);
|
||||||
}
|
}
|
||||||
return <string>vals[0];
|
return vals[0];
|
||||||
};
|
};
|
||||||
|
|
||||||
// If we have these params, expect a widget API to be available (ie. to be in an iframe
|
// If we have these params, expect a widget API to be available (ie. to be in an iframe
|
||||||
|
File diff suppressed because one or more lines are too long
@ -17,7 +17,7 @@ function renderConfigError(message: string): void {
|
|||||||
const toHide = document.getElementsByClassName("mx_HomePage_container");
|
const toHide = document.getElementsByClassName("mx_HomePage_container");
|
||||||
const errorContainers = document.getElementsByClassName(
|
const errorContainers = document.getElementsByClassName(
|
||||||
"mx_HomePage_errorContainer",
|
"mx_HomePage_errorContainer",
|
||||||
) as HTMLCollectionOf<HTMLDialogElement>;
|
) as HTMLCollectionOf<HTMLDivElement>;
|
||||||
|
|
||||||
for (const e of toHide) {
|
for (const e of toHide) {
|
||||||
// We have to clear the content because .style.display='none'; doesn't work
|
// We have to clear the content because .style.display='none'; doesn't work
|
||||||
|
@ -106,11 +106,10 @@ export default class WebPlatform extends VectorBasePlatform {
|
|||||||
}
|
}
|
||||||
|
|
||||||
getNormalizedAppVersion(version: string): string {
|
getNormalizedAppVersion(version: string): string {
|
||||||
// if version looks like semver with leading v, strip it
|
// if version looks like semver with leading v, strip it (matches scripts/normalize-version.sh)
|
||||||
// (matches scripts/normalize-version.sh)
|
const semVerRegex = /^v\d+.\d+.\d+(-.+)?$/;
|
||||||
const semVerRegex = new RegExp("^v[0-9]+.[0-9]+.[0-9]+(-.+)?$");
|
|
||||||
if (semVerRegex.test(version)) {
|
if (semVerRegex.test(version)) {
|
||||||
return version.substr(1);
|
return version.substring(1);
|
||||||
}
|
}
|
||||||
return version;
|
return version;
|
||||||
}
|
}
|
||||||
|
@ -53,10 +53,6 @@
|
|||||||
margin-top: 30px;
|
margin-top: 30px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.mx_HomePage_header {
|
|
||||||
align-items: center;
|
|
||||||
}
|
|
||||||
|
|
||||||
.mx_HomePage_col {
|
.mx_HomePage_col {
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: row;
|
flex-direction: row;
|
||||||
|
@ -54,10 +54,6 @@
|
|||||||
margin-top: 30px;
|
margin-top: 30px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.mx_HomePage_header {
|
|
||||||
align-items: center;
|
|
||||||
}
|
|
||||||
|
|
||||||
.mx_HomePage_col {
|
.mx_HomePage_col {
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: row;
|
flex-direction: row;
|
||||||
|
@ -34,8 +34,7 @@ const cssThemes = {
|
|||||||
function getActiveThemes() {
|
function getActiveThemes() {
|
||||||
// Default to `light` theme when the MATRIX_THEMES environment variable is not defined.
|
// Default to `light` theme when the MATRIX_THEMES environment variable is not defined.
|
||||||
const theme = process.env.MATRIX_THEMES ?? 'light';
|
const theme = process.env.MATRIX_THEMES ?? 'light';
|
||||||
const themes = theme.split(',').filter(x => x).map(x => x.trim()).filter(x => x);
|
return theme.split(',').map(x => x.trim()).filter(Boolean);
|
||||||
return themes;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// See docs/customisations.md
|
// See docs/customisations.md
|
||||||
@ -80,7 +79,6 @@ module.exports = (env, argv) => {
|
|||||||
const nodeEnv = argv.mode;
|
const nodeEnv = argv.mode;
|
||||||
const devMode = nodeEnv !== 'production';
|
const devMode = nodeEnv !== 'production';
|
||||||
const useHMR = process.env.CSS_HOT_RELOAD === '1' && devMode;
|
const useHMR = process.env.CSS_HOT_RELOAD === '1' && devMode;
|
||||||
const fullPageErrors = process.env.FULL_PAGE_ERRORS === '1' && devMode;
|
|
||||||
const enableMinification = !devMode && !process.env.CI_PACKAGE;
|
const enableMinification = !devMode && !process.env.CI_PACKAGE;
|
||||||
|
|
||||||
const development = {};
|
const development = {};
|
||||||
@ -99,17 +97,16 @@ module.exports = (env, argv) => {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Resolve the directories for the react-sdk and js-sdk for later use. We resolve these early so we
|
// Resolve the directories for the react-sdk and js-sdk for later use. We resolve these early, so we
|
||||||
// don't have to call them over and over. We also resolve to the package.json instead of the src
|
// don't have to call them over and over. We also resolve to the package.json instead of the src
|
||||||
// directory so we don't have to rely on a index.js or similar file existing.
|
// directory, so we don't have to rely on an index.js or similar file existing.
|
||||||
const reactSdkSrcDir = path.resolve(require.resolve("matrix-react-sdk/package.json"), '..', 'src');
|
const reactSdkSrcDir = path.resolve(require.resolve("matrix-react-sdk/package.json"), '..', 'src');
|
||||||
const jsSdkSrcDir = path.resolve(require.resolve("matrix-js-sdk/package.json"), '..', 'src');
|
const jsSdkSrcDir = path.resolve(require.resolve("matrix-js-sdk/package.json"), '..', 'src');
|
||||||
|
|
||||||
const ACTIVE_THEMES = getActiveThemes();
|
const ACTIVE_THEMES = getActiveThemes();
|
||||||
function getThemesImports() {
|
function getThemesImports() {
|
||||||
const imports = ACTIVE_THEMES.map((t, index) => {
|
const imports = ACTIVE_THEMES.map((t) => {
|
||||||
const themeImportPath = cssThemes[`theme-${ t }`].replace('./node_modules/', '');
|
return cssThemes[`theme-${ t }`].replace('./node_modules/', ''); // theme import path
|
||||||
return themeImportPath;
|
|
||||||
});
|
});
|
||||||
const s = JSON.stringify(ACTIVE_THEMES);
|
const s = JSON.stringify(ACTIVE_THEMES);
|
||||||
return `
|
return `
|
||||||
@ -483,7 +480,7 @@ module.exports = (env, argv) => {
|
|||||||
esModule: false,
|
esModule: false,
|
||||||
name: '[name].[hash:7].[ext]',
|
name: '[name].[hash:7].[ext]',
|
||||||
outputPath: getAssetOutputPath,
|
outputPath: getAssetOutputPath,
|
||||||
publicPath: function (url, resourcePath) {
|
publicPath: function(url, resourcePath) {
|
||||||
const outputPath = getAssetOutputPath(url, resourcePath);
|
const outputPath = getAssetOutputPath(url, resourcePath);
|
||||||
return toPublicPath(outputPath);
|
return toPublicPath(outputPath);
|
||||||
},
|
},
|
||||||
@ -495,13 +492,13 @@ module.exports = (env, argv) => {
|
|||||||
esModule: false,
|
esModule: false,
|
||||||
name: '[name].[hash:7].[ext]',
|
name: '[name].[hash:7].[ext]',
|
||||||
outputPath: getAssetOutputPath,
|
outputPath: getAssetOutputPath,
|
||||||
publicPath: function (url, resourcePath) {
|
publicPath: function(url, resourcePath) {
|
||||||
const outputPath = getAssetOutputPath(url, resourcePath);
|
const outputPath = getAssetOutputPath(url, resourcePath);
|
||||||
return toPublicPath(outputPath);
|
return toPublicPath(outputPath);
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
]
|
],
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
test: /\.svg$/,
|
test: /\.svg$/,
|
||||||
@ -513,7 +510,7 @@ module.exports = (env, argv) => {
|
|||||||
esModule: false,
|
esModule: false,
|
||||||
name: '[name].[hash:7].[ext]',
|
name: '[name].[hash:7].[ext]',
|
||||||
outputPath: getAssetOutputPath,
|
outputPath: getAssetOutputPath,
|
||||||
publicPath: function (url, resourcePath) {
|
publicPath: function(url, resourcePath) {
|
||||||
// CSS image usages end up in the `bundles/[hash]` output
|
// CSS image usages end up in the `bundles/[hash]` output
|
||||||
// directory, so we adjust the final path to navigate up
|
// directory, so we adjust the final path to navigate up
|
||||||
// twice.
|
// twice.
|
||||||
@ -522,7 +519,7 @@ module.exports = (env, argv) => {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
]
|
],
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
test: /\.(gif|png|ttf|woff|woff2|xml|ico)$/,
|
test: /\.(gif|png|ttf|woff|woff2|xml|ico)$/,
|
||||||
|
Loading…
Reference in New Issue
Block a user