Take ifFirstInstall into account

This commit is contained in:
Ilya Ig. Petrov 2017-05-30 20:44:40 +05:00
parent c3a641d85f
commit 4e6508a058
3 changed files with 23 additions and 13 deletions

View File

@ -20,10 +20,9 @@ export default function getApp(theState) {
const hash = window.location.hash.substr(1); const hash = window.location.hash.substr(1);
const hashParams = new URLSearchParams(hash); const hashParams = new URLSearchParams(hash);
console.log('GOT from', hash, hashParams.toString());
this.state = { this.state = {
status: hashParams.get('status') || 'Загрузка...', status: hashParams.get('status') || 'Хорошего настроения вам!',
ifInputsDisabled: false, ifInputsDisabled: false,
hashParams, hashParams,
}; };

View File

@ -21,8 +21,6 @@ export default function getMain(theState) {
const ApplyMods = getApplyMods(theState); const ApplyMods = getApplyMods(theState);
const Notifications = getNotifications(theState); const Notifications = getNotifications(theState);
//const addChecks = (arr) => arr.map( (conf) => Object.assign(conf, {ifChecked: Boolean(conf.value)}) );
const checksName = 'pacMods'; const checksName = 'pacMods';
return class Main extends Component { return class Main extends Component {

View File

@ -60,6 +60,14 @@ export default function getPacChooser(theState) {
chosenPacName: 'none', chosenPacName: 'none',
}; };
this.updatePac = function updatePac() {
props.funs.conduct(
'Обновляем...',
(cb) => props.apis.antiCensorRu.syncWithPacProviderAsync(cb),
'Обновлено.'
);
};
} }
getCurrentProviderId() { getCurrentProviderId() {
@ -103,14 +111,6 @@ export default function getPacChooser(theState) {
render(props) { render(props) {
const updatePac = function updatePac() {
props.funs.conduct(
'Обновляем...',
(cb) => props.apis.antiCensorRu.syncWithPacProviderAsync(cb),
'Обновлено.'
);
};
const iddyToCheck = this.getCurrentProviderId(); const iddyToCheck = this.getCurrentProviderId();
return ( return (
<div> <div>
@ -125,7 +125,12 @@ export default function getPacChooser(theState) {
name="pacProvider" name="pacProvider"
checked={iddyToCheck === provConf.key} checked={iddyToCheck === provConf.key}
disabled={props.ifInputsDisabled} disabled={props.ifInputsDisabled}
nodeAfterLabel={<a href="" class={scopedCss.updateButton} onClick={(evt) => { evt.preventDefault(); updatePac(); }}>[обновить]</a>} nodeAfterLabel={<a href="" class={scopedCss.updateButton} onClick={(evt) => {
evt.preventDefault();
this.updatePac();
}}>[обновить]</a>}
/>) />)
) )
} }
@ -147,6 +152,14 @@ export default function getPacChooser(theState) {
} }
componentDidMount() {
if (this.props.apis.antiCensorRu.ifFirstInstall) {
this.updatePac();
}
}
}; };
}; };