Fix bugs caused by merge
Also formatted using Prettier
This commit is contained in:
parent
eb56ac3699
commit
4a58f79270
11 changed files with 356 additions and 345 deletions
16
src/App.js
16
src/App.js
|
@ -1,13 +1,13 @@
|
||||||
import React from "react";
|
import React from 'react';
|
||||||
import styled, { createGlobalStyle } from "styled-components";
|
import styled, { createGlobalStyle } from 'styled-components';
|
||||||
|
|
||||||
import SearchBar from "./components/searchBar";
|
import SearchBar from './components/searchBar';
|
||||||
import Greeter from "./components/greeter";
|
import Greeter from './components/greeter';
|
||||||
import AppList from "./components/appList";
|
import AppList from './components/appList';
|
||||||
import BookmarkList from "./components/bookmarkList";
|
import BookmarkList from './components/bookmarkList';
|
||||||
import SettingsModal from "./components/settingsModal";
|
import SettingsModal from './components/settingsModal';
|
||||||
|
|
||||||
import selectedTheme from "./components/themeManager";
|
import selectedTheme from './components/themeManager';
|
||||||
|
|
||||||
const GlobalStyle = createGlobalStyle`
|
const GlobalStyle = createGlobalStyle`
|
||||||
body {
|
body {
|
||||||
|
|
|
@ -1,12 +1,10 @@
|
||||||
import React from "react";
|
import React, { useCallback, useEffect, useState } from 'react';
|
||||||
import MaterialIcon from "material-icons-react";
|
import MaterialIcon from 'material-icons-react';
|
||||||
import styled from "styled-components";
|
import styled from 'styled-components';
|
||||||
|
|
||||||
import appData from "./data/apps.json";
|
import selectedTheme from './themeManager';
|
||||||
|
|
||||||
import selectedTheme from "./themeManager";
|
import { Headline, ListContainer, ItemList, Item, Button } from './elements';
|
||||||
|
|
||||||
import { Headline, ListContainer, ItemList, Item } from "./elements";
|
|
||||||
|
|
||||||
const IconContainer = styled.div`
|
const IconContainer = styled.div`
|
||||||
margin-right: 0.5vh;
|
margin-right: 0.5vh;
|
||||||
|
@ -61,10 +59,10 @@ function useAppData() {
|
||||||
? fetch('/apps.json').then(handleResponse)
|
? fetch('/apps.json').then(handleResponse)
|
||||||
: import('./data/apps.json')
|
: import('./data/apps.json')
|
||||||
)
|
)
|
||||||
.then((jsonResponse) => {
|
.then(jsonResponse => {
|
||||||
setAppData({ ...jsonResponse, error: false });
|
setAppData({ ...jsonResponse, error: false });
|
||||||
})
|
})
|
||||||
.catch((error) => {
|
.catch(error => {
|
||||||
setAppData({ apps: [], error: error.message });
|
setAppData({ apps: [], error: error.message });
|
||||||
});
|
});
|
||||||
}, []);
|
}, []);
|
||||||
|
@ -77,34 +75,36 @@ function useAppData() {
|
||||||
const AppList = () => {
|
const AppList = () => {
|
||||||
const {
|
const {
|
||||||
appData: { apps, error },
|
appData: { apps, error },
|
||||||
fetchAppData,
|
fetchAppData
|
||||||
} = useAppData();
|
} = useAppData();
|
||||||
return (
|
return (
|
||||||
<AppListContainer>
|
<ListContainer>
|
||||||
<ApplicationsText>
|
<Headline>
|
||||||
Applications <Button onClick={fetchAppData}>refresh</Button>
|
Applications <Button onClick={fetchAppData}>refresh</Button>
|
||||||
</ApplicationsText>
|
</Headline>
|
||||||
<AppsContainer>
|
<ItemList>
|
||||||
{error && <ErrorMessage>{error}</ErrorMessage>}
|
{error && <ErrorMessage>{error}</ErrorMessage>}
|
||||||
{apps.map((app, idx) => {
|
{apps.map((app, idx) => {
|
||||||
const { name } = app;
|
const { name } = app;
|
||||||
return (
|
return (
|
||||||
<AppContainer key={[name, idx].join('')}>
|
<Item key={[name, idx].join('')}>
|
||||||
|
<App>
|
||||||
<IconContainer>
|
<IconContainer>
|
||||||
<MaterialIcon
|
<MaterialIcon
|
||||||
icon={app.icon}
|
icon={app.icon}
|
||||||
color={selectedTheme.mainColor}
|
color={selectedTheme.mainColor}
|
||||||
/>
|
/>
|
||||||
</IconContainer>
|
</IconContainer>
|
||||||
<AppDetails>
|
<DetailsContainer>
|
||||||
<Link href={app.URL}>{app.name}</Link>
|
<Link href={app.URL}>{app.name}</Link>
|
||||||
<Description>{app.displayURL}</Description>
|
<Description>{app.displayURL}</Description>
|
||||||
</AppDetails>
|
</DetailsContainer>
|
||||||
</AppContainer>
|
</App>
|
||||||
|
</Item>
|
||||||
);
|
);
|
||||||
})}
|
})}
|
||||||
</AppsContainer>
|
</ItemList>
|
||||||
</AppListContainer>
|
</ListContainer>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -1,10 +1,10 @@
|
||||||
import React from "react";
|
import React from 'react';
|
||||||
import styled from "styled-components";
|
import styled from 'styled-components';
|
||||||
|
|
||||||
import bookmarkData from "./data/bookmarks.json";
|
import bookmarkData from './data/bookmarks.json';
|
||||||
|
|
||||||
import selectedTheme from "./themeManager";
|
import selectedTheme from './themeManager';
|
||||||
import { Headline, ListContainer, ItemList, Item } from "./elements";
|
import { Headline, ListContainer, ItemList, Item } from './elements';
|
||||||
|
|
||||||
const Group = styled.h4`
|
const Group = styled.h4`
|
||||||
font-family: Roboto, sans-serif;
|
font-family: Roboto, sans-serif;
|
||||||
|
@ -38,7 +38,7 @@ const bookmarkList = () => (
|
||||||
<Item key={name}>
|
<Item key={name}>
|
||||||
<BookmarkGroup>
|
<BookmarkGroup>
|
||||||
<Group>{name}</Group>
|
<Group>{name}</Group>
|
||||||
{group.items.map(({ url, name: linkName }) => (
|
{items.map(({ url, name: linkName }) => (
|
||||||
<Bookmark key={linkName} href={url}>
|
<Bookmark key={linkName} href={url}>
|
||||||
{linkName}
|
{linkName}
|
||||||
</Bookmark>
|
</Bookmark>
|
||||||
|
|
|
@ -1,13 +0,0 @@
|
||||||
import styled from 'styled-components';
|
|
||||||
import { selectedTheme } from '../selectedTheme';
|
|
||||||
|
|
||||||
export const Button = styled.button`
|
|
||||||
font-family: Roboto, sans-serif;
|
|
||||||
text-transform: uppercase;
|
|
||||||
font-weight: 400;
|
|
||||||
border: 1px solid ${selectedTheme.mainColor};
|
|
||||||
color: ${selectedTheme.mainColor};
|
|
||||||
background: none;
|
|
||||||
margin-left: 1rem;
|
|
||||||
min-height: 3em;
|
|
||||||
`;
|
|
|
@ -1,11 +1,15 @@
|
||||||
import styled from "styled-components";
|
import React from 'react';
|
||||||
import selectedTheme from "./themeManager";
|
import styled from 'styled-components';
|
||||||
|
import selectedTheme from './themeManager';
|
||||||
|
import MaterialIcon from 'material-icons-react';
|
||||||
|
|
||||||
const ListContainer = styled.div`
|
// File for elements that are/can be reused across the entire site.
|
||||||
|
|
||||||
|
export const ListContainer = styled.div`
|
||||||
padding: 2rem 0 2rem 0;
|
padding: 2rem 0 2rem 0;
|
||||||
`;
|
`;
|
||||||
|
|
||||||
const Headline = styled.h3`
|
export const Headline = styled.h3`
|
||||||
font-family: Roboto, sans-serif;
|
font-family: Roboto, sans-serif;
|
||||||
font-weight: 900;
|
font-weight: 900;
|
||||||
text-transform: uppercase;
|
text-transform: uppercase;
|
||||||
|
@ -14,7 +18,7 @@ const Headline = styled.h3`
|
||||||
color: ${selectedTheme.mainColor};
|
color: ${selectedTheme.mainColor};
|
||||||
`;
|
`;
|
||||||
|
|
||||||
const ItemList = styled.ul`
|
export const ItemList = styled.ul`
|
||||||
display: grid;
|
display: grid;
|
||||||
grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
|
grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
|
||||||
grid-gap: 1rem;
|
grid-gap: 1rem;
|
||||||
|
@ -22,11 +26,46 @@ const ItemList = styled.ul`
|
||||||
list-style: none;
|
list-style: none;
|
||||||
`;
|
`;
|
||||||
|
|
||||||
const Item = styled.li`
|
export const Item = styled.li`
|
||||||
max-height: 100px;
|
max-height: 100px;
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
position: relative;
|
position: relative;
|
||||||
list-style: none;
|
list-style: none;
|
||||||
`;
|
`;
|
||||||
|
|
||||||
export { Headline, ListContainer, ItemList, Item };
|
export const Button = styled.button`
|
||||||
|
font-family: Roboto, sans-serif;
|
||||||
|
text-transform: uppercase;
|
||||||
|
font-weight: 400;
|
||||||
|
border: 1px solid ${selectedTheme.mainColor};
|
||||||
|
color: ${selectedTheme.mainColor};
|
||||||
|
background: none;
|
||||||
|
margin-left: 1rem;
|
||||||
|
min-height: 3em;
|
||||||
|
`;
|
||||||
|
|
||||||
|
const StyledButton = styled.button`
|
||||||
|
float: right;
|
||||||
|
border: none;
|
||||||
|
background: none;
|
||||||
|
`;
|
||||||
|
|
||||||
|
export const IconButton = props => {
|
||||||
|
if (
|
||||||
|
props.icon &&
|
||||||
|
props.icon !== '' &&
|
||||||
|
props.icon !== undefined &&
|
||||||
|
props.onClick &&
|
||||||
|
props.onClick !== '' &&
|
||||||
|
props.onClick !== undefined
|
||||||
|
) {
|
||||||
|
return (
|
||||||
|
<StyledButton onClick={props.onClick}>
|
||||||
|
<MaterialIcon
|
||||||
|
icon={props.icon}
|
||||||
|
color={selectedTheme.mainColor}
|
||||||
|
/>
|
||||||
|
</StyledButton>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
import React from "react";
|
import React from 'react';
|
||||||
import styled from "styled-components";
|
import styled from 'styled-components';
|
||||||
|
|
||||||
import selectedTheme from "./themeManager";
|
import selectedTheme from './themeManager';
|
||||||
|
|
||||||
const GreeterContainer = styled.div`
|
const GreeterContainer = styled.div`
|
||||||
padding: 2rem 0 2rem 0;
|
padding: 2rem 0 2rem 0;
|
||||||
|
@ -29,7 +29,7 @@ const getGreeting = () => {
|
||||||
return 'Hello World!';
|
return 'Hello World!';
|
||||||
};
|
};
|
||||||
|
|
||||||
const getExtension = (day) => {
|
const getExtension = day => {
|
||||||
let extension = '';
|
let extension = '';
|
||||||
|
|
||||||
if ((day > 4 && day <= 20) || (day > 20 && day % 10 >= 4)) {
|
if ((day > 4 && day <= 20) || (day > 20 && day % 10 >= 4)) {
|
||||||
|
@ -57,7 +57,7 @@ const monthNames = [
|
||||||
'September',
|
'September',
|
||||||
'October',
|
'October',
|
||||||
'November',
|
'November',
|
||||||
'December',
|
'December'
|
||||||
];
|
];
|
||||||
|
|
||||||
const weekDayNames = [
|
const weekDayNames = [
|
||||||
|
@ -67,7 +67,7 @@ const weekDayNames = [
|
||||||
'Wednesday',
|
'Wednesday',
|
||||||
'Thursday',
|
'Thursday',
|
||||||
'Friday',
|
'Friday',
|
||||||
'Saturday',
|
'Saturday'
|
||||||
];
|
];
|
||||||
|
|
||||||
const getDateString = () => {
|
const getDateString = () => {
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
import React, { useState } from "react";
|
import React, { useState } from 'react';
|
||||||
import styled from "styled-components";
|
import styled from 'styled-components';
|
||||||
|
|
||||||
import searchData from "./data/search.json";
|
import searchData from './data/search.json';
|
||||||
|
|
||||||
import selectedTheme from "./themeManager";
|
import selectedTheme from './themeManager';
|
||||||
|
|
||||||
const SearchInput = styled.input`
|
const SearchInput = styled.input`
|
||||||
width: 100%;
|
width: 100%;
|
||||||
|
@ -16,13 +16,13 @@ const SearchInput = styled.input`
|
||||||
`;
|
`;
|
||||||
|
|
||||||
const handleQueryWithProvider = query => {
|
const handleQueryWithProvider = query => {
|
||||||
let queryArray = query.split(" ");
|
let queryArray = query.split(' ');
|
||||||
|
|
||||||
let prefix = queryArray[0];
|
let prefix = queryArray[0];
|
||||||
|
|
||||||
queryArray.shift();
|
queryArray.shift();
|
||||||
|
|
||||||
let searchQuery = queryArray.join(" ");
|
let searchQuery = queryArray.join(' ');
|
||||||
|
|
||||||
var foundProvider = false;
|
var foundProvider = false;
|
||||||
searchData.providers.forEach(provider => {
|
searchData.providers.forEach(provider => {
|
||||||
|
@ -33,7 +33,7 @@ const handleQueryWithProvider = query => {
|
||||||
});
|
});
|
||||||
|
|
||||||
if (!foundProvider) {
|
if (!foundProvider) {
|
||||||
window.location = "https://google.com/search?q=" + query;
|
window.location = 'https://google.com/search?q=' + query;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -43,10 +43,10 @@ const SearchBar = () => {
|
||||||
const handleSearchQuery = e => {
|
const handleSearchQuery = e => {
|
||||||
var query = input;
|
var query = input;
|
||||||
|
|
||||||
if (query.split(" ")[0].includes("/")) {
|
if (query.split(' ')[0].includes('/')) {
|
||||||
handleQueryWithProvider(query);
|
handleQueryWithProvider(query);
|
||||||
} else {
|
} else {
|
||||||
window.location = "https://google.com/search?q=" + query;
|
window.location = 'https://google.com/search?q=' + query;
|
||||||
}
|
}
|
||||||
|
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
|
|
|
@ -1,27 +1,13 @@
|
||||||
import React, { useState } from "react";
|
import React, { useState } from 'react';
|
||||||
import MaterialIcon from "material-icons-react";
|
import styled from 'styled-components';
|
||||||
import styled from "styled-components";
|
|
||||||
|
|
||||||
import Select from "react-select";
|
import Select from 'react-select';
|
||||||
|
|
||||||
import searchData from './data/search.json';
|
import searchData from './data/search.json';
|
||||||
import themeData from './data/themes.json';
|
import themeData from './data/themes.json';
|
||||||
|
|
||||||
import selectedTheme, { setTheme } from "./themeManager";
|
import selectedTheme, { setTheme } from './themeManager';
|
||||||
import { Button } from './button';
|
import { Button, IconButton } from './elements';
|
||||||
|
|
||||||
const ModalButton = styled.button`
|
|
||||||
float: right;
|
|
||||||
border: none;
|
|
||||||
background: none;
|
|
||||||
padding: 10px;
|
|
||||||
`;
|
|
||||||
|
|
||||||
const ExitButton = styled.button`
|
|
||||||
float: right;
|
|
||||||
border: none;
|
|
||||||
background: none;
|
|
||||||
`;
|
|
||||||
|
|
||||||
const Modal = styled.div`
|
const Modal = styled.div`
|
||||||
position: absolute;
|
position: absolute;
|
||||||
|
@ -75,36 +61,36 @@ const HeadCell = styled.th`
|
||||||
const SelectorStyle = {
|
const SelectorStyle = {
|
||||||
control: provided => ({
|
control: provided => ({
|
||||||
...provided,
|
...provided,
|
||||||
fontFamily: "Roboto, sans-serif",
|
fontFamily: 'Roboto, sans-serif',
|
||||||
fontWeight: "500",
|
fontWeight: '500',
|
||||||
color: selectedTheme.mainColor,
|
color: selectedTheme.mainColor,
|
||||||
textTransform: "uppercase",
|
textTransform: 'uppercase',
|
||||||
width: "200px",
|
width: '200px',
|
||||||
background: "none",
|
background: 'none',
|
||||||
borderRadius: "0px",
|
borderRadius: '0px',
|
||||||
border: "1px solid " + selectedTheme.mainColor,
|
border: '1px solid ' + selectedTheme.mainColor,
|
||||||
boxShadow: 0,
|
boxShadow: 0,
|
||||||
"&:hover": {
|
'&:hover': {
|
||||||
border: "1px solid " + selectedTheme.mainColor
|
border: '1px solid ' + selectedTheme.mainColor
|
||||||
}
|
}
|
||||||
}),
|
}),
|
||||||
menu: provided => ({
|
menu: provided => ({
|
||||||
...provided,
|
...provided,
|
||||||
backgroundColor: selectedTheme.backgroundColor,
|
backgroundColor: selectedTheme.backgroundColor,
|
||||||
border: "1px solid " + selectedTheme.mainColor,
|
border: '1px solid ' + selectedTheme.mainColor,
|
||||||
borderRadius: "0px",
|
borderRadius: '0px',
|
||||||
boxShadow: 0
|
boxShadow: 0
|
||||||
}),
|
}),
|
||||||
option: provided => ({
|
option: provided => ({
|
||||||
...provided,
|
...provided,
|
||||||
fontFamily: "Roboto, sans-serif",
|
fontFamily: 'Roboto, sans-serif',
|
||||||
fontWeight: "500",
|
fontWeight: '500',
|
||||||
color: selectedTheme.mainColor,
|
color: selectedTheme.mainColor,
|
||||||
textTransform: "uppercase",
|
textTransform: 'uppercase',
|
||||||
borderRadius: "0px",
|
borderRadius: '0px',
|
||||||
boxShadow: 0,
|
boxShadow: 0,
|
||||||
backgroundColor: selectedTheme.backgroundColor,
|
backgroundColor: selectedTheme.backgroundColor,
|
||||||
"&:hover": {
|
'&:hover': {
|
||||||
backgroundColor: selectedTheme.mainColor,
|
backgroundColor: selectedTheme.mainColor,
|
||||||
color: selectedTheme.backgroundColor
|
color: selectedTheme.backgroundColor
|
||||||
}
|
}
|
||||||
|
@ -123,13 +109,15 @@ const SettingsModal = () => {
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<ModalButton onClick={() => setModalHidden(!modalHidden)}>
|
<IconButton
|
||||||
<MaterialIcon icon="settings" color={selectedTheme.mainColor} />
|
icon="settings"
|
||||||
</ModalButton>
|
onClick={() => setModalHidden(!modalHidden)}
|
||||||
|
/>
|
||||||
<Modal hidden={modalHidden}>
|
<Modal hidden={modalHidden}>
|
||||||
<ExitButton onClick={() => setModalHidden(!modalHidden)}>
|
<IconButton
|
||||||
<MaterialIcon icon="close" color={selectedTheme.mainColor} />
|
icon="close"
|
||||||
</ExitButton>
|
onClick={() => setModalHidden(!modalHidden)}
|
||||||
|
/>
|
||||||
<SelectContainer>
|
<SelectContainer>
|
||||||
<Headline>Theme:</Headline>
|
<Headline>Theme:</Headline>
|
||||||
<FormContainer>
|
<FormContainer>
|
||||||
|
@ -141,7 +129,9 @@ const SettingsModal = () => {
|
||||||
}}
|
}}
|
||||||
styles={SelectorStyle}
|
styles={SelectorStyle}
|
||||||
/>
|
/>
|
||||||
<Button onClick={() => setTheme(JSON.stringify(newTheme))}>
|
<Button
|
||||||
|
onClick={() => setTheme(JSON.stringify(newTheme))}
|
||||||
|
>
|
||||||
Apply
|
Apply
|
||||||
</Button>
|
</Button>
|
||||||
</FormContainer>
|
</FormContainer>
|
||||||
|
|
|
@ -1,22 +1,22 @@
|
||||||
import themeData from "./data/themes.json";
|
import themeData from './data/themes.json';
|
||||||
|
|
||||||
const setTheme = theme => {
|
const setTheme = theme => {
|
||||||
localStorage.setItem("theme", theme);
|
localStorage.setItem('theme', theme);
|
||||||
window.location.reload();
|
window.location.reload();
|
||||||
};
|
};
|
||||||
|
|
||||||
const resetTheme = () => {
|
const resetTheme = () => {
|
||||||
localStorage.removeItem("theme");
|
localStorage.removeItem('theme');
|
||||||
};
|
};
|
||||||
|
|
||||||
const getTheme = () => {
|
const getTheme = () => {
|
||||||
let selectedTheme = themeData.themes[0];
|
let selectedTheme = themeData.themes[0];
|
||||||
|
|
||||||
if (
|
if (
|
||||||
localStorage.getItem("theme") &&
|
localStorage.getItem('theme') &&
|
||||||
localStorage.getItem("theme") !== undefined
|
localStorage.getItem('theme') !== undefined
|
||||||
) {
|
) {
|
||||||
selectedTheme = JSON.parse(localStorage.getItem("theme"));
|
selectedTheme = JSON.parse(localStorage.getItem('theme'));
|
||||||
}
|
}
|
||||||
|
|
||||||
return selectedTheme;
|
return selectedTheme;
|
||||||
|
|
|
@ -1,5 +0,0 @@
|
||||||
import themeData from './components/data/themes.json';
|
|
||||||
|
|
||||||
export const selectedTheme = localStorage.getItem('theme')
|
|
||||||
? JSON.parse(localStorage.getItem('theme'))
|
|
||||||
: themeData.themes[0];
|
|
|
@ -57,7 +57,7 @@ export function register(config) {
|
||||||
function registerValidSW(swUrl, config) {
|
function registerValidSW(swUrl, config) {
|
||||||
navigator.serviceWorker
|
navigator.serviceWorker
|
||||||
.register(swUrl)
|
.register(swUrl)
|
||||||
.then((registration) => {
|
.then(registration => {
|
||||||
registration.onupdatefound = () => {
|
registration.onupdatefound = () => {
|
||||||
const installingWorker = registration.installing;
|
const installingWorker = registration.installing;
|
||||||
if (installingWorker == null) {
|
if (installingWorker == null) {
|
||||||
|
@ -93,7 +93,7 @@ function registerValidSW(swUrl, config) {
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
})
|
})
|
||||||
.catch((error) => {
|
.catch(error => {
|
||||||
console.error('Error during service worker registration:', error);
|
console.error('Error during service worker registration:', error);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -101,9 +101,9 @@ function registerValidSW(swUrl, config) {
|
||||||
function checkValidServiceWorker(swUrl, config) {
|
function checkValidServiceWorker(swUrl, config) {
|
||||||
// Check if the service worker can be found. If it can't reload the page.
|
// Check if the service worker can be found. If it can't reload the page.
|
||||||
fetch(swUrl, {
|
fetch(swUrl, {
|
||||||
headers: { 'Service-Worker': 'script' },
|
headers: { 'Service-Worker': 'script' }
|
||||||
})
|
})
|
||||||
.then((response) => {
|
.then(response => {
|
||||||
// Ensure service worker exists, and that we really are getting a JS file.
|
// Ensure service worker exists, and that we really are getting a JS file.
|
||||||
const contentType = response.headers.get('content-type');
|
const contentType = response.headers.get('content-type');
|
||||||
if (
|
if (
|
||||||
|
@ -112,7 +112,7 @@ function checkValidServiceWorker(swUrl, config) {
|
||||||
contentType.indexOf('javascript') === -1)
|
contentType.indexOf('javascript') === -1)
|
||||||
) {
|
) {
|
||||||
// No service worker found. Probably a different app. Reload the page.
|
// No service worker found. Probably a different app. Reload the page.
|
||||||
navigator.serviceWorker.ready.then((registration) => {
|
navigator.serviceWorker.ready.then(registration => {
|
||||||
registration.unregister().then(() => {
|
registration.unregister().then(() => {
|
||||||
window.location.reload();
|
window.location.reload();
|
||||||
});
|
});
|
||||||
|
@ -132,10 +132,10 @@ function checkValidServiceWorker(swUrl, config) {
|
||||||
export function unregister() {
|
export function unregister() {
|
||||||
if ('serviceWorker' in navigator) {
|
if ('serviceWorker' in navigator) {
|
||||||
navigator.serviceWorker.ready
|
navigator.serviceWorker.ready
|
||||||
.then((registration) => {
|
.then(registration => {
|
||||||
registration.unregister();
|
registration.unregister();
|
||||||
})
|
})
|
||||||
.catch((error) => {
|
.catch(error => {
|
||||||
console.error(error.message);
|
console.error(error.message);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue