Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master' into 1746-rewrites
Browse files Browse the repository at this point in the history
  • Loading branch information
szolin committed Jun 1, 2020
2 parents a679498 + 67dacdf commit fb3ad25
Show file tree
Hide file tree
Showing 9 changed files with 49 additions and 41 deletions.
22 changes: 7 additions & 15 deletions client/public/assets/safari-pinned-tab.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion client/public/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<meta name="google" content="notranslate">
<meta http-equiv="x-dns-prefetch-control" content="off">
<link rel="apple-touch-icon" sizes="180x180" href="assets/apple-touch-icon-180x180.png" />
<link rel="mask-icon" href="assets/safari-pinned-tab.svg" color="#5bbad5">
<link rel="mask-icon" href="assets/safari-pinned-tab.svg" color="#67B279">
<link rel="icon" type="image/png" href="assets/favicon.png" sizes="48x48">
<title>AdGuard Home</title>
</head>
Expand Down
2 changes: 1 addition & 1 deletion client/public/install.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<meta name="theme-color" content="#000000">
<meta name="google" content="notranslate">
<link rel="apple-touch-icon" sizes="180x180" href="assets/apple-touch-icon-180x180.png" />
<link rel="mask-icon" href="assets/safari-pinned-tab.svg" color="#5bbad5">
<link rel="mask-icon" href="assets/safari-pinned-tab.svg" color="#67B279">
<link rel="icon" type="image/png" href="assets/favicon.png" sizes="48x48">
<title>Setup AdGuard Home</title>
</head>
Expand Down
2 changes: 1 addition & 1 deletion client/public/login.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<meta name="theme-color" content="#000000">
<meta name="google" content="notranslate">
<link rel="apple-touch-icon" sizes="180x180" href="assets/apple-touch-icon-180x180.png" />
<link rel="mask-icon" href="assets/safari-pinned-tab.svg" color="#5bbad5">
<link rel="mask-icon" href="assets/safari-pinned-tab.svg" color="#67B279">
<link rel="icon" type="image/png" href="assets/favicon.png" sizes="48x48">
<title>Login</title>
</head>
Expand Down
1 change: 0 additions & 1 deletion client/src/components/Settings/FiltersConfig/Form.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,6 @@ const Form = (props) => {
<label className="form__label">
<Trans>filters_interval</Trans>
</label>

{getIntervalSelect(processing, t, handleChange, toNumber)}
</div>
</div>
Expand Down
40 changes: 21 additions & 19 deletions client/src/components/Settings/FiltersConfig/index.js
Original file line number Diff line number Diff line change
@@ -1,33 +1,35 @@
import React, { Component } from 'react';
import React from 'react';
import PropTypes from 'prop-types';
import { withTranslation } from 'react-i18next';
import debounce from 'lodash/debounce';

import { DEBOUNCE_TIMEOUT } from '../../../helpers/constants';
import Form from './Form';
import { getObjDiff } from '../../../helpers/helpers';

class FiltersConfig extends Component {
handleFormChange = debounce((values) => {
this.props.setFiltersConfig(values);
}, DEBOUNCE_TIMEOUT);
const FiltersConfig = (props) => {
const { initialValues, processing } = props;

const handleFormChange = debounce((values) => {
const diff = getObjDiff(initialValues, values);

render() {
const { interval, enabled, processing } = this.props;
if (Object.values(diff).length > 0) {
props.setFiltersConfig(values);
}
}, DEBOUNCE_TIMEOUT);

return (
<Form
initialValues={{ interval, enabled }}
onSubmit={this.handleFormChange}
onChange={this.handleFormChange}
processing={processing}
/>
);
}
}
return (
<Form
initialValues={initialValues}
onSubmit={handleFormChange}
onChange={handleFormChange}
processing={processing}
/>
);
};

FiltersConfig.propTypes = {
interval: PropTypes.number.isRequired,
enabled: PropTypes.bool.isRequired,
initialValues: PropTypes.object.isRequired,
processing: PropTypes.bool.isRequired,
setFiltersConfig: PropTypes.func.isRequired,
t: PropTypes.func.isRequired,
Expand Down
6 changes: 4 additions & 2 deletions client/src/components/Settings/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,10 @@ class Settings extends Component {
<Card bodyType="card-body box-body--settings">
<div className="form">
<FiltersConfig
interval={filtering.interval}
enabled={filtering.enabled}
initialValues={{
interval: filtering.interval,
enabled: filtering.enabled,
}}
processing={filtering.processingSetConfig}
setFiltersConfig={setFiltersConfig}
/>
Expand Down
13 changes: 13 additions & 0 deletions client/src/helpers/helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -482,6 +482,19 @@ export const getCurrentFilter = (url, filters) => {
};
};

/**
* @param {object} initialValues
* @param {object} values
* @returns {object} Returns different values of objects
*/
export const getObjDiff = (initialValues, values) => Object.entries(values)
.reduce((acc, [key, value]) => {
if (value !== initialValues[key]) {
acc[key] = value;
}
return acc;
}, {});

/**
* @param number Number to format
* @returns string Returns a string with a language-sensitive representation of this number
Expand Down
2 changes: 1 addition & 1 deletion client/src/reducers/rewrites.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ const rewrites = handleActions(
[actions.addRewriteSuccess]: (state, { payload }) => {
const newState = {
...state,
list: [...state.list, ...payload],
list: [...state.list, payload],
processingAdd: false,
};
return newState;
Expand Down

0 comments on commit fb3ad25

Please sign in to comment.