Improving performance

This commit is contained in:
Liyas Thomas
2019-11-28 20:41:52 +05:30
parent 2a81c2611b
commit b10a209daf
28 changed files with 1028 additions and 585 deletions

View File

@@ -1,18 +1,22 @@
// Layout transitions
.layout-enter-active, .layout-leave-active {
.layout-enter-active,
.layout-leave-active {
transition: opacity 0.5s;
}
.layout-enter, .layout-leave-active {
.layout-enter,
.layout-leave-active {
opacity: 0;
}
// Page transitions
.page-enter-active, .page-leave-active {
.page-enter-active,
.page-leave-active {
transition: opacity 0.5s;
}
.page-enter, .page-leave-to {
.page-enter,
.page-leave-to {
opacity: 0;
}

View File

@@ -7,7 +7,7 @@ import * as querystring from "querystring";
* output this: 'msg1=value1&msg2=value2'
* @param dataArguments
*/
const joinDataArguments = (dataArguments) => {
const joinDataArguments = dataArguments => {
let data = "";
dataArguments.forEach((argument, i) => {
if (i === 0) {
@@ -17,9 +17,9 @@ const joinDataArguments = (dataArguments) => {
}
});
return data;
}
};
const parseCurlCommand = (curlCommand) => {
const parseCurlCommand = curlCommand => {
let newlineFound = /\r|\n/.exec(curlCommand);
if (newlineFound) {
// remove newlines
@@ -47,7 +47,7 @@ const parseCurlCommand = (curlCommand) => {
}
let headers;
const parseHeaders = (headerFieldName) => {
const parseHeaders = headerFieldName => {
if (parsedArguments[headerFieldName]) {
if (!headers) {
headers = {};
@@ -55,7 +55,7 @@ const parseCurlCommand = (curlCommand) => {
if (!Array.isArray(parsedArguments[headerFieldName])) {
parsedArguments[headerFieldName] = [parsedArguments[headerFieldName]];
}
parsedArguments[headerFieldName].forEach((header) => {
parsedArguments[headerFieldName].forEach(header => {
if (header.includes("Cookie")) {
// stupid javascript tricks: closure
cookieString = header;
@@ -95,7 +95,7 @@ const parseCurlCommand = (curlCommand) => {
if (!Array.isArray(parsedArguments.F)) {
parsedArguments.F = [parsedArguments.F];
}
parsedArguments.F.forEach((multipartArgument) => {
parsedArguments.F.forEach(multipartArgument => {
// input looks like key=value. value could be json or a file path prepended with an @
const [key, value] = multipartArgument.split("=", 2);
multipartUploads[key] = value;
@@ -221,6 +221,6 @@ const parseCurlCommand = (curlCommand) => {
request.insecure = true;
}
return request;
}
};
export default parseCurlCommand;

View File

@@ -2,36 +2,39 @@ export default () => {
//*** Determine whether or not the PWA has been installed. ***//
// Step 1: Check local storage
let pwaInstalled = localStorage.getItem('pwaInstalled') === 'yes';
let pwaInstalled = localStorage.getItem("pwaInstalled") === "yes";
// Step 2: Check if the display-mode is standalone. (Only permitted for PWAs.)
if (!pwaInstalled && window.matchMedia('(display-mode: standalone)').matches) {
localStorage.setItem('pwaInstalled', 'yes');
if (
!pwaInstalled &&
window.matchMedia("(display-mode: standalone)").matches
) {
localStorage.setItem("pwaInstalled", "yes");
pwaInstalled = true;
}
// Step 3: Check if the navigator is in standalone mode. (Again, only permitted for PWAs.)
if (!pwaInstalled && window.navigator.standalone === true) {
localStorage.setItem('pwaInstalled', 'yes');
localStorage.setItem("pwaInstalled", "yes");
pwaInstalled = true;
}
//*** If the PWA has not been installed, show the install PWA prompt.. ***//
let deferredPrompt = null;
window.addEventListener('beforeinstallprompt', (event) => {
window.addEventListener("beforeinstallprompt", event => {
deferredPrompt = event;
// Show the install button if the prompt appeared.
if (!pwaInstalled) {
document.querySelector('#installPWA').style.display = 'inline-flex';
document.querySelector("#installPWA").style.display = "inline-flex";
}
});
// When the app is installed, remove install prompts.
window.addEventListener('appinstalled', (event) => {
localStorage.setItem('pwaInstalled', 'yes');
window.addEventListener("appinstalled", event => {
localStorage.setItem("pwaInstalled", "yes");
pwaInstalled = true;
document.getElementById('installPWA').style.display = 'none';
document.getElementById("installPWA").style.display = "none";
});
// When the app is uninstalled, add the prompts back
@@ -40,13 +43,14 @@ export default () => {
deferredPrompt.prompt();
let outcome = await deferredPrompt.userChoice;
if (outcome === 'accepted') {
console.log('Postwoman was installed successfully.')
if (outcome === "accepted") {
console.log("Postwoman was installed successfully.");
} else {
console.log('Postwoman could not be installed. (Installation rejected by user.)')
console.log(
"Postwoman could not be installed. (Installation rejected by user.)"
);
}
deferredPrompt = null;
}
};
};