From 65a8f56fa0cfb496c46f3b819a6f7291a81a7322 Mon Sep 17 00:00:00 2001 From: decoy Date: Wed, 14 Oct 2020 13:42:42 +0530 Subject: [PATCH 1/3] trimmed potential recipent id with white space --- src/app/inbox/inbox-compose/inbox-compose.component.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/app/inbox/inbox-compose/inbox-compose.component.ts b/src/app/inbox/inbox-compose/inbox-compose.component.ts index 7d3d216..e2b265b 100644 --- a/src/app/inbox/inbox-compose/inbox-compose.component.ts +++ b/src/app/inbox/inbox-compose/inbox-compose.component.ts @@ -145,8 +145,10 @@ export class InboxComposeComponent implements OnInit { this.setRecipientLoadingText() this.resetModelToField() } - this.currentRecipientValue = event.target.value - this.recipientAddressChanged.next(event.target.value); + if (event.target.value && event.target.value.length > 0) { + this.currentRecipientValue = event.target.value.trim(); + this.recipientAddressChanged.next(event.target.value); + } } /** From 9529b3003c705192fac107543af49e2372862031 Mon Sep 17 00:00:00 2001 From: Tim B Date: Thu, 4 Feb 2021 20:18:09 +0000 Subject: [PATCH 2/3] add tests for whitespace --- .../inbox-compose/inbox-compose.component.spec.ts | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/app/inbox/inbox-compose/inbox-compose.component.spec.ts b/src/app/inbox/inbox-compose/inbox-compose.component.spec.ts index c4a0ea8..a081de5 100644 --- a/src/app/inbox/inbox-compose/inbox-compose.component.spec.ts +++ b/src/app/inbox/inbox-compose/inbox-compose.component.spec.ts @@ -291,6 +291,19 @@ describe('InboxComposeComponent', () => { component.recipientResolve(event) expect(component.currentRecipientValue).toEqual("alice.eth") }) + it('should trim whitespace from currentRecipientValue', () => { + let event = { target: { value: " alice.eth " } } + + component.recipientResolve(event) + expect(component.currentRecipientValue).toEqual("alice.eth") + }) + it('should trim whitespace from the call to recipientAddressChanged', () => { + let event = { target: { value: " alice.eth " } } + spyOn(component.recipientAddressChanged, 'next').and.callThrough() + + component.recipientResolve(event) + expect(component.recipientAddressChanged.next).toHaveBeenCalledWith("alice.eth") + }) xit('should call the resolveAddress thru the private recipientAddressChanged subscription next function with the event.target.value', () => { let event = { target: { value: "alice.eth" } } spyOn(component, 'resolveAddress').and.callThrough() From e802c276b0ad4fd32d0310366763bcba259c303e Mon Sep 17 00:00:00 2001 From: Tim B Date: Thu, 4 Feb 2021 20:28:20 +0000 Subject: [PATCH 3/3] Update variable; Fix text by trimming the event.target.value at the start of the function. Remove if statement because we still want the currentRecipentValue & recipientAddressChanged to take the eventVal, even if it's no value --- .../inbox/inbox-compose/inbox-compose.component.ts | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/app/inbox/inbox-compose/inbox-compose.component.ts b/src/app/inbox/inbox-compose/inbox-compose.component.ts index e2b265b..7a5a859 100644 --- a/src/app/inbox/inbox-compose/inbox-compose.component.ts +++ b/src/app/inbox/inbox-compose/inbox-compose.component.ts @@ -39,7 +39,7 @@ export class InboxComposeComponent implements OnInit { private subscription public currentRecipientValue - private recipientAddressChanged = new Subject(); + public recipientAddressChanged = new Subject(); public recipientLoadingIcon = "" public recipientLoadingText = "" public messageToField = "" @@ -136,19 +136,19 @@ export class InboxComposeComponent implements OnInit { * @param event the event from keyup */ public recipientResolve(event) { - if (event.target.value == "") { + let eventVal = event.target.value.trim(); + if (eventVal == "") { this.setRecipientLoadingIcon("clear") this.setRecipientLoadingText() this.resetModelToField() - } else if (this.currentRecipientValue != event.target.value) { + } else if (this.currentRecipientValue != eventVal) { this.setRecipientLoadingIcon("loading") this.setRecipientLoadingText() this.resetModelToField() } - if (event.target.value && event.target.value.length > 0) { - this.currentRecipientValue = event.target.value.trim(); - this.recipientAddressChanged.next(event.target.value); - } + this.currentRecipientValue = eventVal + this.recipientAddressChanged.next(eventVal); + } /**