From 8aca9ae31cda57758f647911f5e78d8bd78d124a Mon Sep 17 00:00:00 2001 From: David Ralph Date: Thu, 11 Nov 2021 10:51:45 +0000 Subject: [PATCH] fix: settings fix, keybinds fix (WIP), modal ui fix --- package.json | 40 +++++++++---------- .../main/marketplace/SideloadFailedModal.jsx | 5 ++- .../modals/main/scss/marketplace/_main.scss | 4 -- .../modals/main/scss/settings/_buttons.scss | 7 ++++ .../main/settings/sections/Keybinds.jsx | 18 ++++++--- src/modules/default_settings.json | 2 +- src/modules/helpers/settings/index.js | 16 ++++---- src/modules/helpers/settings/modals.js | 28 +++++++++++-- 8 files changed, 78 insertions(+), 42 deletions(-) diff --git a/package.json b/package.json index 9f6f32ae..5fe8f309 100644 --- a/package.json +++ b/package.json @@ -11,8 +11,8 @@ "license": "BSD-3-Clause", "version": "5.3.3", "dependencies": { - "@eartharoid/i18n": "^1.0.0", - "@emotion/react": "^11.4.1", + "@eartharoid/i18n": "^1.0.2", + "@emotion/react": "^11.5.0", "@emotion/styled": "^11.3.0", "@fontsource/lexend-deca": "4.4.5", "@fontsource/montserrat": "4.4.5", @@ -29,29 +29,29 @@ "weather-icons-react": "1.2.0" }, "devDependencies": { - "@babel/core": "^7.15.5", - "@babel/eslint-parser": "^7.15.7", - "@babel/plugin-proposal-class-properties": "^7.14.5", - "@babel/plugin-transform-react-constant-elements": "^7.14.5", - "@babel/plugin-transform-react-inline-elements": "^7.14.5", - "@babel/plugin-transform-runtime": "^7.15.0", - "@babel/preset-env": "^7.15.6", - "@babel/preset-react": "^7.14.5", + "@babel/core": "^7.16.0", + "@babel/eslint-parser": "^7.16.3", + "@babel/plugin-proposal-class-properties": "^7.16.0", + "@babel/plugin-transform-react-constant-elements": "^7.16.0", + "@babel/plugin-transform-react-inline-elements": "^7.16.0", + "@babel/plugin-transform-runtime": "^7.16.0", + "@babel/preset-env": "^7.16.0", + "@babel/preset-react": "^7.16.0", "@eartharoid/deep-merge": "^0.0.2", - "babel-loader": "^8.2.2", + "babel-loader": "^8.2.3", "babel-plugin-transform-react-class-to-function": "^1.2.2", "copy-webpack-plugin": "^9.0.1", - "css-loader": "^6.2.0", - "eslint": "^8.0.0", + "css-loader": "^6.5.1", + "eslint": "^8.2.0", "eslint-config-react-app": "^6.0.0", - "html-webpack-plugin": "^5.3.2", - "mini-css-extract-plugin": "^2.3.0", - "sass": "^1.42.1", - "sass-loader": "^12.1.0", + "html-webpack-plugin": "^5.5.0", + "mini-css-extract-plugin": "^2.4.4", + "sass": "^1.43.4", + "sass-loader": "^12.3.0", "source-map-loader": "^3.0.0", - "webpack": "^5.61.0", - "webpack-cli": "^4.8.0", - "webpack-dev-server": "^4.3.0" + "webpack": "^5.63.0", + "webpack-cli": "^4.9.1", + "webpack-dev-server": "^4.4.0" }, "scripts": { "start": "webpack serve", diff --git a/src/components/modals/main/marketplace/SideloadFailedModal.jsx b/src/components/modals/main/marketplace/SideloadFailedModal.jsx index c28f44b7..38400929 100644 --- a/src/components/modals/main/marketplace/SideloadFailedModal.jsx +++ b/src/components/modals/main/marketplace/SideloadFailedModal.jsx @@ -1,4 +1,5 @@ import variables from 'modules/variables'; +import { Close } from '@mui/icons-material'; export default function SideloadFailedModal({ modalClose, reason }) { const getMessage = (text) => variables.language.getMessage(variables.languagecode, text); @@ -10,7 +11,9 @@ export default function SideloadFailedModal({ modalClose, reason }) {

{reason}
- +
); diff --git a/src/components/modals/main/scss/marketplace/_main.scss b/src/components/modals/main/scss/marketplace/_main.scss index eee052f6..ab8a8c75 100644 --- a/src/components/modals/main/scss/marketplace/_main.scss +++ b/src/components/modals/main/scss/marketplace/_main.scss @@ -120,8 +120,4 @@ p.author { min-width: 250px; max-width: 250px; overflow-x: hidden; - - button { - margin-left: -50px; - } } diff --git a/src/components/modals/main/scss/settings/_buttons.scss b/src/components/modals/main/scss/settings/_buttons.scss index 9e1182aa..4b1e7561 100644 --- a/src/components/modals/main/scss/settings/_buttons.scss +++ b/src/components/modals/main/scss/settings/_buttons.scss @@ -61,6 +61,13 @@ &:disabled { cursor: not-allowed; + background: none; + border: 1px solid var(--tab-active); + + &:hover { + background: none; + border: 1px solid var(--tab-active); + } } } diff --git a/src/components/modals/main/settings/sections/Keybinds.jsx b/src/components/modals/main/settings/sections/Keybinds.jsx index 222a60f2..2ed3c936 100644 --- a/src/components/modals/main/settings/sections/Keybinds.jsx +++ b/src/components/modals/main/settings/sections/Keybinds.jsx @@ -10,7 +10,8 @@ export default class KeybindSettings extends PureComponent { constructor() { super(); this.state = { - keybinds: JSON.parse(localStorage.getItem('keybinds')) || {} + keybinds: JSON.parse(localStorage.getItem('keybinds')) || {}, + cancelled: false }; } @@ -23,14 +24,15 @@ export default class KeybindSettings extends PureComponent { const currentKeybinds = this.state.keybinds; currentKeybinds[type] = this.getMessage('modals.main.settings.sections.keybinds.recording'); this.setState({ - keybinds: currentKeybinds + keybinds: currentKeybinds, + cancelled: false }); this.forceUpdate(); let keys = ''; let previouskey = ''; this.keydown = document.addEventListener('keydown', (event) => { - if (event.key === previouskey) { + if (event.key === previouskey && this.state.cancelled === true) { return; } @@ -44,6 +46,10 @@ export default class KeybindSettings extends PureComponent { }); this.keyup = document.addEventListener('keyup', () => { + if (this.state.cancelled === true) { + return; + } + document.removeEventListener('keydown', this.keydown); const keybinds = this.state.keybinds; keybinds[type] = keys.split('+').slice(0, 4).join('+'); @@ -66,7 +72,8 @@ export default class KeybindSettings extends PureComponent { delete currentKeybinds[type]; this.setState({ - keybinds: currentKeybinds + keybinds: currentKeybinds, + cancelled: true }); this.forceUpdate(); } @@ -77,7 +84,8 @@ export default class KeybindSettings extends PureComponent { localStorage.setItem('keybinds', JSON.stringify(keybinds)); this.setState({ - keybinds: JSON.parse(localStorage.getItem('keybinds')) || {} + keybinds: JSON.parse(localStorage.getItem('keybinds')) || {}, + cancelled: true }); this.showReminder(); diff --git a/src/modules/default_settings.json b/src/modules/default_settings.json index b74fa12a..d3c09191 100644 --- a/src/modules/default_settings.json +++ b/src/modules/default_settings.json @@ -209,7 +209,7 @@ }, { "name": "backgroundFilter", - "value": "grayscale" + "value": "none" }, { "name": "apiQuality", diff --git a/src/modules/helpers/settings/index.js b/src/modules/helpers/settings/index.js index 4c0f9126..6354e842 100644 --- a/src/modules/helpers/settings/index.js +++ b/src/modules/helpers/settings/index.js @@ -115,13 +115,15 @@ export function loadSettings(hotreload) { return; } - const js = localStorage.getItem('customjs'); - if (js) { - try { - // eslint-disable-next-line no-eval - eval(js); - } catch (e) { - console.error('Failed to run custom JS: ', e); + if (window.location.href.startsWith('http://') || window.location.href.startsWith('https://')){ + const js = localStorage.getItem('customjs'); + if (js) { + try { + // eslint-disable-next-line no-eval + eval(js); + } catch (e) { + console.error('Failed to run custom JS: ', e); + } } } diff --git a/src/modules/helpers/settings/modals.js b/src/modules/helpers/settings/modals.js index e95402b4..401e07b1 100644 --- a/src/modules/helpers/settings/modals.js +++ b/src/modules/helpers/settings/modals.js @@ -42,10 +42,30 @@ export function importSettings(e) { export function values(type) { const marks = { - zoom: [{ value: 10, label: '0.1x' }, { value: 100, label: '1x' }, { value: 200, label: '2x' }, { value: 400, label: '4x' }], - toast: [{ value: 500, label: '0.5s' }, { value: 1000, label: '1s' }, { value: 1500, label: '1.5s' }, { value: 2000, label: '2s' }, { value: 2500, label: '2.5s' }, { value: 3000, label: '3s' }, { value: 4000, label: '4s' }, { value: 5000, label: '5s'}], - background: [{ value: 0, label: '0%'}, { value: 25, label: '25%' }, { value: 50, label: '50%' }, { value: 75, label: '75%' }, { value: 100, label: '100%' }] - } + zoom: [ + { value: 10, label: '0.1x' }, + { value: 100, label: '1x' }, + { value: 200, label: '2x' }, + { value: 400, label: '4x' } + ], + toast: [ + { value: 500, label: '0.5s' }, + { value: 1000, label: '1s' }, + { value: 1500, label: '1.5s' }, + { value: 2000, label: '2s' }, + { value: 2500, label: '2.5s' }, + { value: 3000, label: '3s' }, + { value: 4000, label: '4s' }, + { value: 5000, label: '5s'} + ], + background: [ + { value: 0, label: '0%'}, + { value: 25, label: '25%' }, + { value: 50, label: '50%' }, + { value: 75, label: '75%' }, + { value: 100, label: '100%' } + ] + }; return marks[type]; }