From dac0b9d2cd800c4f19eec28474b5aaeb22093014 Mon Sep 17 00:00:00 2001 From: Jake Archibald Date: Mon, 29 Oct 2018 13:11:11 +0000 Subject: [PATCH] Undo copy settings across. --- src/components/compress/index.tsx | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/components/compress/index.tsx b/src/components/compress/index.tsx index 9c49bfb3..ef5f19aa 100644 --- a/src/components/compress/index.tsx +++ b/src/components/compress/index.tsx @@ -251,12 +251,24 @@ export default class Compress extends Component { } } - private onCopyToOtherClick(index: 0 | 1) { + private async onCopyToOtherClick(index: 0 | 1) { const otherIndex = (index + 1) % 2; + const oldSettings = this.state.images[otherIndex]; this.setState({ images: cleanSet(this.state.images, otherIndex, this.state.images[index]), }); + + const result = await this.props.showSnack('Settings copied across', { + timeout: 5000, + actions: ['undo', 'dismiss'], + }); + + if (result !== 'undo') return; + + this.setState({ + images: cleanSet(this.state.images, otherIndex, oldSettings), + }); } @bind