Merge pull request #578 from liyasthomas/refactor/lint

Refactor/lint
This commit is contained in:
Liyas Thomas
2020-02-20 10:12:53 +05:30
committed by GitHub
9 changed files with 90 additions and 74 deletions

View File

@@ -22,13 +22,11 @@ $responsiveWidth: 768px;
::-webkit-scrollbar {
width: 4px;
height: 4px;
border-radius: 4px;
background-color: var(--bg-light-color);
background-color: var(--bg-dark-color);
}
::-webkit-scrollbar-thumb {
background-color: var(--fg-light-color);
border-radius: 8px;
&:hover {
background-color: var(--fg-color);
@@ -62,7 +60,6 @@ body {
scroll-behavior: smooth;
}
// Make theme transition smoother.
body.afterLoad {
transition: background-color 0.2s ease-in-out;
}
@@ -76,6 +73,10 @@ a {
color: inherit;
text-decoration: none;
transition: all 0.2s ease-in-out;
&.link {
color: var(--ac-color);
}
}
header,
@@ -146,7 +147,8 @@ footer {
z-index: 1;
height: 100vh;
padding: 0 8px;
background-color: var(--bg-light-color);
background-color: var(--bg-dark-color);
transition: all 0.2s ease-in-out;
}
.main {
@@ -186,7 +188,6 @@ nav.primary-nav {
color: var(--fg-light-color);
fill: var(--fg-light-color);
margin: 8px 0;
transition: all 0.2s ease-in-out;
&:hover {
color: var(--fg-color);
@@ -422,7 +423,6 @@ button {
color: var(--act-color);
fill: var(--act-color);
box-shadow: inset 0 0 0 2px var(--fg-color);
transition: all 0.2s ease-in-out;
}
&.icon {
@@ -437,7 +437,6 @@ button {
color: var(--fg-color);
fill: var(--fg-color);
box-shadow: none;
transition: all 0.2s ease-in-out;
}
}
@@ -472,7 +471,6 @@ button {
fieldset {
margin: 16px 0;
border-radius: 16px;
transition: all 0.2s ease-in-out;
background-color: var(--bg-dark-color);
}
@@ -565,7 +563,6 @@ code {
&:not([readonly]):not(.ace_editor):active,
&:not([readonly]):not(.ace_editor):focus {
box-shadow: inset 0 0 0 2px var(--fg-light-color);
transition: all 0.2s ease-in-out;
}
}
@@ -576,7 +573,6 @@ code {
&:active,
&:focus {
box-shadow: inset 0 0 0 2px var(--fg-light-color);
transition: all 0.2s ease-in-out;
}
}
@@ -884,18 +880,19 @@ input[type="radio"]:checked + label + .tab {
padding: 0;
width: 100%;
background-color: var(--bg-color);
transition: all 0.2s ease-in-out;
box-shadow: 0 2px 6px 0 rgba(0, 0, 0, 0.45);
}
nav.primary-nav {
flex-flow: row nowrap;
overflow: auto;
justify-content: space-around;
justify-content: space-between;
background-color: var(--bg-dark-color);
a {
background-color: transparent;
margin: 8px;
flex: 1;
&.nuxt-link-exact-active {
background-color: transparent;

View File

@@ -20,6 +20,7 @@
border-radius: 100%;
border: 3px solid var(--bg-dark-color);
cursor: pointer;
transition: all 0.2s ease-in-out;
&.fg {
color: var(--act-color);

View File

@@ -121,4 +121,4 @@ export const commonHeaders = [
"X-Requested-With",
"X-Robots-Tag",
"X-UA-Compatible"
]
];

View File

@@ -1,16 +1,17 @@
import AxiosStrategy from "./strategies/AxiosStrategy";
import ExtensionStrategy from "./strategies/ExtensionStrategy";
import FirefoxStrategy from "./strategies/FirefoxStrategy";
import ChromeStrategy, { hasChromeExtensionInstalled } from "./strategies/ChromeStrategy";
import ChromeStrategy, {
hasChromeExtensionInstalled
} from "./strategies/ChromeStrategy";
const isExtensionsAllowed = ({ state }) => {
return typeof state.postwoman.settings.EXTENSIONS_ENABLED === 'undefined'
|| state.postwoman.settings.EXTENSIONS_ENABLED;
}
const isExtensionsAllowed = ({ state }) =>
typeof state.postwoman.settings.EXTENSIONS_ENABLED === "undefined" ||
state.postwoman.settings.EXTENSIONS_ENABLED;
const runAppropriateStrategy = (req, store) => {
if (isExtensionsAllowed(store)) {
if (typeof window.__POSTWOMAN_EXTENSION_HOOK__ !== 'undefined') {
if (typeof window.__POSTWOMAN_EXTENSION_HOOK__ !== "undefined") {
return ExtensionStrategy(req, store);
}
@@ -19,7 +20,7 @@ const runAppropriateStrategy = (req, store) => {
// Chrome Provides a chrome object for scripts to access
// Check its availability to say whether you are in Google Chrome
if (window.chrome && hasChromeExtensionInstalled()) {
return ChromeStrategy(req, store);
return ChromeStrategy(req, store);
}
// The firefox plugin injects a function to send requests through it
// If that is available, then we can use the FirefoxStrategy
@@ -29,10 +30,11 @@ const runAppropriateStrategy = (req, store) => {
}
return AxiosStrategy(req, store);
}
};
const sendNetworkRequest = (req, store) =>
runAppropriateStrategy(req, store)
.finally(() => window.$nuxt.$loading.finish());
runAppropriateStrategy(req, store).finally(() =>
window.$nuxt.$loading.finish()
);
export { sendNetworkRequest };

View File

@@ -3,47 +3,54 @@ const EXTENSION_ID = "amknoiejhlmhancpahfcfcfhllgkpbld";
// Check if the Chrome Extension is present
// The Chrome extension injects an empty span to help detection.
// Also check for the presence of window.chrome object to confirm smooth operations
export const hasChromeExtensionInstalled = () => {
return document.getElementById("chromePWExtensionDetect") !== null;
}
export const hasChromeExtensionInstalled = () =>
document.getElementById("chromePWExtensionDetect") !== null;
const chromeWithoutProxy = (req, _store) => new Promise((resolve, reject) => {
chrome.runtime.sendMessage(
EXTENSION_ID, {
messageType: "send-req",
data: {
config: req
}
}, (message) => {
if (message.data.error) {
reject(message.data.error);
} else {
resolve(message.data.response);
}
}
);
});
const chromeWithProxy = (req, { state }) => new Promise((resolve, reject) => {
chrome.runtime.sendMessage(
EXTENSION_ID, {
messageType: "send-req",
data: {
config: {
method: "post",
url: state.postwoman.settings.PROXY_URL || "https://postwoman.apollotv.xyz/",
data: req
const chromeWithoutProxy = (req, _store) =>
new Promise((resolve, reject) => {
chrome.runtime.sendMessage(
EXTENSION_ID,
{
messageType: "send-req",
data: {
config: req
}
},
({ data }) => {
if (data.error) {
reject(data.error);
} else {
resolve(data.response);
}
}
}, (message) => {
if (message.data.error) {
reject(error);
} else {
resolve(message.data.response.data);
);
});
const chromeWithProxy = (req, { state }) =>
new Promise((resolve, reject) => {
chrome.runtime.sendMessage(
EXTENSION_ID,
{
messageType: "send-req",
data: {
config: {
method: "post",
url:
state.postwoman.settings.PROXY_URL ||
"https://postwoman.apollotv.xyz/",
data: req
}
}
},
({ data }) => {
if (data.error) {
reject(error);
} else {
resolve(data.response.data);
}
}
}
)
});
);
});
const chromeStrategy = (req, store) => {
if (store.state.postwoman.settings.PROXY_ENABLED) {
@@ -51,6 +58,6 @@ const chromeStrategy = (req, store) => {
} else {
return chromeWithoutProxy(req, store);
}
}
};
export default chromeStrategy;

View File

@@ -1,7 +1,8 @@
const extensionWithProxy = async (req, { state }) => {
const { data } = await window.__POSTWOMAN_EXTENSION_HOOK__.sendRequest({
method: "post",
url: state.postwoman.settings.PROXY_URL || "https://postwoman.apollotv.xyz/",
url:
state.postwoman.settings.PROXY_URL || "https://postwoman.apollotv.xyz/",
data: req
});
return data;

View File

@@ -408,7 +408,7 @@
<div class="flex-wrap">
<span v-if="version.name" class="mono">
<a
class="link"
class="footer-link"
:href="
'https://github.com/liyasthomas/postwoman/releases/tag/' +
version.name
@@ -420,7 +420,7 @@
{{ version.name }}
</a>
<a
class="link hide-on-small-screen"
class="footer-link hide-on-small-screen"
href="https://www.netlify.com"
target="_blank"
rel="noopener"
@@ -660,7 +660,7 @@
</template>
<style scoped lang="scss">
.link {
.footer-link {
margin: 8px 16px;
}
</style>
@@ -715,7 +715,7 @@ export default {
.then(() => {})
.catch(console.error);
} else {
// fallback
// fallback
}
}
},

View File

@@ -206,7 +206,12 @@
{{ $t("postwoman_official_proxy_hosting") }}
<br />
{{ $t("read_the") }}
<a href="https://apollotv.xyz/legal" target="_blank" rel="noopener">
<a
class="link"
href="https://apollotv.xyz/legal"
target="_blank"
rel="noopener"
>
{{ $t("apollotv_privacy_policy") }} </a
>.
</p>

View File

@@ -57,11 +57,11 @@ export const SETTINGS_KEYS = [
* e.g. 'auth'
*/
"URL_EXCLUDES",
/**
* A boolean value indicating whether to use the browser extensions
* to run the requests
*/
*/
"EXTENSIONS_ENABLED"
];
@@ -118,7 +118,9 @@ export const mutations = {
addNewCollection({ collections }, collection) {
const { name } = collection;
const duplicateCollection = collections.some(item => item.name.toLowerCase() === name.toLowerCase());
const duplicateCollection = collections.some(
item => item.name.toLowerCase() === name.toLowerCase()
);
if (duplicateCollection) {
this.$toast.info("Duplicate collection");
return;
@@ -137,9 +139,10 @@ export const mutations = {
},
editCollection({ collections }, payload) {
const { collection, collectionIndex } = payload;
const { name } = collection;
const duplicateCollection = collections.some(item => item.name.toLowerCase() === name.toLowerCase());
const { collection: { name }, collectionIndex } = payload;
const duplicateCollection = collections.some(
item => item.name.toLowerCase() === name.toLowerCase()
);
if (duplicateCollection) {
this.$toast.info("Duplicate collection");
return;