From 1f8b95f1ab23c4d896d7df6da7401e248e2999b5 Mon Sep 17 00:00:00 2001 From: David Ralph Date: Thu, 13 Jun 2024 23:04:42 +0100 Subject: [PATCH] fix: background dnd #762 --- src/features/background/options/Custom.jsx | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/src/features/background/options/Custom.jsx b/src/features/background/options/Custom.jsx index 7788f27e..7553aad4 100644 --- a/src/features/background/options/Custom.jsx +++ b/src/features/background/options/Custom.jsx @@ -41,14 +41,16 @@ export default class CustomSettings extends PureComponent { EventBus.emit('refresh', 'background'); }; - customBackground(e, text, index) { - const result = text === true ? e.target.value : e.target.result; + customBackground(e, index) { + const result = e.target.result; const customBackground = this.state.customBackground; - customBackground[index] = result; + customBackground[index || customBackground.length] = result; + this.setState({ customBackground, }); + this.forceUpdate(); localStorage.setItem('customBackground', JSON.stringify(customBackground)); @@ -159,7 +161,7 @@ export default class CustomSettings extends PureComponent { return toast(variables.getMessage('toasts.no_storage')); } - return this.customBackground(file, false, this.state.currentBackgroundIndex); + return this.customBackground(file, this.state.currentBackgroundIndex); } compressAccurately(file, { @@ -170,7 +172,11 @@ export default class CustomSettings extends PureComponent { return toast(variables.getMessage('toasts.no_storage')); } - this.customBackground(await filetoDataURL(res), false, this.state.currentBackgroundIndex); + this.customBackground({ + target: { + result: await filetoDataURL(res), + } + }, this.state.currentBackgroundIndex); }); e.preventDefault(); }; @@ -274,7 +280,7 @@ export default class CustomSettings extends PureComponent { this.customBackground(e, false, this.state.currentBackgroundIndex)} + loadFunction={(e) => this.customBackground(e, this.state.currentBackgroundIndex)} /> {this.videoCustomSettings()}