Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FEATURE] Update legal #57

Merged
merged 3 commits into from
Jan 31, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 19 additions & 7 deletions frontend/containers/agreement-page.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@ class Agreement extends Component {
this.state = {
eula: false,
ga: false,
isUpdate: false,
};
window.ipcRenderer.on("agreement-update-found", this.updateAgreement);
}

componentDidMount() {
Expand All @@ -18,6 +20,7 @@ class Agreement extends Component {
}

componentWillUnmount() {
window.ipcRenderer.removeListener("agreement-update-found", this.updateAgreement);
window.ipcRenderer.removeListener("agreement-wrote", this.ipcSuccess);
window.ipcRenderer.removeListener("error", this.ipcError);
}
Expand All @@ -26,6 +29,13 @@ class Agreement extends Component {
this.setState({ [e.target.name]: e.target.checked });
};

updateAgreement = (sender, data) => {
this.setState({
ga: data.ga,
isUpdate: true,
});
};

ipcSuccess = () => {
window.close();
};
Expand All @@ -49,7 +59,7 @@ class Agreement extends Component {
<div className="col-xs-12">
<div className="agreement__titles center-block">
<div className="agreement__title">
Privacy and policy
Privacy policy{this.state.isUpdate && " updated"}
</div>
<div className="agreement__logo">
<img src="public/assets/images/logo-black.svg" alt="Lightning peach" />
Expand All @@ -69,12 +79,14 @@ class Agreement extends Component {
<span className="form-checkbox__label">I accept the agreement</span>
</label>
</div>
<div className="col-xs-12">
<label className="form-checkbox label_line pull-left channels__custom">
<input id="ga-agreement-checkbox" name="ga" type="checkbox" onChange={this.onChange} />
<span className="form-checkbox__label">I agree to the personal data processing</span>
</label>
</div>
{!this.state.isUpdate &&
<div className="col-xs-12">
<label className="form-checkbox label_line pull-left channels__custom">
<input id="ga-agreement-checkbox" name="ga" type="checkbox" onChange={this.onChange} />
<span className="form-checkbox__label">I agree to the personal data processing</span>
</label>
</div>
}
<div className="col-xs-12">
<button
type="submit"
Expand Down
19 changes: 14 additions & 5 deletions main.js
Original file line number Diff line number Diff line change
Expand Up @@ -140,25 +140,34 @@ function createWindow() {
}

const checkAgreement = async () => {
if (settings.get.agreement.eula) {
if (settings.get.agreement.eula && settings.get.agreement.legalVersion === settings.get.version.legal) {
createWindow();
return;
}
agreementWindow = new BrowserWindow(defaultWindowSettings);
agreementWindow.webContents.isMain = true; // to check if this window is main in server.utils.helpers.ipcSend
agreementWindow.webContents.isAgreemnt = true; // to check if this window is main in server.utils.helpers.ipcSend

agreementWindow.loadURL(url.format({
pathname: path.join(__dirname, "agreement.html"),
protocol: "file:",
slashes: true,
}));
devTools(agreementWindow);
agreementWindow.setMenu(null);
agreementWindow.maximize();
agreementWindow.show();
agreementWindow.webContents.on("did-finish-load", () => {
agreementWindow.setMenu(null);
agreementWindow.maximize();
agreementWindow.show();
agreementWindow.focus();
if (settings.get.agreement.eula) {
helpers.ipcSend("agreement-update-found", {
ga: settings.get.agreement.sendStatistics,
});
}
});

agreementWindow.webContents.on("close", () => {
if (settings.get.agreement.eula) {
if (settings.get.agreement.eula && settings.get.agreement.legalVersion === settings.get.version.legal) {
createWindow();
}
});
Expand Down
Loading