Skip to content

Commit

Permalink
disable clear data button when clicked once
Browse files Browse the repository at this point in the history
  • Loading branch information
nklhtv committed Nov 2, 2021
1 parent 2a8d7ab commit 55effde
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/App/ErrorDialog/ErrorDialog.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,13 @@ const { Button, Image } = require('stremio/common');
const styles = require('./styles');

const ErrorDialog = ({ className }) => {
const [dataCleared, setDataCleared] = React.useState(false);
const reload = React.useCallback(() => {
window.location.reload();
}, []);
const clearData = React.useCallback(() => {
window.localStorage.clear();
setDataCleared(true);
}, []);
return (
<div className={classnames(className, styles['error-container'])}>
Expand All @@ -25,7 +27,7 @@ const ErrorDialog = ({ className }) => {
<Button className={styles['button-container']} title={'Try again'} onClick={reload}>
<div className={styles['label']}>Try again</div>
</Button>
<Button className={styles['button-container']} title={'Clear data'} onClick={clearData}>
<Button className={styles['button-container']} disabled={dataCleared} title={'Clear data'} onClick={clearData}>
<div className={styles['label']}>Clear data</div>
</Button>
</div>
Expand Down
4 changes: 4 additions & 0 deletions src/App/ErrorDialog/styles.less
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,10 @@
background-color: @color-accent3-light1;
}

&:global(.disabled) {
background-color: @color-surface-dark5;
}

.label {
flex-grow: 0;
flex-shrink: 1;
Expand Down

0 comments on commit 55effde

Please sign in to comment.