Performer and Movie UI fixes and improvements (#447)

* Improve gender display
* Sanitise performer URLs
* Refactor editable text into separate module
* Make movie duration DurationInput
* Fix clearing sometimes not firing onChange
* Set movie duration as string
* Fix TextUtil.fileSize
* Improve scene URL
This commit is contained in:
WithoutPants
2020-04-11 13:23:31 +10:00
committed by GitHub
parent aef31c8b50
commit 6764c1f545
13 changed files with 361 additions and 136 deletions

View File

@@ -20,7 +20,7 @@ const fileSize = (bytes: number = 0, precision: number = 2) => {
unit++;
}
return `${bytes.toFixed(+precision)} ${Units[unit]}`;
return `${count.toFixed(+precision)} ${Units[unit]}`;
};
const secondsToTimestamp = (seconds: number) => {
@@ -83,6 +83,33 @@ const resolution = (height: number) => {
}
};
const twitterURL = new URL("https://www.twitter.com");
const instagramURL = new URL("https://www.instagram.com");
const sanitiseURL = (url?: string, siteURL?: URL) => {
if (!url) {
return url;
}
if (url.startsWith("http://") || url.startsWith("https://")) {
// just return the entire URL
return url;
}
if (siteURL) {
// if url starts with the site host, then prepend the protocol
if (url.startsWith(siteURL.host)) {
return siteURL.protocol + url;
}
// otherwise, construct the url from the protocol, host and passed url
return siteURL.protocol + siteURL.host + "/" + url;
}
// just prepend the protocol - assume https
return "https://" + url;
}
const TextUtils = {
truncate,
fileSize,
@@ -91,6 +118,9 @@ const TextUtils = {
age: getAge,
bitRate,
resolution,
sanitiseURL,
twitterURL,
instagramURL,
};
export default TextUtils;