Revert "Fixed errors thrown from blank twitter/facebook URL fields"

This reverts commit a523fedccb.

- caused input value to be cleared on focus+blur with no changes
- reverting in favor of an incoming refactor
This commit is contained in:
Kevin Ansfield 2022-10-04 10:30:13 +01:00
parent a523fedccb
commit d8193da005
2 changed files with 30 additions and 18 deletions

View File

@ -104,18 +104,24 @@ export default class GeneralController extends Controller {
@action
validateFacebookUrl() {
let newUrl = this._scratchFacebook;
let oldUrl = this.get('settings.facebook');
let errMessage = '';
// reset errors and validation
this.get('settings.errors').remove('facebook');
this.get('settings.hasValidated').removeObject('facebook');
if (!newUrl) {
if (newUrl === '') {
// Clear out the Facebook url
this.set('settings.facebook', null);
this.set('settings.facebook', '');
return;
}
// _scratchFacebook will be null unless the user has input something
if (!newUrl) {
newUrl = oldUrl;
}
try {
// strip any facebook URLs out
newUrl = newUrl.replace(/(https?:\/\/)?(www\.)?facebook\.com/i, '');
@ -153,18 +159,24 @@ export default class GeneralController extends Controller {
@action
validateTwitterUrl() {
let newUrl = this._scratchTwitter;
let oldUrl = this.get('settings.twitter');
let errMessage = '';
// reset errors and validation
this.get('settings.errors').remove('twitter');
this.get('settings.hasValidated').removeObject('twitter');
if (!newUrl) {
if (newUrl === '') {
// Clear out the Twitter url
this.set('settings.twitter', '');
return;
}
// _scratchTwitter will be null unless the user has input something
if (!newUrl) {
newUrl = oldUrl;
}
if (newUrl.match(/(?:twitter\.com\/)(\S+)/) || newUrl.match(/([a-z\d.]+)/i)) {
let username = [];

View File

@ -87,18 +87,24 @@ export default Controller.extend({
actions: {
validateFacebookUrl() {
let newUrl = this._scratchFacebook;
let oldUrl = this.get('user.facebook');
let errMessage = '';
// reset errors and validation
this.get('user.errors').remove('facebook');
this.get('user.hasValidated').removeObject('facebook');
if (!newUrl) {
if (newUrl === '') {
// Clear out the Facebook url
this.set('user.facebook', '');
return;
}
// _scratchFacebook will be null unless the user has input something
if (!newUrl) {
newUrl = oldUrl;
}
try {
// strip any facebook URLs out
newUrl = newUrl.replace(/(https?:\/\/)?(www\.)?facebook\.com/i, '');
@ -137,18 +143,24 @@ export default Controller.extend({
validateTwitterUrl() {
let newUrl = this._scratchTwitter;
let oldUrl = this.get('user.twitter');
let errMessage = '';
// reset errors and validation
this.get('user.errors').remove('twitter');
this.get('user.hasValidated').removeObject('twitter');
if (!newUrl) {
if (newUrl === '') {
// Clear out the Twitter url
this.set('user.twitter', null);
this.set('user.twitter', '');
return;
}
// _scratchTwitter will be null unless the user has input something
if (!newUrl) {
newUrl = oldUrl;
}
if (newUrl.match(/(?:twitter\.com\/)(\S+)/) || newUrl.match(/([a-z\d.]+)/i)) {
let username = [];
@ -381,18 +393,6 @@ export default Controller.extend({
}
}).group('saveHandlers'),
saveViaKeyboard: action(function (event) {
event.preventDefault();
event.stopImmediatePropagation();
// trigger a blur and wait for any resulting validation actions to complete
document.activeElement.blur();
run.schedule('actions', () => {
this.save.perform();
});
}),
copyContentKey: task(function* () {
copyTextToClipboard(this.personalToken);
yield timeout(this.isTesting ? 50 : 3000);