Extract real method

Refs #1750, #1788.
This commit is contained in:
Franz Liedke 2019-08-14 08:27:06 +02:00
parent c3740281b6
commit e7cdd497dd

View File

@ -100,25 +100,25 @@ export default {
return; return;
} }
const showAlert = type => {
const { username, email } = this.data.attributes;
app.alerts.show(new Alert({
type,
children: app.translator.trans(
`core.forum.user.delete_alert_${type}`, { username, email }
)
}));
};
this.delete().then(() => { this.delete().then(() => {
showAlert('success'); this.showDeletionAlert('success');
if (app.current instanceof UserPage && app.current.user === this) { if (app.current instanceof UserPage && app.current.user === this) {
app.history.back(); app.history.back();
} else { } else {
window.location.reload(); window.location.reload();
} }
}).catch(() => showAlert('error')); }).catch(() => this.showDeletionAlert('error'));
},
showDeletionAlert(type) {
const { username, email } = this.data.attributes;
app.alerts.show(new Alert({
type,
children: app.translator.trans(
`core.forum.user.delete_alert_${type}`, { username, email }
)
}));
}, },
/** /**