rm unused service-worker, format all files

This commit is contained in:
Collin M. Barrett 2019-07-27 12:48:21 -05:00
parent 577b88fa4e
commit bf0b27447c
39 changed files with 190 additions and 345 deletions

View file

@ -6,20 +6,20 @@ interface IProps {
export const Layout = (props: IProps) =>
<div className="container">
<Header/>
<Header />
<div className="row">
<div className="w-100">
{ props.children }
{props.children}
</div>
</div>
<Footer/>
<Footer />
</div>;
const Header = () =>
<header className="row">
<h1>
<a href="./">
<img src="logo_filterlists.png" alt="FilterLists" className="img-fluid"/>
<img src="logo_filterlists.png" alt="FilterLists" className="img-fluid" />
</a>
</h1>
</header>;
@ -27,13 +27,13 @@ const Header = () =>
const Footer = () =>
<footer className="row justify-content-center">
<p className="mt-2 ml-1 mr-1">
<HubLink/> | <GitHubLink/> | <ApiLink/> | <DonateLink/> | By <OwnerLink/>
<HubLink /> | <GitHubLink /> | <ApiLink /> | <DonateLink /> | By <OwnerLink />
</p>
</footer>;
const HubLink = () =>
<a href="https://hub.filterlists.com"
title="Discourse community forum">
title="Discourse community forum">
Hub
</a>;
@ -44,13 +44,13 @@ const GitHubLink = () =>
const ApiLink = () =>
<a href="/api/v1/lists"
title="API lists endpoint">
title="API lists endpoint">
API
</a>;
const DonateLink = () =>
<a href="https://beerpay.io/collinbarrett/FilterLists"
title="Support with Beerpay">
title="Support with Beerpay">
Donate
</a>;

View file

@ -4,10 +4,10 @@ import { Route, Redirect, Switch } from "react-router-dom";
import { Home } from "./modules";
export const Routes = <Layout>
<Switch>
<Route exact path="/" component={Home}/>
<Route>
<Redirect to="/"/>
</Route>
</Switch>
</Layout>;
<Switch>
<Route exact path="/" component={Home} />
<Route>
<Redirect to="/" />
</Route>
</Switch>
</Layout>;

View file

@ -2,11 +2,5 @@ import React from 'react';
import ReactDOM from 'react-dom';
import './index.css';
import App from './App';
import * as serviceWorker from './serviceWorker';
ReactDOM.render(<App />, document.getElementById('root'));
// If you want your app to work offline and load faster, you can change
// unregister() to register() below. Note this comes with some pitfalls.
// Learn more about service workers: https://bit.ly/CRA-PWA
serviceWorker.unregister();
ReactDOM.render(<App />, document.getElementById('root'));

View file

@ -38,7 +38,7 @@ export class HomeContainer extends React.Component<{}, IState> {
componentDidMount() {
this.fetchLists();
this.fetchLanguages();
this.fetchLicenses();
this.fetchLicenses();
this.fetchMaintainers();
this.fetchSoftware();
this.fetchSyntaxes();

View file

@ -7,11 +7,11 @@ interface IProps {
export const Oneliner = (props: IProps) =>
props.listCount > 0/* && props.ruleCount > 0*/
? <p className="ml-2 mr-2">
? <p className="ml-2 mr-2">
The independent, comprehensive directory of {/*}<strong>{props.ruleCount.toLocaleString()
}</strong> unique rules across */}<strong>{props.listCount.toLocaleString()
}</strong> filter and host lists for advertisements, trackers, malware, and annoyances.
}</strong> filter and host lists for advertisements, trackers, malware, and annoyances.
</p>
: <p className="ml-2 mr-2">
The independent, comprehensive directory of filter and host lists for advertisements, trackers, malware, and annoyances.
: <p className="ml-2 mr-2">
The independent, comprehensive directory of filter and host lists for advertisements, trackers, malware, and annoyances.
</p>;

View file

@ -8,10 +8,10 @@ interface IProps {
export const TagGroup = (props: IProps) =>
props.tags && props.tags.length > 0
? <div className="fl-wrap-cell">
{props.tags.map((t: ITag, i: number) => <Tag tag={t} key={i}/>)}
</div>
: null;
? <div className="fl-wrap-cell">
{props.tags.map((t: ITag, i: number) => <Tag tag={t} key={i} />)}
</div>
: null;
interface ITagProps {
tag: ITag;
@ -21,13 +21,13 @@ const Tag = (props: ITagProps) => {
if (props.tag) {
const hexColor = kelly_colors_hex[props.tag.id % kelly_colors_hex.length];
return <span className="badge"
style={{
backgroundColor: `#${hexColor}`,
color: getContrast(hexColor)
}}
title={props.tag.description}>
{props.tag.name}
</span>;
style={{
backgroundColor: `#${hexColor}`,
color: getContrast(hexColor)
}}
title={props.tag.description}>
{props.tag.name}
</span>;
} else {
return null;
}

View file

@ -28,14 +28,14 @@ interface IProps {
export const LinkButtonGroup = (props: IProps) =>
<div className="col-3 p-0 btn-group-vertical justify-content-start d-flex align-items-end">
<SubscribeButtonGroup name={props.name} url={props.viewUrl} urlMirrors={props.viewUrlMirrors}/>
<ViewButtonGroup name={props.name} url={props.viewUrl} urlMirrors={props.viewUrlMirrors}/>
<HomeButton name={props.name} url={props.homeUrl}/>
<PolicyButton name={props.name} url={props.policyUrl}/>
<DonateButton name={props.name} url={props.donateUrl}/>
<IssuesButton name={props.name} url={props.issuesUrl}/>
<ForumButton name={props.name} url={props.forumUrl}/>
<ChatButton name={props.name} url={props.chatUrl}/>
<SubmitButton name={props.name} url={props.submissionUrl}/>
<EmailButton name={props.name} emailAddress={props.emailAddress}/>
<SubscribeButtonGroup name={props.name} url={props.viewUrl} urlMirrors={props.viewUrlMirrors} />
<ViewButtonGroup name={props.name} url={props.viewUrl} urlMirrors={props.viewUrlMirrors} />
<HomeButton name={props.name} url={props.homeUrl} />
<PolicyButton name={props.name} url={props.policyUrl} />
<DonateButton name={props.name} url={props.donateUrl} />
<IssuesButton name={props.name} url={props.issuesUrl} />
<ForumButton name={props.name} url={props.forumUrl} />
<ChatButton name={props.name} url={props.chatUrl} />
<SubmitButton name={props.name} url={props.submissionUrl} />
<EmailButton name={props.name} emailAddress={props.emailAddress} />
</div>;

View file

@ -8,9 +8,9 @@ interface IProps {
export const Description = (props: IProps) =>
props.description
? <h3 className="card-header fl-description">
{props.url
? <blockquote cite={props.url} className="m-0">{props.description}</blockquote>
: props.description}
</h3>
: null;
? <h3 className="card-header fl-description">
{props.url
? <blockquote cite={props.url} className="m-0">{props.description}</blockquote>
: props.description}
</h3>
: null;

View file

@ -6,7 +6,7 @@ interface IProps {
export const RuleCount = (props: IProps) =>
props.ruleCount > 0
? <li className="list-group-item">
<p>Rule Count: {props.ruleCount.toLocaleString()}</p>
</li>
: null;
? <li className="list-group-item">
<p>Rule Count: {props.ruleCount.toLocaleString()}</p>
</li>
: null;

View file

@ -2,4 +2,4 @@
export {
InfoCard
};
};

View file

@ -10,7 +10,7 @@ interface IProps {
export const MaintainerLinkButtonGroup = (props: IProps) =>
<div className="col-3 p-0 btn-group-vertical justify-content-start d-flex align-items-end" role="group">
<HomeButton {...props} url={props.homeUrl}/>
<EmailButton {...props}/>
<TwitterButton {...props}/>
<HomeButton {...props} url={props.homeUrl} />
<EmailButton {...props} />
<TwitterButton {...props} />
</div>;

View file

@ -2,4 +2,4 @@
export {
MaintainersInfoCard
};
};

View file

@ -6,4 +6,4 @@ export {
DetailsExpander,
ListsTable,
Oneliner
};
};

View file

@ -8,7 +8,7 @@ interface IProps {
export const ChatButton = (props: IProps) =>
props.url
? <LinkButton href={props.url}
title={`Enter the chat room for ${props.name}.`}
text="Chat"/>
: null;
? <LinkButton href={props.url}
title={`Enter the chat room for ${props.name}.`}
text="Chat" />
: null;

View file

@ -8,7 +8,7 @@ interface IProps {
export const DonateButton = (props: IProps) =>
props.url
? <LinkButton href={props.url}
title={`Donate to the maintainer of ${props.name}.`}
text="Donate"/>
: null;
? <LinkButton href={props.url}
title={`Donate to the maintainer of ${props.name}.`}
text="Donate" />
: null;

View file

@ -8,7 +8,7 @@ interface IProps {
export const EmailButton = (props: IProps) =>
props.emailAddress
? <LinkButton href={`mailto:${props.emailAddress}`}
title={`Email ${props.name}.`}
text="Email"/>
: null;
? <LinkButton href={`mailto:${props.emailAddress}`}
title={`Email ${props.name}.`}
text="Email" />
: null;

View file

@ -8,7 +8,7 @@ interface IProps {
export const ForumButton = (props: IProps) =>
props.url
? <LinkButton href={props.url}
title={`View the forum for ${props.name}.`}
text="Forum"/>
: null;
? <LinkButton href={props.url}
title={`View the forum for ${props.name}.`}
text="Forum" />
: null;

View file

@ -8,7 +8,7 @@ interface IProps {
export const HomeButton = (props: IProps) =>
props.url
? <LinkButton href={props.url}
title={`View ${props.name}'s homepage.`}
text="Home"/>
: null;
? <LinkButton href={props.url}
title={`View ${props.name}'s homepage.`}
text="Home" />
: null;

View file

@ -8,7 +8,7 @@ interface IProps {
export const IssuesButton = (props: IProps) =>
props.url
? <LinkButton href={props.url}
title={`View the GitHub Issues for ${props.name}.`}
text="GH Issues"/>
: null;
? <LinkButton href={props.url}
title={`View the GitHub Issues for ${props.name}.`}
text="GH Issues" />
: null;

View file

@ -10,9 +10,9 @@ interface IProps {
export const LinkButton = (props: IProps) =>
props.href
? <a href={props.href}
title={props.title}
className={`btn ${props.buttonClass || "btn-primary"} fl-btn-link`}>
{props.text}
</a>
: null;
? <a href={props.href}
title={props.title}
className={`btn ${props.buttonClass || "btn-primary"} fl-btn-link`}>
{props.text}
</a>
: null;

View file

@ -8,7 +8,7 @@ interface IProps {
export const PolicyButton = (props: IProps) =>
props.url
? <LinkButton href={props.url}
title={`View the types of rules that ${props.name} includes.`}
text="Policy"/>
: null;
? <LinkButton href={props.url}
title={`View the types of rules that ${props.name} includes.`}
text="Policy" />
: null;

View file

@ -8,7 +8,7 @@ interface IProps {
export const SubmitButton = (props: IProps) =>
props.url
? <LinkButton href={props.url}
title={`Submit a new rule to be included in ${props.name}.`}
text="Submit"/>
: null;
? <LinkButton href={props.url}
title={`Submit a new rule to be included in ${props.name}.`}
text="Submit" />
: null;

View file

@ -10,7 +10,7 @@ interface IProps {
export const SubscribeButton = (props: IProps) => {
let buttonClass: string | undefined;
let titlePrefix: string;
if (props.url.indexOf(".onion/") > 0) {
buttonClass = "btn-success";
titlePrefix = "Tor address - ";
@ -21,42 +21,36 @@ export const SubscribeButton = (props: IProps) => {
buttonClass = undefined;
titlePrefix = "";
}
const hrefTitle = `${encodeURIComponent(props.name)}`;
let href;
if (props.url.indexOf(".tpl") > 0)
{
href = `javascript:window.external.msAddTrackingProtectionList('${encodeURIComponent(props.url)}', '${hrefTitle}')`;
} else if (props.url.indexOf(".lsrules") > 0)
{
href = `x-littlesnitch:subscribe-rules?url=${encodeURIComponent(props.url)}`;
} else if (props.url.indexOf("?hostformat=littlesnitch") > 0)
{
href = `x-littlesnitch:subscribe-rules?url=${encodeURIComponent(props.url)}`;
} else {
href = `abp:subscribe?location=${encodeURIComponent(props.url)}&amp;title=${hrefTitle}`;
};
if (props.url.indexOf(".tpl") > 0) {
href = `javascript:window.external.msAddTrackingProtectionList('${encodeURIComponent(props.url)}', '${hrefTitle}')`;
} else if (props.url.indexOf(".lsrules") > 0) {
href = `x-littlesnitch:subscribe-rules?url=${encodeURIComponent(props.url)}`;
} else if (props.url.indexOf("?hostformat=littlesnitch") > 0) {
href = `x-littlesnitch:subscribe-rules?url=${encodeURIComponent(props.url)}`;
} else {
href = `abp:subscribe?location=${encodeURIComponent(props.url)}&amp;title=${hrefTitle}`;
};
let title;
if (props.url.indexOf(".tpl") > 0)
{
title = `${titlePrefix}Subscribe to ${props.name} with Internet Explorer's Tracking Protection List feature.`;
} else if (props.url.indexOf(".lsrules") > 0)
{
title = `${titlePrefix}Subscribe to ${props.name} with Little Snitch's rule group subscription feature.`;
} else if (props.url.indexOf("?hostformat=littlesnitch") > 0)
{
title = `${titlePrefix}Subscribe to ${props.name} with Little Snitch's rule group subscription feature.`;
} else {
title = `${titlePrefix}Subscribe to ${props.name} with a browser extension supporting the "abp:" protocol (e.g. uBlock Origin, Adblock Plus).`;
};
if (props.url.indexOf(".tpl") > 0) {
title = `${titlePrefix}Subscribe to ${props.name} with Internet Explorer's Tracking Protection List feature.`;
} else if (props.url.indexOf(".lsrules") > 0) {
title = `${titlePrefix}Subscribe to ${props.name} with Little Snitch's rule group subscription feature.`;
} else if (props.url.indexOf("?hostformat=littlesnitch") > 0) {
title = `${titlePrefix}Subscribe to ${props.name} with Little Snitch's rule group subscription feature.`;
} else {
title = `${titlePrefix}Subscribe to ${props.name} with a browser extension supporting the "abp:" protocol (e.g. uBlock Origin, Adblock Plus).`;
};
return props.url
? <LinkButton href={href}
title={title}
buttonClass={buttonClass}
text={props.text || "Subscribe"}/>
: null;
? <LinkButton href={href}
title={title}
buttonClass={buttonClass}
text={props.text || "Subscribe"} />
: null;
};

View file

@ -9,11 +9,11 @@ interface IProps {
export const SubscribeButtonGroup = (props: IProps) =>
props.url
? (props.urlMirrors && props.urlMirrors.length > 0)
? <SubscribeButtonGroupDropdown {...props} urlMirrors={props
.urlMirrors}/>
: <SubscribeButton {...props}/>
: null;
? (props.urlMirrors && props.urlMirrors.length > 0)
? <SubscribeButtonGroupDropdown {...props} urlMirrors={props
.urlMirrors} />
: <SubscribeButton {...props} />
: null;
interface ISubscribeButtonGroupDropdownProps {
name: string;
@ -31,22 +31,22 @@ const SubscribeButtonGroupDropdown = (props: ISubscribeButtonGroupDropdownProps)
}
return <div className="btn-group-vertical dropleft fl-btn-link" role="group">
<BtnGroupDropSubscribe/>
<div className="dropdown-menu" aria-labelledby="btnGroupDropSubscribe">
<SubscribeButton {...props} text={firstButtonText}/>
{props.urlMirrors.map(
(m: string, i: number) =>
<SubscribeButton {...props} url={m} text={`Mirror ${i + 1 + mirrorIndex}`} key={i}/>)}
</div>
</div>;
<BtnGroupDropSubscribe />
<div className="dropdown-menu" aria-labelledby="btnGroupDropSubscribe">
<SubscribeButton {...props} text={firstButtonText} />
{props.urlMirrors.map(
(m: string, i: number) =>
<SubscribeButton {...props} url={m} text={`Mirror ${i + 1 + mirrorIndex}`} key={i} />)}
</div>
</div>;
};
const BtnGroupDropSubscribe = () =>
<button id="btnGroupDropSubscribe"
type="button"
className="btn btn-primary dropdown-toggle"
data-toggle="dropdown"
aria-haspopup="true"
aria-expanded="false">
type="button"
className="btn btn-primary dropdown-toggle"
data-toggle="dropdown"
aria-haspopup="true"
aria-expanded="false">
Subscribe
</button>;

View file

@ -8,7 +8,7 @@ interface IProps {
export const TwitterButton = (props: IProps) =>
props.twitterHandle
? <LinkButton href={`https://twitter.com/${props.twitterHandle}`}
title={`View ${props.name}'s Twitter profile.`}
text="Twitter"/>
: null;
? <LinkButton href={`https://twitter.com/${props.twitterHandle}`}
title={`View ${props.name}'s Twitter profile.`}
text="Twitter" />
: null;

View file

@ -8,7 +8,7 @@ interface IProps {
};
export const ViewButton = (props: IProps) => {
let title;
if (props.url.indexOf(".onion/") > 0) { title = `Tor address - View ${props.name} in its raw format.`; }
else if (props.url.indexOf(".zip") > 0) { title = `Download ${props.name} as a ZIP compressed archive.`; }
@ -16,9 +16,9 @@ export const ViewButton = (props: IProps) => {
else if (props.url.indexOf(".tar.gz") > 0) { title = `Download ${props.name} as a compressed tarball archive.`; }
else { title = `View ${props.name} in its raw format`; };
return props.url
? <LinkButton href={props.url}
title={title}
text={props.text || "View"}/>
: null;
return props.url
? <LinkButton href={props.url}
title={title}
text={props.text || "View"} />
: null;
}

View file

@ -9,10 +9,10 @@ interface IProps {
export const ViewButtonGroup = (props: IProps) =>
props.url
? (props.urlMirrors && props.urlMirrors.length > 0)
? <ViewButtonGroupDropdown {...props} urlMirrors={props.urlMirrors}/>
: <ViewButton {...props}/>
: null;
? (props.urlMirrors && props.urlMirrors.length > 0)
? <ViewButtonGroupDropdown {...props} urlMirrors={props.urlMirrors} />
: <ViewButton {...props} />
: null;
interface IViewButtonGroupDropdownProps {
name: string;
@ -30,22 +30,22 @@ const ViewButtonGroupDropdown = (props: IViewButtonGroupDropdownProps) => {
}
return <div className="btn-group-vertical dropleft fl-btn-link" role="group">
<BtnGroupDropView/>
<div className="dropdown-menu" aria-labelledby="btnGroupDropView">
<ViewButton {...props} text={firstButtonText}/>
{props.urlMirrors.map(
(m: string, i: number) =>
<ViewButton {...props} url={m} text={`Mirror ${i + 1 + mirrorIndex}`} key={i}/>)}
</div>
</div>;
<BtnGroupDropView />
<div className="dropdown-menu" aria-labelledby="btnGroupDropView">
<ViewButton {...props} text={firstButtonText} />
{props.urlMirrors.map(
(m: string, i: number) =>
<ViewButton {...props} url={m} text={`Mirror ${i + 1 + mirrorIndex}`} key={i} />)}
</div>
</div>;
};
const BtnGroupDropView = () =>
<button id="btnGroupDropView"
type="button"
className="btn btn-primary dropdown-toggle"
data-toggle="dropdown"
aria-haspopup="true"
aria-expanded="false">
type="button"
className="btn btn-primary dropdown-toggle"
data-toggle="dropdown"
aria-haspopup="true"
aria-expanded="false">
View
</button>;

View file

@ -22,4 +22,4 @@ export {
SubscribeButtonGroup,
TwitterButton,
ViewButtonGroup
};
};

View file

@ -15,12 +15,12 @@ export const DetailsButton = {
const Expander = (props: RowRenderProps) =>
<div>
{props.isExpanded
? <button className="btn btn-primary btn-block active fl-btn-link"
title={`Collapse details about ${props.row.name}.`}>
Details
? <button className="btn btn-primary btn-block active fl-btn-link"
title={`Collapse details about ${props.row.name}.`}>
Details
</button>
: <button className="btn btn-primary btn-block fl-btn-link"
title={`Learn more about ${props.row.name}.`}>
Details
: <button className="btn btn-primary btn-block fl-btn-link"
title={`Learn more about ${props.row.name}.`}>
Details
</button>}
</div>;

View file

@ -18,5 +18,5 @@ const sortMethod = (a: string, b: string) =>
const Cell = (name: string) =>
name
? <h2 className="mb-0">{name}</h2>
: null;
? <h2 className="mb-0">{name}</h2>
: null;

View file

@ -22,4 +22,4 @@ export {
Syntax,
Tags,
UpdatedDate
};
};

View file

@ -2,4 +2,4 @@
export {
ListsTable,
};
};

View file

@ -41,11 +41,11 @@ interface IProps {
export const SoftwareIcon = (props: IProps) =>
icons[props.id]
? <img src={icons[props.id].image}
height="20"
alt={icons[props.id].imageTitle}
title={icons[props.id].imageTitle}/>
: null;
? <img src={icons[props.id].image}
height="20"
alt={icons[props.id].imageTitle}
title={icons[props.id].imageTitle} />
: null;
interface IIcon {
image: any;

View file

@ -66,4 +66,4 @@ export {
img32,
img33,
img34
};
};

View file

@ -2,4 +2,4 @@
export {
SoftwareIcon
};
};

View file

@ -2,4 +2,4 @@
export {
HomeContainer as Home
};
};

View file

@ -2,4 +2,4 @@
export {
Home
};
};

View file

@ -1,143 +0,0 @@
// This optional code is used to register a service worker.
// register() is not called by default.
// This lets the app load faster on subsequent visits in production, and gives
// it offline capabilities. However, it also means that developers (and users)
// will only see deployed updates on subsequent visits to a page, after all the
// existing tabs open on the page have been closed, since previously cached
// resources are updated in the background.
// To learn more about the benefits of this model and instructions on how to
// opt-in, read https://bit.ly/CRA-PWA
const isLocalhost = Boolean(
window.location.hostname === 'localhost' ||
// [::1] is the IPv6 localhost address.
window.location.hostname === '[::1]' ||
// 127.0.0.1/8 is considered localhost for IPv4.
window.location.hostname.match(
/^127(?:\.(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)){3}$/
)
);
type Config = {
onSuccess?: (registration: ServiceWorkerRegistration) => void;
onUpdate?: (registration: ServiceWorkerRegistration) => void;
};
export function register(config?: Config) {
if (process.env.NODE_ENV === 'production' && 'serviceWorker' in navigator) {
// The URL constructor is available in all browsers that support SW.
const publicUrl = new URL(
(process as { env: { [key: string]: string } }).env.PUBLIC_URL,
window.location.href
);
if (publicUrl.origin !== window.location.origin) {
// Our service worker won't work if PUBLIC_URL is on a different origin
// from what our page is served on. This might happen if a CDN is used to
// serve assets; see https://github.com/facebook/create-react-app/issues/2374
return;
}
window.addEventListener('load', () => {
const swUrl = `${process.env.PUBLIC_URL}/service-worker.js`;
if (isLocalhost) {
// This is running on localhost. Let's check if a service worker still exists or not.
checkValidServiceWorker(swUrl, config);
// Add some additional logging to localhost, pointing developers to the
// service worker/PWA documentation.
navigator.serviceWorker.ready.then(() => {
console.log(
'This web app is being served cache-first by a service ' +
'worker. To learn more, visit https://bit.ly/CRA-PWA'
);
});
} else {
// Is not localhost. Just register service worker
registerValidSW(swUrl, config);
}
});
}
}
function registerValidSW(swUrl: string, config?: Config) {
navigator.serviceWorker
.register(swUrl)
.then(registration => {
registration.onupdatefound = () => {
const installingWorker = registration.installing;
if (installingWorker == null) {
return;
}
installingWorker.onstatechange = () => {
if (installingWorker.state === 'installed') {
if (navigator.serviceWorker.controller) {
// At this point, the updated precached content has been fetched,
// but the previous service worker will still serve the older
// content until all client tabs are closed.
console.log(
'New content is available and will be used when all ' +
'tabs for this page are closed. See https://bit.ly/CRA-PWA.'
);
// Execute callback
if (config && config.onUpdate) {
config.onUpdate(registration);
}
} else {
// At this point, everything has been precached.
// It's the perfect time to display a
// "Content is cached for offline use." message.
console.log('Content is cached for offline use.');
// Execute callback
if (config && config.onSuccess) {
config.onSuccess(registration);
}
}
}
};
};
})
.catch(error => {
console.error('Error during service worker registration:', error);
});
}
function checkValidServiceWorker(swUrl: string, config?: Config) {
// Check if the service worker can be found. If it can't reload the page.
fetch(swUrl)
.then(response => {
// Ensure service worker exists, and that we really are getting a JS file.
const contentType = response.headers.get('content-type');
if (
response.status === 404 ||
(contentType != null && contentType.indexOf('javascript') === -1)
) {
// No service worker found. Probably a different app. Reload the page.
navigator.serviceWorker.ready.then(registration => {
registration.unregister().then(() => {
window.location.reload();
});
});
} else {
// Service worker found. Proceed as normal.
registerValidSW(swUrl, config);
}
})
.catch(() => {
console.log(
'No internet connection found. App is running in offline mode.'
);
});
}
export function unregister() {
if ('serviceWorker' in navigator) {
navigator.serviceWorker.ready.then(registration => {
registration.unregister();
});
}
}

View file

@ -2,4 +2,4 @@
export {
getContrast
};
};