Tweak default device name to be more compact

Fixes https://github.com/vector-im/riot-web/issues/13458
pull/13465/head
J. Ryan Stinnett 2020-04-30 16:50:01 +01:00
parent ab40d5b732
commit 1ad54a4dae
3 changed files with 16 additions and 5 deletions

View File

@ -10,10 +10,10 @@
"Unexpected error preparing the app. See console for details.": "Unexpected error preparing the app. See console for details.",
"Open user settings": "Open user settings",
"Previous/next recently visited room or community": "Previous/next recently visited room or community",
"Riot Desktop on %(platformName)s": "Riot Desktop on %(platformName)s",
"Riot Desktop (%(platformName)s)": "Riot Desktop (%(platformName)s)",
"Go to your browser to complete Sign In": "Go to your browser to complete Sign In",
"Unknown device": "Unknown device",
"%(appName)s via %(browserName)s on %(osName)s": "%(appName)s via %(browserName)s on %(osName)s",
"%(appName)s (%(browserName)s, %(osName)s)": "%(appName)s (%(browserName)s, %(osName)s)",
"You need to be using HTTPS to place a screen-sharing call.": "You need to be using HTTPS to place a screen-sharing call.",
"powered by Matrix": "powered by Matrix",
"Custom Server Options": "Custom Server Options",

View File

@ -390,7 +390,7 @@ export default class ElectronPlatform extends VectorBasePlatform {
}
getDefaultDeviceDisplayName(): string {
return _t('Riot Desktop on %(platformName)s', { platformName: platformFriendlyName() });
return _t('Riot Desktop (%(platformName)s)', { platformName: platformFriendlyName() });
}
screenCaptureErrorString(): ?string {

View File

@ -181,16 +181,27 @@ export default class WebPlatform extends VectorBasePlatform {
getDefaultDeviceDisplayName(): string {
// strip query-string and fragment from uri
const u = url.parse(window.location.href);
u.protocol = "";
u.search = "";
u.hash = "";
const appName = u.format();
// Remove trailing slash if present
u.pathname = u.pathname.replace(/\/$/, "");
let appName = u.format();
// Remove leading slashes if present
appName = appName.replace(/^\/\//, "");
// `appName` is now in the format `riot.im/develop`.
const ua = new UAParser();
const browserName = ua.getBrowser().name || "unknown browser";
let osName = ua.getOS().name || "unknown OS";
// Stylise the value from the parser to match Apple's current branding.
if (osName === "Mac OS") osName = "macOS";
return _t('%(appName)s via %(browserName)s on %(osName)s', {appName: appName, browserName: browserName, osName: osName});
return _t('%(appName)s (%(browserName)s, %(osName)s)', {
appName,
browserName,
osName,
});
}
screenCaptureErrorString(): ?string {