Merge pull request #543 from liyasthomas/refactor

Refactor
This commit is contained in:
James George
2020-02-01 23:44:54 +05:30
committed by GitHub
6 changed files with 118 additions and 158 deletions

View File

@@ -55,8 +55,8 @@ export default {
mounted() { mounted() {
const editor = ace.edit(this.$refs.editor, { const editor = ace.edit(this.$refs.editor, {
theme: "ace/theme/" + this.defineTheme(), theme: `ace/theme/${this.defineTheme()}`,
mode: "ace/mode/" + this.lang, mode: `ace/mode/${this.lang}`,
...this.options ...this.options
}); });
@@ -76,11 +76,10 @@ export default {
defineTheme() { defineTheme() {
if (this.theme) { if (this.theme) {
return this.theme; return this.theme;
} else {
return (
this.$store.state.postwoman.settings.THEME_ACE_EDITOR || DEFAULT_THEME
);
} }
return (
this.$store.state.postwoman.settings.THEME_ACE_EDITOR || DEFAULT_THEME
);
} }
}, },

View File

@@ -363,8 +363,8 @@ export default {
let file = this.$refs.collectionUpload.files[0]; let file = this.$refs.collectionUpload.files[0];
if (file !== undefined && file !== null) { if (file !== undefined && file !== null) {
let reader = new FileReader(); let reader = new FileReader();
reader.onload = e => { reader.onload = ({ target }) => {
this.collectionJSON = e.target.result; this.collectionJSON = target.result;
}; };
reader.readAsText(file); reader.readAsText(file);
this.$toast.info(this.$t("file_imported"), { this.$toast.info(this.$t("file_imported"), {

View File

@@ -531,7 +531,10 @@ export default {
return this.$store.state.gql.variablesJSONString; return this.$store.state.gql.variablesJSONString;
}, },
set(value) { set(value) {
this.$store.commit("setGQLState", { value, attribute: "variablesJSONString" }); this.$store.commit("setGQLState", {
value,
attribute: "variablesJSONString"
});
} }
}, },
headerString() { headerString() {
@@ -620,7 +623,7 @@ export default {
this.headers.forEach(header => { this.headers.forEach(header => {
headers[header.key] = header.value; headers[header.key] = header.value;
}); });
let variables = JSON.parse(this.variableString); let variables = JSON.parse(this.variableString);
const gqlQueryString = this.gqlQueryString; const gqlQueryString = this.gqlQueryString;
@@ -780,13 +783,10 @@ export default {
downloadResponse() { downloadResponse() {
const dataToWrite = JSON.stringify(this.schemaString, null, 2); const dataToWrite = JSON.stringify(this.schemaString, null, 2);
const file = new Blob([dataToWrite], { type: "application/json" }); const file = new Blob([dataToWrite], { type: "application/json" });
const a = document.createElement("a"), const a = document.createElement("a");
url = URL.createObjectURL(file); const url = URL.createObjectURL(file);
a.href = url; a.href = url;
a.download = (this.url + " on " + Date() + ".graphql").replace( a.download = `${this.url} on ${Date()}.graphql`.replace(/\./g, "[dot]");
/\./g,
"[dot]"
);
document.body.appendChild(a); document.body.appendChild(a);
a.click(); a.click();
this.$refs.downloadResponse.innerHTML = this.doneButton; this.$refs.downloadResponse.innerHTML = this.doneButton;

View File

@@ -1504,8 +1504,11 @@ export default {
this.rawInput = !this.knownContentTypes.includes(val); this.rawInput = !this.knownContentTypes.includes(val);
}, },
rawInput(status) { rawInput(status) {
if (status && this.rawParams === "") this.rawParams = "{}"; if (status && this.rawParams === "") {
else this.setRouteQueryState(); this.rawParams = "{}";
} else {
this.setRouteQueryState();
}
}, },
"response.body": function(val) { "response.body": function(val) {
if ( if (
@@ -1822,12 +1825,10 @@ export default {
} }
const protocol = "^(https?:\\/\\/)?"; const protocol = "^(https?:\\/\\/)?";
const validIP = new RegExp( const validIP = new RegExp(
protocol + `${protocol}(([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5]).){3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])$`
"(([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5]).){3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])$"
); );
const validHostname = new RegExp( const validHostname = new RegExp(
protocol + `${protocol}(([a-zA-Z0-9]|[a-zA-Z0-9][a-zA-Z0-9-]*[a-zA-Z0-9]).)*([A-Za-z0-9]|[A-Za-z0-9][A-Za-z0-9-]*[A-Za-z0-9/])$`
"(([a-zA-Z0-9]|[a-zA-Z0-9][a-zA-Z0-9-]*[a-zA-Z0-9]).)*([A-Za-z0-9]|[A-Za-z0-9][A-Za-z0-9-]*[A-Za-z0-9/])$"
); );
return validIP.test(this.url) || validHostname.test(this.url); return validIP.test(this.url) || validHostname.test(this.url);
}, },
@@ -1838,8 +1839,8 @@ export default {
return this.path.match(/^([^?]*)\??/)[1]; return this.path.match(/^([^?]*)\??/)[1];
}, },
rawRequestBody() { rawRequestBody() {
const { bodyParams } = this; const { bodyParams, contentType } = this;
if (this.contentType === "application/json") { if (contentType === "application/json") {
try { try {
const obj = JSON.parse( const obj = JSON.parse(
`{${bodyParams `{${bodyParams
@@ -1851,7 +1852,7 @@ export default {
) )
.join()}}` .join()}}`
); );
return JSON.stringify(obj); return JSON.stringify(obj, null, 2);
} catch (ex) { } catch (ex) {
return "invalid"; return "invalid";
} }
@@ -1885,39 +1886,20 @@ export default {
if (this.requestType === "JavaScript XHR") { if (this.requestType === "JavaScript XHR") {
const requestString = []; const requestString = [];
requestString.push("const xhr = new XMLHttpRequest()"); requestString.push("const xhr = new XMLHttpRequest()");
const user = const user = this.auth === "Basic Auth" ? `'${this.httpUser}'` : null;
this.auth === "Basic Auth" ? "'" + this.httpUser + "'" : null; const password =
const pswd = this.auth === "Basic Auth" ? `'${this.httpPassword}'` : null;
this.auth === "Basic Auth" ? "'" + this.httpPassword + "'" : null;
requestString.push( requestString.push(
"xhr.open('" + `xhr.open('${this.method}', '${this.url}${this.pathName}${this.queryString}', true, ${user}, ${password})`
this.method +
"', '" +
this.url +
this.pathName +
this.queryString +
"', true, " +
user +
", " +
pswd +
")"
); );
if (this.auth === "Bearer Token" || this.auth === "OAuth 2.0") { if (this.auth === "Bearer Token" || this.auth === "OAuth 2.0") {
requestString.push( requestString.push(
"xhr.setRequestHeader('Authorization', 'Bearer " + `xhr.setRequestHeader('Authorization', 'Bearer ${this.bearerToken}')`
this.bearerToken +
"')"
); );
} }
if (this.headers) { if (this.headers) {
this.headers.forEach(element => { this.headers.forEach(({ key, value }) => {
requestString.push( requestString.push(`xhr.setRequestHeader('${key}', '${value}')`);
"xhr.setRequestHeader('" +
element.key +
"', '" +
element.value +
"')"
);
}); });
} }
if (["POST", "PUT", "PATCH"].includes(this.method)) { if (["POST", "PUT", "PATCH"].includes(this.method)) {
@@ -1925,14 +1907,12 @@ export default {
? this.rawParams ? this.rawParams
: this.rawRequestBody; : this.rawRequestBody;
requestString.push( requestString.push(
"xhr.setRequestHeader('Content-Length', " + requestBody.length + ")" `xhr.setRequestHeader('Content-Length', ${requestBody.length})`
); );
requestString.push( requestString.push(
"xhr.setRequestHeader('Content-Type', '" + `xhr.setRequestHeader('Content-Type', '${this.contentType}; charset=utf-8')`
this.contentType +
"; charset=utf-8')"
); );
requestString.push("xhr.send(" + requestBody + ")"); requestString.push(`xhr.send(${requestBody})`);
} else { } else {
requestString.push("xhr.send()"); requestString.push("xhr.send()");
} }
@@ -1941,40 +1921,36 @@ export default {
const requestString = []; const requestString = [];
let headers = []; let headers = [];
requestString.push( requestString.push(
'fetch("' + this.url + this.pathName + this.queryString + '", {\n' `fetch("${this.url}${this.pathName}${this.queryString}", {\n`
); );
requestString.push(' method: "' + this.method + '",\n'); requestString.push(` method: "${this.method}",\n`);
if (this.auth === "Basic Auth") { if (this.auth === "Basic Auth") {
const basic = this.httpUser + ":" + this.httpPassword; const basic = `${this.httpUser}:${this.httpPassword}`;
headers.push( headers.push(
' "Authorization": "Basic ' + ` "Authorization": "Basic ${window.btoa(
window.btoa(unescape(encodeURIComponent(basic))) + unescape(encodeURIComponent(basic))
'",\n' )}",\n`
); );
} else if (this.auth === "Bearer Token" || this.auth === "OAuth 2.0") { } else if (this.auth === "Bearer Token" || this.auth === "OAuth 2.0") {
headers.push( headers.push(` "Authorization": "Bearer ${this.bearerToken}",\n`);
' "Authorization": "Bearer ' + this.bearerToken + '",\n'
);
} }
if (["POST", "PUT", "PATCH"].includes(this.method)) { if (["POST", "PUT", "PATCH"].includes(this.method)) {
const requestBody = this.rawInput const requestBody = this.rawInput
? this.rawParams ? this.rawParams
: this.rawRequestBody; : this.rawRequestBody;
requestString.push(" body: " + requestBody + ",\n"); requestString.push(` body: ${requestBody},\n`);
headers.push(' "Content-Length": ' + requestBody.length + ",\n"); headers.push(` "Content-Length": ${requestBody.length},\n`);
headers.push( headers.push(
' "Content-Type": "' + this.contentType + '; charset=utf-8",\n' ` "Content-Type": "${this.contentType}; charset=utf-8",\n`
); );
} }
if (this.headers) { if (this.headers) {
this.headers.forEach(element => { this.headers.forEach(({ key, value }) => {
headers.push( headers.push(` "${key}": "${value}",\n`);
' "' + element.key + '": "' + element.value + '",\n'
);
}); });
} }
headers = headers.join("").slice(0, -2); headers = headers.join("").slice(0, -2);
requestString.push(" headers: {\n" + headers + "\n },\n"); requestString.push(` headers: {\n${headers}\n },\n`);
requestString.push(' credentials: "same-origin"\n'); requestString.push(' credentials: "same-origin"\n');
requestString.push("}).then(function(response) {\n"); requestString.push("}).then(function(response) {\n");
requestString.push(" response.status\n"); requestString.push(" response.status\n");
@@ -1988,40 +1964,36 @@ export default {
return requestString.join(""); return requestString.join("");
} else if (this.requestType === "cURL") { } else if (this.requestType === "cURL") {
const requestString = []; const requestString = [];
requestString.push("curl -X " + this.method + " \n"); requestString.push(`curl -X ${this.method} \n`);
requestString.push( requestString.push(
" '" + this.url + this.pathName + this.queryString + "' \n" ` '${this.url}${this.pathName}${this.queryString}' \n`
); );
if (this.auth === "Basic Auth") { if (this.auth === "Basic Auth") {
const basic = this.httpUser + ":" + this.httpPassword; const basic = `${this.httpUser}:${this.httpPassword}`;
requestString.push( requestString.push(
" -H 'Authorization: Basic " + ` -H 'Authorization: Basic ${window.btoa(
window.btoa(unescape(encodeURIComponent(basic))) + unescape(encodeURIComponent(basic))
"' \n" )}' \n`
); );
} else if (this.auth === "Bearer Token" || this.auth === "OAuth 2.0") { } else if (this.auth === "Bearer Token" || this.auth === "OAuth 2.0") {
requestString.push( requestString.push(
" -H 'Authorization: Bearer " + this.bearerToken + "' \n" ` -H 'Authorization: Bearer ${this.bearerToken}' \n`
); );
} }
if (this.headers) { if (this.headers) {
this.headers.forEach(element => { this.headers.forEach(({ key, value }) => {
requestString.push( requestString.push(` -H '${key}: ${value}' \n`);
" -H '" + element.key + ": " + element.value + "' \n"
);
}); });
} }
if (["POST", "PUT", "PATCH"].includes(this.method)) { if (["POST", "PUT", "PATCH"].includes(this.method)) {
const requestBody = this.rawInput const requestBody = this.rawInput
? this.rawParams ? this.rawParams
: this.rawRequestBody; : this.rawRequestBody;
requestString.push(` -H 'Content-Length: ${requestBody.length}' \n`);
requestString.push( requestString.push(
" -H 'Content-Length: " + requestBody.length + "' \n" ` -H 'Content-Type: ${this.contentType}; charset=utf-8' \n`
); );
requestString.push( requestString.push(` -d '${requestBody}' \n`);
" -H 'Content-Type: " + this.contentType + "; charset=utf-8' \n"
);
requestString.push(" -d '" + requestBody + "' \n");
} }
return requestString.join("").slice(0, -2); return requestString.join("").slice(0, -2);
} }
@@ -2283,21 +2255,20 @@ export default {
} }
}, },
getQueryStringFromPath() { getQueryStringFromPath() {
let queryString, let queryString;
pathParsed = url.parse(this.path); const pathParsed = url.parse(this.path);
return (queryString = pathParsed.query ? pathParsed.query : ""); return (queryString = pathParsed.query ? pathParsed.query : "");
}, },
queryStringToArray(queryString) { queryStringToArray(queryString) {
let queryParsed = querystring.parse(queryString); const queryParsed = querystring.parse(queryString);
return Object.keys(queryParsed).map(key => ({ return Object.keys(queryParsed).map(key => ({
key: key, key,
value: queryParsed[key] value: queryParsed[key]
})); }));
}, },
pathInputHandler() { pathInputHandler() {
let queryString = this.getQueryStringFromPath(), const queryString = this.getQueryStringFromPath();
params = this.queryStringToArray(queryString); const params = this.queryStringToArray(queryString);
this.paramsWatchEnabled = false; this.paramsWatchEnabled = false;
this.params = params; this.params = params;
}, },
@@ -2366,8 +2337,8 @@ export default {
}, },
copyRequest() { copyRequest() {
if (navigator.share) { if (navigator.share) {
let time = new Date().toLocaleTimeString(); const time = new Date().toLocaleTimeString();
let date = new Date().toLocaleDateString(); const date = new Date().toLocaleDateString();
navigator navigator
.share({ .share({
title: `Postwoman`, title: `Postwoman`,
@@ -2418,7 +2389,7 @@ export default {
const aux = document.createElement("textarea"); const aux = document.createElement("textarea");
const copy = const copy =
this.responseType === "application/json" this.responseType === "application/json"
? JSON.stringify(this.response.body) ? JSON.stringify(this.response.body, null, 2)
: this.response.body; : this.response.body;
aux.innerText = copy; aux.innerText = copy;
document.body.appendChild(aux); document.body.appendChild(aux);
@@ -2433,17 +2404,12 @@ export default {
downloadResponse() { downloadResponse() {
const dataToWrite = JSON.stringify(this.response.body, null, 2); const dataToWrite = JSON.stringify(this.response.body, null, 2);
const file = new Blob([dataToWrite], { type: this.responseType }); const file = new Blob([dataToWrite], { type: this.responseType });
const a = document.createElement("a"), const a = document.createElement("a");
url = URL.createObjectURL(file); const url = URL.createObjectURL(file);
a.href = url; a.href = url;
a.download = ( a.download = `${this.url + this.path} [${
this.url + this.method
this.path + }] on ${Date()}`.replace(/\./g, "[dot]");
" [" +
this.method +
"] on " +
Date()
).replace(/\./g, "[dot]");
document.body.appendChild(a); document.body.appendChild(a);
a.click(); a.click();
this.$refs.downloadResponse.innerHTML = this.doneButton; this.$refs.downloadResponse.innerHTML = this.doneButton;
@@ -2489,7 +2455,8 @@ export default {
const haveItems = [...this[key]].length; const haveItems = [...this[key]].length;
if (haveItems && this[key]["value"] !== "") { if (haveItems && this[key]["value"] !== "") {
return `${key}=${JSON.stringify(this[key])}&`; return `${key}=${JSON.stringify(this[key])}&`;
} else return ""; }
return "";
}; };
let flats = [ let flats = [
"method", "method",
@@ -2503,21 +2470,20 @@ export default {
] ]
.filter(item => item !== null) .filter(item => item !== null)
.map(item => flat(item)); .map(item => flat(item));
let deeps = ["headers", "params"].map(item => deep(item)); const deeps = ["headers", "params"].map(item => deep(item));
let bodyParams = this.rawInput const bodyParams = this.rawInput
? [flat("rawParams")] ? [flat("rawParams")]
: [deep("bodyParams")]; : [deep("bodyParams")];
history.replaceState( history.replaceState(
window.location.href, window.location.href,
"", "",
"/?" + `/?${encodeURI(
encodeURI( flats
flats .concat(deeps, bodyParams)
.concat(deeps, bodyParams) .join("")
.join("") .slice(0, -1)
.slice(0, -1) )}`
)
); );
}, },
setRouteQueries(queries) { setRouteQueries(queries) {
@@ -2529,7 +2495,9 @@ export default {
if (key === "rawParams") { if (key === "rawParams") {
this.rawInput = true; this.rawInput = true;
this.rawParams = queries["rawParams"]; this.rawParams = queries["rawParams"];
} else if (typeof this[key] === "string") this[key] = queries[key]; } else if (typeof this[key] === "string") {
this[key] = queries[key];
}
} }
}, },
observeRequestButton() { observeRequestButton() {
@@ -2553,18 +2521,17 @@ export default {
observer.observe(requestElement); observer.observe(requestElement);
}, },
handleImport() { handleImport() {
let textarea = document.getElementById("import-text"); const { value: text } = document.getElementById("import-text");
let text = textarea.value;
try { try {
let parsedCurl = parseCurlCommand(text); const parsedCurl = parseCurlCommand(text);
let url = new URL(parsedCurl.url.replace(/"/g, "").replace(/'/g, "")); const { origin, pathname } = new URL(parsedCurl.url.replace(/"/g, "").replace(/'/g, ""));
this.url = url.origin; this.url = origin;
this.path = url.pathname; this.path = pathname;
this.headers = []; this.headers = [];
if (parsedCurl.headers) { if (parsedCurl.headers) {
for (const key of Object.keys(parsedCurl.headers)) { for (const key of Object.keys(parsedCurl.headers)) {
this.$store.commit("addHeaders", { this.$store.commit("addHeaders", {
key: key, key,
value: parsedCurl.headers[key] value: parsedCurl.headers[key]
}); });
} }
@@ -2711,11 +2678,11 @@ export default {
}, },
uploadPayload() { uploadPayload() {
this.rawInput = true; this.rawInput = true;
let file = this.$refs.payload.files[0]; const file = this.$refs.payload.files[0];
if (file !== undefined && file !== null) { if (file !== undefined && file !== null) {
let reader = new FileReader(); const reader = new FileReader();
reader.onload = e => { reader.onload = ({ target }) => {
this.rawParams = e.target.result; this.rawParams = target.result;
}; };
reader.readAsText(file); reader.readAsText(file);
this.$toast.info(this.$t("file_imported"), { this.$toast.info(this.$t("file_imported"), {
@@ -2754,7 +2721,7 @@ export default {
} }
}, },
async oauthRedirectReq() { async oauthRedirectReq() {
let tokenInfo = await oauthRedirect(); const tokenInfo = await oauthRedirect();
if (tokenInfo.hasOwnProperty("access_token")) { if (tokenInfo.hasOwnProperty("access_token")) {
this.bearerToken = tokenInfo.access_token; this.bearerToken = tokenInfo.access_token;
this.addOAuthToken({ this.addOAuthToken({
@@ -2806,8 +2773,8 @@ export default {
}, },
removeOAuthTokenReq(index) { removeOAuthTokenReq(index) {
const oldTokenReqs = this.tokenReqs.slice(); const oldTokenReqs = this.tokenReqs.slice();
let targetReqIndex = this.tokenReqs.findIndex( const targetReqIndex = this.tokenReqs.findIndex(
tokenReq => tokenReq.name === this.tokenReqName ({ name }) => name === this.tokenReqName
); );
if (targetReqIndex < 0) return; if (targetReqIndex < 0) return;
this.$store.commit("removeOAuthTokenReq", targetReqIndex); this.$store.commit("removeOAuthTokenReq", targetReqIndex);
@@ -2822,18 +2789,16 @@ export default {
} }
}); });
}, },
tokenReqChange(event) { tokenReqChange({ target }) {
let targetReq = this.tokenReqs.find( const { details, name } = this.tokenReqs.find(({ name }) => name === target.value);
tokenReq => tokenReq.name === event.target.value const {
);
let {
oidcDiscoveryUrl, oidcDiscoveryUrl,
authUrl, authUrl,
accessTokenUrl, accessTokenUrl,
clientId, clientId,
scope scope
} = targetReq.details; } = details;
this.tokenReqName = targetReq.name; this.tokenReqName = name;
this.oidcDiscoveryUrl = oidcDiscoveryUrl; this.oidcDiscoveryUrl = oidcDiscoveryUrl;
this.authUrl = authUrl; this.authUrl = authUrl;
this.accessTokenUrl = accessTokenUrl; this.accessTokenUrl = accessTokenUrl;

View File

@@ -211,24 +211,20 @@ export default {
urlValid() { urlValid() {
const protocol = "^(wss?:\\/\\/)?"; const protocol = "^(wss?:\\/\\/)?";
const validIP = new RegExp( const validIP = new RegExp(
protocol + `${protocol}(([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5]).){3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])$`
"(([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5]).){3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])$"
); );
const validHostname = new RegExp( const validHostname = new RegExp(
protocol + `${protocol}(([a-zA-Z0-9]|[a-zA-Z0-9][a-zA-Z0-9-]*[a-zA-Z0-9]).)*([A-Za-z0-9]|[A-Za-z0-9][A-Za-z0-9-]*[A-Za-z0-9/])$`
"(([a-zA-Z0-9]|[a-zA-Z0-9][a-zA-Z0-9-]*[a-zA-Z0-9]).)*([A-Za-z0-9]|[A-Za-z0-9][A-Za-z0-9-]*[A-Za-z0-9/])$"
); );
return validIP.test(this.url) || validHostname.test(this.url); return validIP.test(this.url) || validHostname.test(this.url);
}, },
serverValid() { serverValid() {
const protocol = "^(https?:\\/\\/)?"; const protocol = "^(https?:\\/\\/)?";
const validIP = new RegExp( const validIP = new RegExp(
protocol + `${protocol}(([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5]).){3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])$`
"(([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5]).){3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])$"
); );
const validHostname = new RegExp( const validHostname = new RegExp(
protocol + `${protocol}(([a-zA-Z0-9]|[a-zA-Z0-9][a-zA-Z0-9-]*[a-zA-Z0-9]).)*([A-Za-z0-9]|[A-Za-z0-9][A-Za-z0-9-]*[A-Za-z0-9/])$`
"(([a-zA-Z0-9]|[a-zA-Z0-9][a-zA-Z0-9-]*[a-zA-Z0-9]).)*([A-Za-z0-9]|[A-Za-z0-9][A-Za-z0-9-]*[A-Za-z0-9/])$"
); );
return validIP.test(this.server) || validHostname.test(this.server); return validIP.test(this.server) || validHostname.test(this.server);
} }

View File

@@ -398,9 +398,9 @@ export default {
firebase firebase
.auth() .auth()
.signInWithPopup(provider) .signInWithPopup(provider)
.then(res => { .then(({ additionalUserInfo }) => {
if (res.additionalUserInfo.isNewUser) { if (additionalUserInfo.isNewUser) {
this.$toast.info(this.$t("turn_on") + " " + this.$t("sync"), { this.$toast.info(`${this.$t("turn_on")} ${this.$t("sync")}`, {
icon: "sync", icon: "sync",
duration: null, duration: null,
closeOnSwipe: false, closeOnSwipe: false,
@@ -427,9 +427,9 @@ export default {
firebase firebase
.auth() .auth()
.signInWithPopup(provider) .signInWithPopup(provider)
.then(res => { .then(({ additionalUserInfo }) => {
if (res.additionalUserInfo.isNewUser) { if (additionalUserInfo.isNewUser) {
this.$toast.info(this.$t("turn_on") + " " + this.$t("sync"), { this.$toast.info(`${this.$t("turn_on")} ${this.$t("sync")}`, {
icon: "sync", icon: "sync",
duration: null, duration: null,
closeOnSwipe: false, closeOnSwipe: false,
@@ -458,14 +458,14 @@ export default {
fb.writeSettings("syncHistory", true); fb.writeSettings("syncHistory", true);
fb.writeSettings("syncCollections", false); fb.writeSettings("syncCollections", false);
}, },
resetProxy(e) { resetProxy({ target }) {
this.settings.PROXY_URL = `https://postwoman.apollotv.xyz/`; this.settings.PROXY_URL = `https://postwoman.apollotv.xyz/`;
e.target.innerHTML = this.doneButton; target.innerHTML = this.doneButton;
this.$toast.info(this.$t("cleared"), { this.$toast.info(this.$t("cleared"), {
icon: "clear_all" icon: "clear_all"
}); });
setTimeout( setTimeout(
() => (e.target.innerHTML = '<i class="material-icons">clear_all</i>'), () => (target.innerHTML = '<i class="material-icons">clear_all</i>'),
1000 1000
); );
} }