Skip to content

Commit

Permalink
Prelim update app message work
Browse files Browse the repository at this point in the history
  • Loading branch information
rayoverweij committed Aug 4, 2020
1 parent 0bbc3c5 commit f6c3a02
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 6 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"license": "MIT",
"description": "A tabbing app for small World Schools-like debating tournaments",
"private": true,
"homepage": "https://rayo.dev/tacotab",
"homepage": ".",
"dependencies": {
"@types/jest": "^24.9.1",
"@types/node": "^12.12.41",
Expand Down
11 changes: 11 additions & 0 deletions src/App.scss
Original file line number Diff line number Diff line change
Expand Up @@ -204,4 +204,15 @@
outline: none;
}
}
}


.alert-global {
position: absolute;
right: 7px;
top: 7px;
}

#alert-new-version-available {
display: none;
}
11 changes: 10 additions & 1 deletion src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ import Container from 'react-bootstrap/Container';
import Tab from 'react-bootstrap/Tab';
import Nav from 'react-bootstrap/Nav';
import Collapse from 'react-bootstrap/Collapse';
import { List } from 'react-bootstrap-icons';
import Alert from 'react-bootstrap/Alert';
import { List, ExclamationTriangle } from 'react-bootstrap-icons';


type AppProps = {}
Expand Down Expand Up @@ -289,6 +290,14 @@ class App extends React.Component<AppProps, AppState> {
</Tab.Container>
</Container>

<Alert
variant="primary"
className="alert-global"
id="alert-new-version-available">
<ExclamationTriangle />&nbsp;&nbsp;
A new version of TacoTab is available! <Alert.Link onClick={() => window.location.reload()}>Click to reload.</Alert.Link>
</Alert>

<SetupScreen
init={this.state.init}
initializeTournament={this.initializeTournament} />
Expand Down
18 changes: 14 additions & 4 deletions src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,20 @@ import App from './App';
import * as serviceWorker from './serviceWorker';

ReactDOM.render(
<React.StrictMode>
<App />
</React.StrictMode>,
document.getElementById('root')
<React.StrictMode>
<App />
</React.StrictMode>,
document.getElementById('root')
);

serviceWorker.register();

// serviceWorker.register({
// onUpdate: (registration: ServiceWorkerRegistration) => {
// document.getElementById("alert-new-version-available")?.classList.add("show");
// if( registration && registration.waiting ) {
// registration.waiting.postMessage({type: 'SKIP_WAITING '});
// }
// window.location.reload(true);
// }
// });

0 comments on commit f6c3a02

Please sign in to comment.