From 91023bade02b497de808f9025780ab16fccc109d Mon Sep 17 00:00:00 2001 From: Niel Rohling Date: Fri, 19 Apr 2019 20:26:41 +0200 Subject: [PATCH] migrated to javascript --- src/serviceWorker.ts => serviceWorker.js | 22 +-- src/App.js | 17 +++ src/App.scss | 5 - src/App.tsx | 22 --- .../{ChannelEntry.tsx => ChannelEntry.js} | 6 +- .../{ChannelList.tsx => ChannelList.js} | 8 +- src/components/Channel/ChannelList.scss | 3 - src/components/Channel/ChannelView.js | 28 ++++ src/components/Channel/ChannelView.scss | 10 -- src/components/Channel/ChannelView.tsx | 29 ---- .../Channel/{Channels.tsx => Channels.js} | 25 ++-- src/components/Header.js | 7 + src/components/Header/Header.scss | 7 - src/components/Header/Header.tsx | 9 -- src/components/{Home.tsx => Home.js} | 0 src/index.css | 14 -- src/{index.tsx => index.js} | 2 +- src/index.scss | 40 ++++++ src/react-app-env.d.ts | 1 - src/serviceWorker.js | 135 ++++++++++++++++++ src/services/ApiService.js | 12 ++ src/services/ApiService.ts | 11 -- src/types.d.ts | 35 ----- 23 files changed, 264 insertions(+), 184 deletions(-) rename src/serviceWorker.ts => serviceWorker.js (87%) mode change 100755 => 100644 create mode 100644 src/App.js delete mode 100644 src/App.scss delete mode 100755 src/App.tsx rename src/components/Channel/{ChannelEntry.tsx => ChannelEntry.js} (82%) rename src/components/Channel/{ChannelList.tsx => ChannelList.js} (62%) delete mode 100644 src/components/Channel/ChannelList.scss create mode 100644 src/components/Channel/ChannelView.js delete mode 100644 src/components/Channel/ChannelView.scss delete mode 100644 src/components/Channel/ChannelView.tsx rename src/components/Channel/{Channels.tsx => Channels.js} (52%) create mode 100644 src/components/Header.js delete mode 100644 src/components/Header/Header.scss delete mode 100644 src/components/Header/Header.tsx rename src/components/{Home.tsx => Home.js} (100%) delete mode 100755 src/index.css rename src/{index.tsx => index.js} (94%) mode change 100755 => 100644 create mode 100644 src/index.scss delete mode 100644 src/react-app-env.d.ts create mode 100644 src/serviceWorker.js create mode 100644 src/services/ApiService.js delete mode 100644 src/services/ApiService.ts delete mode 100644 src/types.d.ts diff --git a/src/serviceWorker.ts b/serviceWorker.js old mode 100755 new mode 100644 similarity index 87% rename from src/serviceWorker.ts rename to serviceWorker.js index c0b1310..f8c7e50 --- a/src/serviceWorker.ts +++ b/serviceWorker.js @@ -8,7 +8,7 @@ // resources are updated in the background. // To learn more about the benefits of this model and instructions on how to -// opt-in, read http://bit.ly/CRA-PWA +// opt-in, read https://bit.ly/CRA-PWA const isLocalhost = Boolean( window.location.hostname === 'localhost' || @@ -20,18 +20,10 @@ const isLocalhost = Boolean( ) ); -type Config = { - onSuccess?: (registration: ServiceWorkerRegistration) => void; - onUpdate?: (registration: ServiceWorkerRegistration) => void; -}; - -export function register(config?: Config) { +export function register(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 - ); + const publicUrl = new URL(process.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 @@ -51,7 +43,7 @@ export function register(config?: Config) { navigator.serviceWorker.ready.then(() => { console.log( 'This web app is being served cache-first by a service ' + - 'worker. To learn more, visit http://bit.ly/CRA-PWA' + 'worker. To learn more, visit https://bit.ly/CRA-PWA' ); }); } else { @@ -62,7 +54,7 @@ export function register(config?: Config) { } } -function registerValidSW(swUrl: string, config?: Config) { +function registerValidSW(swUrl, config) { navigator.serviceWorker .register(swUrl) .then(registration => { @@ -79,7 +71,7 @@ function registerValidSW(swUrl: string, config?: Config) { // 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 http://bit.ly/CRA-PWA.' + 'tabs for this page are closed. See https://bit.ly/CRA-PWA.' ); // Execute callback @@ -106,7 +98,7 @@ function registerValidSW(swUrl: string, config?: Config) { }); } -function checkValidServiceWorker(swUrl: string, config?: Config) { +function checkValidServiceWorker(swUrl, config) { // Check if the service worker can be found. If it can't reload the page. fetch(swUrl) .then(response => { diff --git a/src/App.js b/src/App.js new file mode 100644 index 0000000..9920e82 --- /dev/null +++ b/src/App.js @@ -0,0 +1,17 @@ +import React from 'react'; +import { BrowserRouter as Router, Route } from 'react-router-dom'; +import Home from './components/Home'; +import Header from './components/Header'; + +const App = () => { + return ( +
+
+ + + +
+ ); +}; + +export default App; diff --git a/src/App.scss b/src/App.scss deleted file mode 100644 index 74ebcac..0000000 --- a/src/App.scss +++ /dev/null @@ -1,5 +0,0 @@ -body { - background-color: #4a4a4a; - font-size: 160%; - color: #fff -} diff --git a/src/App.tsx b/src/App.tsx deleted file mode 100755 index 5802c45..0000000 --- a/src/App.tsx +++ /dev/null @@ -1,22 +0,0 @@ -import React, { Component } from 'react'; -import { BrowserRouter as Router, Route } from 'react-router-dom'; - -import Header from './components/Header/Header'; - -import './App.scss'; -import Home from './components/Home'; - -class App extends Component { - public render() { - return ( -
-
- - - -
- ); - } -} - -export default App; diff --git a/src/components/Channel/ChannelEntry.tsx b/src/components/Channel/ChannelEntry.js similarity index 82% rename from src/components/Channel/ChannelEntry.tsx rename to src/components/Channel/ChannelEntry.js index 31af0e0..8d11c67 100644 --- a/src/components/Channel/ChannelEntry.tsx +++ b/src/components/Channel/ChannelEntry.js @@ -1,9 +1,9 @@ -import React, { Component } from 'react'; +import React from 'react'; import ChannelList from './ChannelList'; -const ChannelEntry = (props: ChannelEntryProps) => { +const ChannelEntry = props => { const { clients, channel } = props; - const joined: Client[] = []; + const joined = []; if (channel.totalClients > 0) { clients.forEach(client => { if (client.channelId === channel.id) joined.push(client); diff --git a/src/components/Channel/ChannelList.tsx b/src/components/Channel/ChannelList.js similarity index 62% rename from src/components/Channel/ChannelList.tsx rename to src/components/Channel/ChannelList.js index 4058702..1ceed80 100644 --- a/src/components/Channel/ChannelList.tsx +++ b/src/components/Channel/ChannelList.js @@ -1,10 +1,8 @@ -import React, { Component } from 'react'; -import ApiService from '../../services/ApiService'; +import React from 'react'; + import ChannelEntry from './ChannelEntry'; -import './ChannelList.scss'; - -const ChannelList = ({ channels, clients }: ChannelListProps) => { +const ChannelList = ({ channels, clients }) => { return (